forked from qt-creator/qt-creator
Debugger: Add debugging helper for std::tuple
Add debugging helper for std::tuple and add
a corresponding dumper test for it.
With this in place, the std::tuple variable and its elements
in the "tuple.cpp" sample program from QTCREATORBUG-25865 are
shown as expected on both, Linux (libstdc++) with GDB or LLDB and with
an MSVC build with CDB on Windows.
A debugging helper for libc++ had already been added in commit
34ff9c97e6
.
Task-number: QTCREATORBUG-25865
Change-Id: I24b3d36b5daa26fd4fcb073c4df79015dfe752fc
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -697,6 +697,36 @@ def qdump__std__pair(d, value):
|
||||
d.putValue('(%s, %s)' % (key, value))
|
||||
|
||||
|
||||
def qdumpHelper_get_tuple_elements(d, tuple, value_typename, value_member):
|
||||
"""
|
||||
Helper method that returns the elements of a tuple.
|
||||
"""
|
||||
elems = []
|
||||
other_members = []
|
||||
for member in tuple.members(True):
|
||||
if not member.type.templateArguments():
|
||||
continue
|
||||
if member.type.name.startswith(value_typename):
|
||||
elems.append(member[value_member])
|
||||
else:
|
||||
other_members.append(member)
|
||||
for member in other_members:
|
||||
sub_elems = qdumpHelper_get_tuple_elements(d, member, value_typename, value_member)
|
||||
elems = elems + sub_elems
|
||||
return elems
|
||||
|
||||
|
||||
def qdump__std__tuple(d, value):
|
||||
if d.isMsvcTarget():
|
||||
elems = qdumpHelper_get_tuple_elements(d, value, "std::_Tuple_val", "_Val")
|
||||
else:
|
||||
elems = qdumpHelper_get_tuple_elements(d, value, "std::_Head_base", "_M_head_impl")
|
||||
d.putItemCount(len(elems))
|
||||
with Children(d):
|
||||
for elem in elems:
|
||||
d.putSubItem(0, elem)
|
||||
|
||||
|
||||
def qform__std__unordered_map():
|
||||
return [DisplayFormat.CompactMap]
|
||||
|
||||
|
@@ -5348,6 +5348,18 @@ void tst_Dumpers::dumper_data()
|
||||
+ Check("v.0", "[0]", "\"foo\"", "std::string");
|
||||
|
||||
|
||||
QTest::newRow("StdTuple")
|
||||
<< Data("#include <string>\n",
|
||||
|
||||
"std::tuple<int, std::string, int> tuple = std::make_tuple(123, std::string(\"hello\"), 456);\n",
|
||||
|
||||
"&tuple")
|
||||
|
||||
+ Check("tuple.0", "[0]", "123", "int")
|
||||
+ Check("tuple.1", "[1]", "\"hello\"", "std::string")
|
||||
+ Check("tuple.2", "[2]", "456", "int");
|
||||
|
||||
|
||||
QTest::newRow("StdValArray")
|
||||
<< Data("#include <valarray>\n"
|
||||
"#include <list>\n",
|
||||
|
Reference in New Issue
Block a user