Skip to content

Fix GDB pretty-printer for tuples and pointers #42278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 9, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def get_child_at_index(self, index):

def as_integer(self):
if self.gdb_val.type.code == gdb.TYPE_CODE_PTR:
return int(str(self.gdb_val), 0)
as_str = unicode(self.gdb_val).split()[0]
return int(as_str, 0)
return int(self.gdb_val)

def get_wrapped_value(self):
Expand Down Expand Up @@ -186,10 +187,10 @@ def children(self):
cs = []
wrapped_value = self.__val.get_wrapped_value()

for field in self.__val.type.get_fields():
for number, field in enumerate(self.__val.type.get_fields()):
field_value = wrapped_value[field.name]
if self.__is_tuple_like:
cs.append(("", field_value))
cs.append((str(number), field_value))
else:
cs.append((field.name, field_value))

Expand Down
5 changes: 5 additions & 0 deletions src/test/debuginfo/pretty-std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
// gdbg-check:$6 = None
// gdbr-check:$6 = core::option::Option::None

// gdb-command: print some_string
// gdbr-check:$7 = Some = {"IAMA optional string!"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try making this gdb-check instead of just gdbr-check, so both kinds of GDB are tested.



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

Expand Down Expand Up @@ -82,6 +85,8 @@ fn main() {
let some = Some(8i16);
let none: Option<i64> = None;

let some_string = Some("IAMA optional string!".to_owned());

zzz(); // #break
}

Expand Down