Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions lldb/source/Plugins/Language/CPlusPlus/MsvcStl.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ MsvcStlVariantSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP valobj_sp);

// MSVC STL std::atomic<>
bool IsMsvcStlAtomic(ValueObject &valobj);
bool MsvcStlAtomicSummaryProvider(ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &options);
SyntheticChildrenFrontEnd *
Expand Down
10 changes: 9 additions & 1 deletion lldb/source/Plugins/Language/CPlusPlus/MsvcStlAtomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ llvm::Expected<size_t> lldb_private::formatters::
lldb_private::SyntheticChildrenFrontEnd *
lldb_private::formatters::MsvcStlAtomicSyntheticFrontEndCreator(
CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
return new MsvcStlAtomicSyntheticFrontEnd(valobj_sp);
if (valobj_sp && IsMsvcStlAtomic(*valobj_sp))
return new MsvcStlAtomicSyntheticFrontEnd(valobj_sp);
return nullptr;
}

bool lldb_private::formatters::MsvcStlAtomicSummaryProvider(
Expand All @@ -100,3 +102,9 @@ bool lldb_private::formatters::MsvcStlAtomicSummaryProvider(
}
return false;
}

bool lldb_private::formatters::IsMsvcStlAtomic(ValueObject &valobj) {
if (auto valobj_sp = valobj.GetNonSyntheticValue())
return valobj_sp->GetChildMemberWithName("_Storage") != nullptr;
return false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CXX_SOURCES := main.cpp

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Test formatting of `std::atomic`s not from MSVC's STL
"""

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


class MsvcStlInvalidAtomicDataFormatterTestCase(TestBase):
def test(self):
self.build()
lldbutil.run_to_source_breakpoint(
self, "Set break point at this line.", lldb.SBFileSpec("main.cpp")
)

self.expect_expr(
"a",
result_children=[
ValueCheck(name="foo", value="1"),
ValueCheck(name="bar", value="2"),
],
)
self.expect_expr(
"b",
result_children=[
ValueCheck(name="foo", value="3"),
ValueCheck(name="bar", value="4"),
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace std {
template <typename T> struct atomic {
int foo;
int bar;
};
} // namespace std

int main() {
std::atomic<int> a{1, 2};
std::atomic<void> b{3, 4};

return 0; // Set break point at this line.
}
Loading