File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 46
46
TYPE_KIND_PTR = 15
47
47
TYPE_KIND_FIXED_SIZE_VEC = 16
48
48
TYPE_KIND_REGULAR_UNION = 17
49
+ TYPE_KIND_OS_STRING = 18
49
50
50
51
ENCODED_ENUM_PREFIX = "RUST$ENCODED$ENUM$"
51
52
ENUM_DISR_FIELD_NAME = "RUST$ENUM$DISR"
64
65
# std::String related constants
65
66
STD_STRING_FIELD_NAMES = ["vec" ]
66
67
68
+ # std::ffi::OsString related constants
69
+ OS_STRING_FIELD_NAMES = ["inner" ]
70
+
67
71
68
72
class Type (object ):
69
73
"""
@@ -162,6 +166,11 @@ def __classify_struct(self):
162
166
self .__conforms_to_field_layout (STD_STRING_FIELD_NAMES )):
163
167
return TYPE_KIND_STD_STRING
164
168
169
+ # OS STRING
170
+ if (unqualified_type_name == "OsString" and
171
+ self .__conforms_to_field_layout (OS_STRING_FIELD_NAMES )):
172
+ return TYPE_KIND_OS_STRING
173
+
165
174
# ENUM VARIANTS
166
175
if fields [0 ].name == ENUM_DISR_FIELD_NAME :
167
176
if field_count == 1 :
Original file line number Diff line number Diff line change @@ -125,6 +125,9 @@ def rust_pretty_printer_lookup_function(gdb_val):
125
125
if type_kind == rustpp .TYPE_KIND_STD_STRING :
126
126
return RustStdStringPrinter (val )
127
127
128
+ if type_kind == rustpp .TYPE_KIND_OS_STRING :
129
+ return RustOsStringPrinter (val )
130
+
128
131
if type_kind == rustpp .TYPE_KIND_TUPLE :
129
132
return RustStructPrinter (val ,
130
133
omit_first_field = False ,
@@ -269,6 +272,21 @@ def to_string(self):
269
272
length = length )
270
273
271
274
275
+ class RustOsStringPrinter (object ):
276
+ def __init__ (self , val ):
277
+ self .__val = val
278
+
279
+ def to_string (self ):
280
+ buf = self .__val .get_child_at_index (0 )
281
+ vec = buf .get_child_at_index (0 )
282
+ if vec .type .get_unqualified_type_name () == "Wtf8Buf" :
283
+ vec = vec .get_child_at_index (0 )
284
+
285
+ (length , data_ptr , cap ) = rustpp .extract_length_ptr_and_cap_from_std_vec (
286
+ vec )
287
+ return '"%s"' % data_ptr .get_wrapped_value ().string (length = length )
288
+
289
+
272
290
class RustCStyleVariantPrinter (object ):
273
291
def __init__ (self , val ):
274
292
assert val .type .get_dwarf_type_kind () == rustpp .DWARF_TYPE_CODE_ENUM
Original file line number Diff line number Diff line change 38
38
// gdbg-check:$6 = None
39
39
// gdbr-check:$6 = core::option::Option::None
40
40
41
- // gdb-command: print some_string
42
- // gdbr-check:$7 = Some = {"IAMA optional string!"}
41
+ // gdbr-command: print os_string
42
+ // gdbr-check:$7 = "IAMA OS string 😃"
43
+
44
+ // gdbr-command: print some_string
45
+ // gdbr-check:$8 = Some = {"IAMA optional string!"}
43
46
44
47
45
48
// === LLDB TESTS ==================================================================================
66
69
67
70
68
71
#![ allow( unused_variables) ]
72
+ use std:: ffi:: OsString ;
73
+
69
74
70
75
fn main ( ) {
71
76
@@ -81,6 +86,9 @@ fn main() {
81
86
// String
82
87
let string = "IAMA string!" . to_string ( ) ;
83
88
89
+ // OsString
90
+ let os_string = OsString :: from ( "IAMA OS string \u{1F603} " ) ;
91
+
84
92
// Option
85
93
let some = Some ( 8i16 ) ;
86
94
let none: Option < i64 > = None ;
You can’t perform that action at this time.
0 commit comments