Skip to content

Commit 3885483

Browse files
[lldb][unittest] Add call_once flag to initialize debugger (#80786)
I tried adding a new unit test to the core test suite (#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.
1 parent 36e8db7 commit 3885483

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lldb/unittests/TestingSupport/TestUtilities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using namespace lldb_private;
1919

2020
extern const char *TestMainArgv0;
2121

22+
std::once_flag TestUtilities::g_debugger_initialize_flag;
2223
std::string lldb_private::GetInputFilePath(const llvm::Twine &name) {
2324
llvm::SmallString<128> result = llvm::sys::path::parent_path(TestMainArgv0);
2425
llvm::sys::fs::make_absolute(result);

lldb/unittests/TestingSupport/TestUtilities.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
namespace lldb_private {
3232
std::string GetInputFilePath(const llvm::Twine &name);
3333

34+
class TestUtilities {
35+
public:
36+
static std::once_flag g_debugger_initialize_flag;
37+
};
38+
3439
class TestFile {
3540
public:
3641
static llvm::Expected<TestFile> fromYaml(llvm::StringRef Yaml);
@@ -51,6 +56,6 @@ class TestFile {
5156

5257
std::string Buffer;
5358
};
54-
}
59+
} // namespace lldb_private
5560

5661
#endif

0 commit comments

Comments
 (0)