From 0313cdbd87a6726194ec25ddff707a6b74389c88 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 21 Jun 2019 09:18:14 +0200 Subject: [PATCH] gdbbridge: Convert children to gdb.Value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'Dumper::fromNativeValue' expects an object of type 'gdb.Value'. However, the 'pretty_printer.children()' iterator may return values that first need to be converted to this, as documented for function 'pretty_printer.children' at [1]: > This method must return an object conforming to the Python iterator > protocol. Each item returned by the iterator must be a tuple holding two > elements. The first element is the “name” of the child; the second > element is the child’s value. The value can be any Python object which > is convertible to a GDB value. Therefore, explicitly convert the value to a GDB value first. This fixes the expansion of 'std::vector' when system GDB pretty printers are enabled which previously led to "" being shown e.g. for the following example (expand 'v' in the local variable view at the breakpoint): #include int main() { std::vector v; v.push_back(true); return 0; // insert breakpoint here } Side note: GCC's pretty printer for 'std::vector' previously returned either '0' or '1' for the element values, thus leading to the problem described above. With this patch in place, the elements are shown when the vector is expanded, but the shown type is 'long long' (since that's the type that GDB seems to automatically assign when constructing a 'gdb.Value' from these integers, at least with GDB 8.2.1 on amd64). This will work as expected ('bool' shown as type) from GCC commit [2] on ("Have std::vector printer's iterator return bool for vector"). [1] https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html [2] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6c7d761a3f5fd7d19795d1d4b9b027a04b3fe88b Change-Id: I9047affa5b4369befd2e2386c8a6b04c66c4b632 Reviewed-by: hjk --- share/qtcreator/debugger/gdbbridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index fdfb39746e4..2f056c7a932 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -153,7 +153,7 @@ class PlainDumper: if d.isExpanded(): with Children(d): for child in children: - d.putSubItem(child[0], d.fromNativeValue(child[1])) + d.putSubItem(child[0], d.fromNativeValue(gdb.Value(child[1]))) def importPlainDumpers(args): if args == 'off':