Skip to content

[lldb][unittest] Add call_once flag to initialize debugger #80786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

chelcassanova
Copy link
Contributor

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.

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2024

@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/80786.diff

2 Files Affected:

  • (modified) lldb/unittests/TestingSupport/TestUtilities.cpp (+1)
  • (modified) lldb/unittests/TestingSupport/TestUtilities.h (+6-1)
diff --git a/lldb/unittests/TestingSupport/TestUtilities.cpp b/lldb/unittests/TestingSupport/TestUtilities.cpp
index 9e5523e487547..507241404c08d 100644
--- a/lldb/unittests/TestingSupport/TestUtilities.cpp
+++ b/lldb/unittests/TestingSupport/TestUtilities.cpp
@@ -19,6 +19,7 @@ using namespace lldb_private;
 
 extern const char *TestMainArgv0;
 
+std::once_flag TestUtilities::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);
diff --git a/lldb/unittests/TestingSupport/TestUtilities.h b/lldb/unittests/TestingSupport/TestUtilities.h
index 811c4c1521269..99e569bfa5250 100644
--- a/lldb/unittests/TestingSupport/TestUtilities.h
+++ b/lldb/unittests/TestingSupport/TestUtilities.h
@@ -31,6 +31,11 @@
 namespace lldb_private {
 std::string GetInputFilePath(const llvm::Twine &name);
 
+class TestUtilities {
+  public:
+    static std::once_flag debugger_initialize_flag;
+};
+
 class TestFile {
 public:
   static llvm::Expected<TestFile> fromYaml(llvm::StringRef Yaml);
@@ -51,6 +56,6 @@ class TestFile {
 
   std::string Buffer;
 };
-}
+} // namespace lldb_private
 
 #endif

Copy link

github-actions bot commented Feb 6, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@jasonmolenda
Copy link
Collaborator

Did you mean to include changes to DiagnosticEventTest.cpp and ProgressReportTest.cpp to use this new global?

@chelcassanova
Copy link
Contributor Author

chelcassanova commented Feb 6, 2024

I did, I'm adding them as separate patches. DiagnosticEventTest.cpp could probably go here since it's a simple change but ProgressEventTest doesn't exist upstream yet since I had to revert it so I think that at least should be it's own PR.

Copy link
Collaborator

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@chelcassanova chelcassanova force-pushed the unittest-debugger-flag branch from 2fa9939 to 7b5f866 Compare February 6, 2024 03:09
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 6, 2024
Incorporates the changes from
llvm#80786 to use a once_flag from
`TestUtilities` instead of a local flag in order to prevent hitting an
assertion that the debugger was initialized again in another test.
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 6, 2024
This file was previously approved and merged from this PR:
llvm#79533 but caused a test
failure on the Linux AArch64 bots due to hitting an assertion that
`Debugger::Initialize` was already called.

To fix this, this commit uses the
changes made here: llvm#80786 to
use a shared call_once flag to initialize the debugger.
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.
@chelcassanova chelcassanova force-pushed the unittest-debugger-flag branch from 7b5f866 to 0d56057 Compare February 6, 2024 16:13
@chelcassanova chelcassanova merged commit 3885483 into llvm:main Feb 6, 2024
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 6, 2024
This file was previously approved and merged from this PR:
llvm#79533 but caused a test
failure on the Linux AArch64 bots due to hitting an assertion that
`Debugger::Initialize` was already called.

To fix this, this commit uses the
changes made here: llvm#80786 to
use a shared call_once flag to initialize the debugger.
chelcassanova added a commit that referenced this pull request Feb 6, 2024
Incorporates the changes from
#80786 to use a once_flag from
`TestUtilities` instead of a local flag in order to prevent hitting an
assertion that the debugger was initialized again in another test.
@chelcassanova chelcassanova deleted the unittest-debugger-flag branch February 6, 2024 16:37
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 6, 2024
This file was previously approved and merged from this PR:
llvm#79533 but caused a test
failure on the Linux AArch64 bots due to hitting an assertion that
`Debugger::Initialize` was already called.

To fix this, this commit uses the
changes made here: llvm#80786 to
use a shared call_once flag to initialize the debugger.
chelcassanova added a commit that referenced this pull request Feb 6, 2024
…0791)

This file was previously approved and merged from this PR:
#79533 but caused a test
failure on the Linux AArch64 bots due to hitting an assertion that
`Debugger::Initialize` was already called.

To fix this, this commit uses the
changes made here: #80786 to
use a shared call_once flag to initialize the debugger.
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 7, 2024
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.

(cherry picked from commit 3885483)
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 7, 2024
)

Incorporates the changes from
llvm#80786 to use a once_flag from
`TestUtilities` instead of a local flag in order to prevent hitting an
assertion that the debugger was initialized again in another test.

(cherry picked from commit 5690027)
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 7, 2024
…vm#80791)

This file was previously approved and merged from this PR:
llvm#79533 but caused a test
failure on the Linux AArch64 bots due to hitting an assertion that
`Debugger::Initialize` was already called.

To fix this, this commit uses the
changes made here: llvm#80786 to
use a shared call_once flag to initialize the debugger.

(cherry picked from commit a8ab830)
chelcassanova added a commit to swiftlang/llvm-project that referenced this pull request Feb 8, 2024
…ing support (#8141)

* [lldb][unittest] Add call_once flag to initialize debugger (llvm#80786)

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.

(cherry picked from commit 3885483)

* [lldb][unittest] Use shared once_flag in DiagnosticEventTest (llvm#80788)

Incorporates the changes from
llvm#80786 to use a once_flag from
`TestUtilities` instead of a local flag in order to prevent hitting an
assertion that the debugger was initialized again in another test.

(cherry picked from commit 5690027)
chelcassanova added a commit to swiftlang/llvm-project that referenced this pull request Feb 8, 2024
…vm#80791) (#8142)

This file was previously approved and merged from this PR:
llvm#79533 but caused a test
failure on the Linux AArch64 bots due to hitting an assertion that
`Debugger::Initialize` was already called.

To fix this, this commit uses the
changes made here: llvm#80786 to
use a shared call_once flag to initialize the debugger.

(cherry picked from commit a8ab830)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants