Skip to content

Commit cfcc5c2

Browse files
authored
Unrolled build for #148540
Rollup merge of #148540 - tromey:non-zero-gdb-cleanup, r=bjorn3 Minor fixes to StdNonZeroNumberProvider for gdb While looking at the pretty-printers, I found a few minor oddities in StdNonZeroNumberProvider. First, gdb.Type.fields() already returns a sequence, so there's no need to call list(). Second, it's more idiomatic for the (somewhat misnamed) to_string method to simply return the underlying gdb.Value. This also lets gdb apply whatever formats were passed to `print`, as the new test shows. Third, there's no need to use the field's name when looking up a field in a value, the gdb.Field itself can be used.
2 parents 401ae55 + 71e2e0c commit cfcc5c2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/etc/gdb_providers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ class StdNonZeroNumberProvider(printer_base):
252252
def __init__(self, valobj):
253253
fields = valobj.type.fields()
254254
assert len(fields) == 1
255-
field = list(fields)[0]
255+
field = fields[0]
256256

257-
inner_valobj = valobj[field.name]
257+
inner_valobj = valobj[field]
258258

259259
inner_fields = inner_valobj.type.fields()
260260
assert len(inner_fields) == 1
261-
inner_field = list(inner_fields)[0]
261+
inner_field = inner_fields[0]
262262

263-
self._value = str(inner_valobj[inner_field.name])
263+
self._value = inner_valobj[inner_field]
264264

265265
def to_string(self):
266266
return self._value

tests/debuginfo/numeric-types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
// gdb-command:print nz_usize
203203
// gdb-check:[...]$12 = 122
204204

205+
// gdb-command:print/x nz_i8
206+
// gdb-check:[...]$13 = 0xb
205207

206208

207209
// === LLDB TESTS ==================================================================================

0 commit comments

Comments
 (0)