Skip to content

Commit 59f9cef

Browse files
committed
[lldb] review changes.
1 parent ce0695a commit 59f9cef

File tree

12 files changed

+80
-79
lines changed

12 files changed

+80
-79
lines changed

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ class NodeAllocator {
592592
public:
593593
void reset() { Alloc.Reset(); }
594594

595-
template <typename T, typename... Args> T *makeNode(Args &&... args) {
595+
template <typename T, typename... Args> T *makeNode(Args &&...args) {
596596
return new (Alloc.Allocate(sizeof(T), alignof(T)))
597597
T(std::forward<Args>(args)...);
598598
}
@@ -614,7 +614,7 @@ class ManglingSubstitutor
614614
ManglingSubstitutor() : Base(nullptr, nullptr) {}
615615

616616
template <typename... Ts>
617-
ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) {
617+
ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) {
618618
this->getDerived().reset(Mangled, std::forward<Ts>(Vals)...);
619619
return substituteImpl(Mangled);
620620
}
@@ -1450,109 +1450,109 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
14501450

14511451
cpp_category_sp->AddTypeSynthetic(
14521452
"^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex,
1453-
std::make_shared<ScriptedSyntheticChildren>(
1453+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14541454
stl_synth_flags,
1455-
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider"));
1455+
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
14561456
cpp_category_sp->AddTypeSynthetic(
14571457
"^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex,
1458-
std::make_shared<ScriptedSyntheticChildren>(
1458+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14591459
stl_synth_flags,
1460-
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"));
1460+
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
14611461
cpp_category_sp->AddTypeSynthetic(
14621462
"^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex,
1463-
std::make_shared<ScriptedSyntheticChildren>(
1463+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14641464
stl_deref_flags,
1465-
"lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"));
1465+
"lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider")));
14661466
cpp_category_sp->AddTypeSynthetic(
14671467
"^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex,
1468-
std::make_shared<ScriptedSyntheticChildren>(
1468+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14691469
stl_deref_flags,
1470-
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"));
1470+
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
14711471
cpp_category_sp->AddTypeSynthetic(
14721472
"^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex,
1473-
std::make_shared<ScriptedSyntheticChildren>(
1473+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14741474
stl_deref_flags,
1475-
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"));
1475+
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
14761476
cpp_category_sp->AddTypeSynthetic(
14771477
"^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex,
1478-
std::make_shared<ScriptedSyntheticChildren>(
1478+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14791479
stl_deref_flags,
1480-
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"));
1480+
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
14811481
cpp_category_sp->AddTypeSynthetic(
14821482
"^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$",
14831483
eFormatterMatchRegex,
1484-
std::make_shared<ScriptedSyntheticChildren>(
1484+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14851485
stl_deref_flags,
1486-
"lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"));
1486+
"lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider")));
14871487
cpp_category_sp->AddTypeSynthetic(
14881488
"^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
14891489
eFormatterMatchRegex,
1490-
std::make_shared<ScriptedSyntheticChildren>(
1490+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14911491
stl_deref_flags,
1492-
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"));
1492+
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
14931493
cpp_category_sp->AddTypeSynthetic(
14941494
"^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
14951495
eFormatterMatchRegex,
1496-
std::make_shared<ScriptedSyntheticChildren>(
1496+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14971497
stl_synth_flags,
1498-
"lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider"));
1498+
"lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider")));
14991499
cpp_category_sp->AddTypeSynthetic(
15001500
"^std::variant<.+>$", eFormatterMatchRegex,
1501-
std::make_shared<ScriptedSyntheticChildren>(
1501+
SyntheticChildrenSP(new ScriptedSyntheticChildren(
15021502
stl_synth_flags,
1503-
"lldb.formatters.cpp.gnu_libstdcpp.VariantSynthProvider"));
1503+
"lldb.formatters.cpp.gnu_libstdcpp.VariantSynthProvider")));
15041504

15051505
stl_summary_flags.SetDontShowChildren(false);
15061506
stl_summary_flags.SetSkipPointers(false);
15071507
cpp_category_sp->AddTypeSummary("^std::(__debug::)?bitset<.+>(( )?&)?$",
15081508
eFormatterMatchRegex,
1509-
std::make_shared<StringSummaryFormat>(
1510-
stl_summary_flags, "size=${svar%#}"));
1509+
TypeSummaryImplSP(new StringSummaryFormat(
1510+
stl_summary_flags, "size=${svar%#}")));
15111511
cpp_category_sp->AddTypeSummary("^std::(__debug::)?vector<.+>(( )?&)?$",
15121512
eFormatterMatchRegex,
1513-
std::make_shared<StringSummaryFormat>(
1514-
stl_summary_flags, "size=${svar%#}"));
1513+
TypeSummaryImplSP(new StringSummaryFormat(
1514+
stl_summary_flags, "size=${svar%#}")));
15151515
cpp_category_sp->AddTypeSummary("^std::(__debug::)?map<.+> >(( )?&)?$",
15161516
eFormatterMatchRegex,
1517-
std::make_shared<StringSummaryFormat>(
1518-
stl_summary_flags, "size=${svar%#}"));
1517+
TypeSummaryImplSP(new StringSummaryFormat(
1518+
stl_summary_flags, "size=${svar%#}")));
15191519
cpp_category_sp->AddTypeSummary("^std::(__debug::)?set<.+> >(( )?&)?$",
15201520
eFormatterMatchRegex,
1521-
std::make_shared<StringSummaryFormat>(
1522-
stl_summary_flags, "size=${svar%#}"));
1521+
TypeSummaryImplSP(new StringSummaryFormat(
1522+
stl_summary_flags, "size=${svar%#}")));
15231523
cpp_category_sp->AddTypeSummary("^std::(__debug::)?deque<.+>(( )?&)?$",
15241524
eFormatterMatchRegex,
1525-
std::make_shared<StringSummaryFormat>(
1526-
stl_summary_flags, "size=${svar%#}"));
1525+
TypeSummaryImplSP(new StringSummaryFormat(
1526+
stl_summary_flags, "size=${svar%#}")));
15271527
cpp_category_sp->AddTypeSummary("^std::(__debug::)?multimap<.+> >(( )?&)?$",
15281528
eFormatterMatchRegex,
1529-
std::make_shared<StringSummaryFormat>(
1530-
stl_summary_flags, "size=${svar%#}"));
1529+
TypeSummaryImplSP(new StringSummaryFormat(
1530+
stl_summary_flags, "size=${svar%#}")));
15311531
cpp_category_sp->AddTypeSummary("^std::(__debug::)?multiset<.+> >(( )?&)?$",
15321532
eFormatterMatchRegex,
1533-
std::make_shared<StringSummaryFormat>(
1534-
stl_summary_flags, "size=${svar%#}"));
1533+
TypeSummaryImplSP(new StringSummaryFormat(
1534+
stl_summary_flags, "size=${svar%#}")));
15351535
cpp_category_sp->AddTypeSummary(
15361536
"^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$",
15371537
eFormatterMatchRegex,
1538-
std::make_shared<StringSummaryFormat>(stl_summary_flags,
1539-
"size=${svar%#}"));
1538+
TypeSummaryImplSP(
1539+
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
15401540
cpp_category_sp->AddTypeSummary(
15411541
"^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
15421542
eFormatterMatchRegex,
1543-
std::make_shared<StringSummaryFormat>(stl_summary_flags,
1544-
"size=${svar%#}"));
1543+
TypeSummaryImplSP(
1544+
new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
15451545
cpp_category_sp->AddTypeSummary(
15461546
"^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
15471547
eFormatterMatchRegex,
1548-
std::make_shared<ScriptSummaryFormat>(
1548+
TypeSummaryImplSP(new ScriptSummaryFormat(
15491549
stl_summary_flags,
1550-
"lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider"));
1550+
"lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider")));
15511551
cpp_category_sp->AddTypeSummary(
15521552
"^std::variant<.+>$", eFormatterMatchRegex,
1553-
std::make_shared<ScriptSummaryFormat>(
1553+
TypeSummaryImplSP(new ScriptSummaryFormat(
15541554
stl_summary_flags,
1555-
"lldb.formatters.cpp.gnu_libstdcpp.VariantSummaryProvider"));
1555+
"lldb.formatters.cpp.gnu_libstdcpp.VariantSummaryProvider")));
15561556

15571557
AddCXXSynthetic(
15581558
cpp_category_sp,
@@ -1737,6 +1737,9 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
17371737
DataVisualization::Categories::GetCategory(ConstString(GetPluginName()),
17381738
g_category);
17391739
if (g_category) {
1740+
// NOTE: the libstdcpp formatters are loaded after libcxx formatters
1741+
// because of a conflict matching the `__debug`namespace in libstdcpp.
1742+
// since lldb priorities the last loaded matching formatter.
17401743
LoadLibCxxFormatters(g_category);
17411744
LoadLibStdcppFormatters(g_category);
17421745
LoadSystemFormatters(g_category);

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/DataFormatterStdMap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
from abc import abstractmethod
6-
from lldbsuite.test.decorators import add_test_categories, expectedFailureAll
76
from lldbsuite.test.lldbtest import (
87
CURRENT_EXECUTABLE_SET,
98
RUN_SUCCEEDED,
@@ -25,9 +24,10 @@ def setUp(self):
2524
def test_with_run_command(self):
2625
pass
2726

28-
def with_run_command(self, artifact_name: str, namespace: str = ""):
27+
def with_run_command(self, namespace: str, dictionary: dict):
2928
"""Test that that file and class static variables display correctly."""
30-
self.build()
29+
self.build(dictionary=dictionary)
30+
artifact_name = dictionary.get("EXE", "a.out")
3131
self.runCmd(
3232
"file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
3333
)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ class StdMapDataFormatter(StdMapDataFormatterBase):
1212
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
1313
@override
1414
def test_with_run_command(self):
15-
self.with_run_command("a.out")
15+
build_args = {"EXE": "a.out"}
16+
self.with_run_command("", build_args)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMapWithDebug.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ class StdMapDataFormatterWithDebug(StdMapDataFormatterBase):
1212
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
1313
@override
1414
def test_with_run_command(self):
15-
self.with_run_command("debug_a.out", "__debug::")
15+
build_args = {"_GLIBCXX_DEBUG": 1, "EXE": "debug_a.out"}
16+
self.with_run_command("__debug::", build_args)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/DataFormatterStdVBool.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
"""
44

55
from abc import abstractmethod
6-
from lldbsuite.test.decorators import add_test_categories
7-
from lldbsuite.test.lldbtest import CURRENT_EXECUTABLE_SET, RUN_SUCCEEDED, STOPPED_DUE_TO_BREAKPOINT, TestBase, \
8-
line_number
6+
from lldbsuite.test.lldbtest import (
7+
CURRENT_EXECUTABLE_SET,
8+
RUN_SUCCEEDED,
9+
STOPPED_DUE_TO_BREAKPOINT,
10+
TestBase,
11+
line_number,
12+
)
913
from lldbsuite.test import lldbutil
1014

1115

@@ -20,10 +24,13 @@ def setUp(self):
2024
def test_with_run_command(self):
2125
pass
2226

23-
def with_run_command(self, artifact_name: str):
27+
def with_run_command(self, dictionary: dict):
2428
"""Test that that file and class static variables display correctly."""
25-
self.build()
26-
self.runCmd("file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET)
29+
self.build(dictionary=dictionary)
30+
artifact_name = dictionary.get("EXE", "a.out")
31+
self.runCmd(
32+
"file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
33+
)
2734

2835
lldbutil.run_break_set_by_file_and_line(
2936
self, "main.cpp", self.line, num_expected_locations=-1
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
CXX_SOURCES := main.cpp
22

3-
CXXFLAGS := -O0
3+
CFLAGS_EXTRAS := -O0
44
USE_LIBSTDCPP := 1
55

6-
all: debug_a.out
7-
86
include Makefile.rules
9-
10-
debug_main.o: main.cpp
11-
$(CXX) $(PCHFLAGS) $(CXXFLAGS) -D_GLIBCXX_DEBUG -MT $@ -MD -MP -MF $*.d -c -o $@ $<
12-
13-
debug_a.out: debug_main.o
14-
$(LD) debug_main.o $(LDFLAGS) -o debug_a.out

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class StdVBoolDataFormatter(StdVBoolDataFormatterBase):
1111
@add_test_categories(["libstdcxx"])
1212
@override
1313
def test_with_run_command(self):
14-
self.with_run_command("a.out")
14+
build_args = {"EXE": "a.out"}
15+
self.with_run_command(build_args)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBoolWithDebug.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ class StdVBoolDataFormatterWithDebug(StdVBoolDataFormatterBase):
1111
@add_test_categories(["libstdcxx"])
1212
@override
1313
def test_with_run_command(self):
14-
self.with_run_command("debug_a.out")
14+
build_args = {"EXE": "debug_a.out", "_GLIBCXX_DEBUG": 1}
15+
self.with_run_command(build_args)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/DataFormatterStdVector.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ def setUp(self):
2424
def test_with_run_command(self):
2525
pass
2626

27-
def with_run_command(self, artifact_name: str):
27+
def with_run_command(self, dictionary: dict):
2828
"""Test that that file and class static variables display correctly."""
29-
self.build()
29+
self.build(dictionary=dictionary)
30+
artifact_name = dictionary.get("EXE", "a.out")
3031
self.runCmd(
3132
"file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
3233
)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,4 @@ CXX_SOURCES := main.cpp
33
CXXFLAGS := -O0
44
USE_LIBSTDCPP := 1
55

6-
all: debug_a.out
7-
86
include Makefile.rules
9-
10-
debug_main.o: main.cpp
11-
$(CXX) $(PCHFLAGS) $(CXXFLAGS) -D_GLIBCXX_DEBUG -MT $@ -MD -MP -MF $*.d -c -o $@ $<
12-
13-
debug_a.out: debug_main.o
14-
$(LD) debug_main.o $(LDFLAGS) -o debug_a.out

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ class NoDebugTestCase(StdVectorDataFormatterBase):
1313
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
1414
@override
1515
def test_with_run_command(self):
16-
self.with_run_command("a.out")
16+
build_args = {"EXE": "a.out"}
17+
self.with_run_command(build_args)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVectorDebug.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Test lldb data formatter subsystem for std::vector with -D_GLIBCXX_DEBUG flag
2+
Test lldb data formatter subsystem for std::vector with `_GLIBCXX_DEBUG` flag
33
"""
44

55
from typing import override
@@ -13,4 +13,5 @@ class WithDebugTestCase(StdVectorDataFormatterBase):
1313
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
1414
@override
1515
def test_with_run_command(self):
16-
self.with_run_command("debug_a.out")
16+
build_args = {"_GLIBCXX_DEBUG": 1, "EXE": "debug_a.out"}
17+
self.with_run_command(build_args)

0 commit comments

Comments
 (0)