Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,10 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
stl_summary_flags, true);

AddCXXSummary(cpp_category_sp, ContainerSizeSummaryProvider,
"libstdc++ std::tuple summary provider",
"^std::tuple<.*>(( )?&)?$", stl_summary_flags, true);

cpp_category_sp->AddTypeSummary(
"^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
eFormatterMatchRegex,
Expand Down Expand Up @@ -1546,7 +1550,7 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibStdcppTupleSyntheticFrontEndCreator,
"std::tuple synthetic children", "^std::tuple<.+>(( )?&)?$",
"std::tuple synthetic children", "^std::tuple<.*>(( )?&)?$",
stl_synth_flags, true);

static constexpr const char *const libstdcpp_std_coroutine_handle_regex =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CXX_SOURCES := main.cpp

USE_LIBCPP := 1
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""
Test lldb data formatter subsystem.
"""

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class TestDataFormatterStdTuple(TestBase):
def setUp(self):
TestBase.setUp(self)
self.line = line_number("main.cpp", "// break here")
self.namespace = "std"

def do_test(self):
"""Test that std::tuple is displayed correctly"""
lldbutil.run_to_source_breakpoint(
self, "// break here", lldb.SBFileSpec("main.cpp", False)
)

tuple_name = self.namespace + "::tuple"
self.expect("frame variable empty", substrs=[tuple_name, "size=0", "{}"])

self.expect(
"frame variable one_elt",
substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"],
)

self.expect(
"frame variable three_elts",
substrs=[
tuple_name,
"size=3",
"{",
"[0] = 1",
"[1] = 47",
'[2] = "foo"',
"}",
],
)

frame = self.frame()
self.assertTrue(frame.IsValid())

self.assertEqual(
47, frame.GetValueForVariablePath("one_elt[0]").GetValueAsUnsigned()
)
self.assertFalse(frame.GetValueForVariablePath("one_elt[1]").IsValid())

self.assertEqual(
'"foobar"', frame.GetValueForVariablePath("string_elt[0]").GetSummary()
)
self.assertFalse(frame.GetValueForVariablePath("string_elt[1]").IsValid())

self.assertEqual(
1, frame.GetValueForVariablePath("three_elts[0]").GetValueAsUnsigned()
)
self.assertEqual(
47, frame.GetValueForVariablePath("three_elts[1]").GetValueAsUnsigned()
)
self.assertEqual(
'"foo"', frame.GetValueForVariablePath("three_elts[2]").GetSummary()
)
self.assertFalse(frame.GetValueForVariablePath("three_elts[3]").IsValid())

@add_test_categories(["libc++"])
def test_libcxx(self):
self.build(dictionary={"USE_LIBCPP": 1})
self.do_test()

@add_test_categories(["libstdcxx"])
def test_libstdcxx(self):
self.build(dictionary={"USE_LIBSTDCPP": 1})
self.do_test()
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <tuple>
#include <string>
#include <tuple>

int main() {
std::tuple<> empty;
std::tuple<int> one_elt{47};
std::tuple<std::string> string_elt{"foobar"};
std::tuple<int, long, std::string> three_elts{1, 47l, "foo"};
return 0; // break here
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading