Skip to content

Commit

Permalink
[lldb][unittest] Add call_once flag to initialize debugger (llvm#80786)
Browse files Browse the repository at this point in the history
I tried adding a new unit test to the core test
suite (llvm#79533) but it broke the
test suite on AArch64 Linux due to hitting an assertion for calling
`Debugger::Initialize` more than once. When the unit test suite is
invoked as a standalone binary the test suite state is shared, and
`Debugger::Initialize` gets called in `DiagnosticEventTest.cpp` before
being called in `ProgressReportTest.cpp`.

`DiagnosticEventTest.cpp` uses a call_once flag to initialize the
debugger but it's local to that test. This commit adds a once_flag to
`TestUtilities` so that `Debugger::Initialize` can be called once by the
tests that use it.
  • Loading branch information
chelcassanova authored Feb 6, 2024
1 parent 36e8db7 commit 3885483
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lldb/unittests/TestingSupport/TestUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using namespace lldb_private;

extern const char *TestMainArgv0;

std::once_flag TestUtilities::g_debugger_initialize_flag;
std::string lldb_private::GetInputFilePath(const llvm::Twine &name) {
llvm::SmallString<128> result = llvm::sys::path::parent_path(TestMainArgv0);
llvm::sys::fs::make_absolute(result);
Expand Down
7 changes: 6 additions & 1 deletion lldb/unittests/TestingSupport/TestUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
namespace lldb_private {
std::string GetInputFilePath(const llvm::Twine &name);

class TestUtilities {
public:
static std::once_flag g_debugger_initialize_flag;
};

class TestFile {
public:
static llvm::Expected<TestFile> fromYaml(llvm::StringRef Yaml);
Expand All @@ -51,6 +56,6 @@ class TestFile {

std::string Buffer;
};
}
} // namespace lldb_private

#endif

0 comments on commit 3885483

Please sign in to comment.