1
1
import lldb
2
- import re
3
2
import debugger_pretty_printers_common as rustpp
4
3
5
- #===============================================================================
4
+ # ===============================================================================
6
5
# LLDB Pretty Printing Module for Rust
7
- #===============================================================================
6
+ # ===============================================================================
7
+
8
8
9
9
class LldbType (rustpp .Type ):
10
10
@@ -84,16 +84,16 @@ def print_val(lldb_val, internal_dict):
84
84
type_kind == rustpp .TYPE_KIND_EMPTY ):
85
85
return print_struct_val (val ,
86
86
internal_dict ,
87
- omit_first_field = False ,
88
- omit_type_name = False ,
89
- is_tuple_like = False )
87
+ omit_first_field = False ,
88
+ omit_type_name = False ,
89
+ is_tuple_like = False )
90
90
91
91
if type_kind == rustpp .TYPE_KIND_STRUCT_VARIANT :
92
92
return print_struct_val (val ,
93
93
internal_dict ,
94
- omit_first_field = True ,
95
- omit_type_name = False ,
96
- is_tuple_like = False )
94
+ omit_first_field = True ,
95
+ omit_type_name = False ,
96
+ is_tuple_like = False )
97
97
98
98
if type_kind == rustpp .TYPE_KIND_SLICE :
99
99
return print_vec_slice_val (val , internal_dict )
@@ -110,26 +110,26 @@ def print_val(lldb_val, internal_dict):
110
110
if type_kind == rustpp .TYPE_KIND_TUPLE :
111
111
return print_struct_val (val ,
112
112
internal_dict ,
113
- omit_first_field = False ,
114
- omit_type_name = True ,
115
- is_tuple_like = True )
113
+ omit_first_field = False ,
114
+ omit_type_name = True ,
115
+ is_tuple_like = True )
116
116
117
117
if type_kind == rustpp .TYPE_KIND_TUPLE_STRUCT :
118
118
return print_struct_val (val ,
119
119
internal_dict ,
120
- omit_first_field = False ,
121
- omit_type_name = False ,
122
- is_tuple_like = True )
120
+ omit_first_field = False ,
121
+ omit_type_name = False ,
122
+ is_tuple_like = True )
123
123
124
124
if type_kind == rustpp .TYPE_KIND_CSTYLE_VARIANT :
125
125
return val .type .get_unqualified_type_name ()
126
126
127
127
if type_kind == rustpp .TYPE_KIND_TUPLE_VARIANT :
128
128
return print_struct_val (val ,
129
129
internal_dict ,
130
- omit_first_field = True ,
131
- omit_type_name = False ,
132
- is_tuple_like = True )
130
+ omit_first_field = True ,
131
+ omit_type_name = False ,
132
+ is_tuple_like = True )
133
133
134
134
if type_kind == rustpp .TYPE_KIND_SINGLETON_ENUM :
135
135
return print_val (lldb_val .GetChildAtIndex (0 ), internal_dict )
@@ -157,9 +157,9 @@ def print_val(lldb_val, internal_dict):
157
157
return lldb_val .GetValue ()
158
158
159
159
160
- #=--------------------------------------------------------------------------------------------------
160
+ # =--------------------------------------------------------------------------------------------------
161
161
# Type-Specialized Printing Functions
162
- #=--------------------------------------------------------------------------------------------------
162
+ # =--------------------------------------------------------------------------------------------------
163
163
164
164
def print_struct_val (val , internal_dict , omit_first_field , omit_type_name , is_tuple_like ):
165
165
"""
@@ -212,6 +212,7 @@ def render_child(child_index):
212
212
return template % {"type_name" : type_name ,
213
213
"body" : body }
214
214
215
+
215
216
def print_pointer_val (val , internal_dict ):
216
217
"""Prints a pointer value with Rust syntax"""
217
218
assert val .type .get_dwarf_type_kind () == rustpp .DWARF_TYPE_CODE_PTR
@@ -253,18 +254,21 @@ def print_std_vec_val(val, internal_dict):
253
254
length ,
254
255
internal_dict )
255
256
257
+
256
258
def print_str_slice_val (val , internal_dict ):
257
259
(length , data_ptr ) = rustpp .extract_length_and_ptr_from_slice (val )
258
260
return read_utf8_string (data_ptr , length )
259
261
262
+
260
263
def print_std_string_val (val , internal_dict ):
261
264
vec = val .get_child_at_index (0 )
262
265
(length , data_ptr , cap ) = rustpp .extract_length_ptr_and_cap_from_std_vec (vec )
263
266
return read_utf8_string (data_ptr , length )
264
267
265
- #=--------------------------------------------------------------------------------------------------
268
+ # =--------------------------------------------------------------------------------------------------
266
269
# Helper Functions
267
- #=--------------------------------------------------------------------------------------------------
270
+ # =--------------------------------------------------------------------------------------------------
271
+
268
272
269
273
def print_array_of_values (array_name , data_ptr_val , length , internal_dict ):
270
274
"""Prints a contiguous memory range, interpreting it as values of the
0 commit comments