Skip to content

[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h #87409

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

Conversation

chelcassanova
Copy link
Contributor

@chelcassanova chelcassanova commented Apr 2, 2024

When the eBroadcastBitProgressCategory bit was originally added to Debugger.h and SBDebugger.h, each corresponding bit was added in order of the other bits that were previously there. Since Debugger.h has an enum bit that SBDebugger.h does not, this meant that their offsets did not match.

Instead of trying to keep the bit offsets in sync between the two, it's preferable to just move SBDebugger's enum into the main enumerations header and use the bits from there.

@chelcassanova chelcassanova force-pushed the match-debugger-progress-category-bits branch from efa26c8 to 88c6b49 Compare April 2, 2024 20:30
Copy link

github-actions bot commented Apr 2, 2024

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

@@ -46,7 +46,8 @@ class LLDB_API SBDebugger {
eBroadcastBitProgress = (1 << 0),
eBroadcastBitWarning = (1 << 1),
eBroadcastBitError = (1 << 2),
eBroadcastBitProgressCategory = (1 << 3),
eBroadcastBitProgressCategory =
(1 << 4), // This needs to match the corresponding bit in Debugger.h
Copy link
Member

Choose a reason for hiding this comment

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

Let's move that comment above the enum.

@chelcassanova chelcassanova force-pushed the match-debugger-progress-category-bits branch from 88c6b49 to b3ff6c7 Compare April 2, 2024 21:56
@@ -46,7 +46,8 @@ class LLDB_API SBDebugger {
eBroadcastBitProgress = (1 << 0),
eBroadcastBitWarning = (1 << 1),
eBroadcastBitError = (1 << 2),
eBroadcastBitProgressCategory = (1 << 3),
// This needs to match the corresponding bit in Debugger.h
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this comment apply to the whole enum? My suggestion was to move this above line 45 to convey that, unless that's not the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mistake, I was indicating that the progress category bit is skipping (1 << 3) in this sequence since that bit has to match the one in Debugger.h. I can change the comment to say that the whole enum needs to match Debugger.h.

When the `eBroadcastBitProgressCategory` bit was originally added to
Debugger.h and SBDebugger.h, each corresponding bit was added in order
of the other bits that were previously there. Since `Debugger.h` has an
enum bit that `SBDebugger.h` does not, this meant that their offsets did
not match. This commit changes it so that the bit offsets match each other.
@chelcassanova chelcassanova force-pushed the match-debugger-progress-category-bits branch from b3ff6c7 to 7561d03 Compare April 3, 2024 20:19
@llvmbot llvmbot added the lldb label Apr 3, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 3, 2024

@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)

Changes

When the eBroadcastBitProgressCategory bit was originally added to Debugger.h and SBDebugger.h, each corresponding bit was added in order of the other bits that were previously there. Since Debugger.h has an enum bit that SBDebugger.h does not, this meant that their offsets did not match. This commit changes it so that the bit offsets match each other.


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

1 Files Affected:

  • (modified) lldb/include/lldb/API/SBDebugger.h (+3-1)
diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h
index 62b2f91f5076d5..a994874dde6d4a 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,11 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  // The enum values here need to match their corresponding values in
+  // Debugger.h.
   FLAGS_ANONYMOUS_ENUM(){
       eBroadcastBitProgress = (1 << 0),
       eBroadcastBitWarning = (1 << 1),
       eBroadcastBitError = (1 << 2),
-      eBroadcastBitProgressCategory = (1 << 3),
+      eBroadcastBitProgressCategory = (1 << 4),
   };
 
   SBDebugger();

@medismailben
Copy link
Member

Why don't we just remove the enum from SBDebugger and use the one from Debugger instead, this will ensure the offsets are always the same.

@bulbazord
Copy link
Member

Why don't we just remove the enum from SBDebugger and use the one from Debugger instead, this will ensure the offsets are always the same.

SBDebugger is public and Debugger is private, so I'm not sure how you can do this? Maybe I'm misunderstanding your suggestion...

It would be nice if we could move the enum into lldb-enumerations so we didn't have to worry about keeping this in sync though.

Per Alex's suggestions, adds the broadcast bits from SBDebugger
into lldb-enumerations.
Comment on lines 45 to 51
// The enum values here need to match their corresponding values in
// Debugger.h.
FLAGS_ANONYMOUS_ENUM(){
eBroadcastBitProgress = (1 << 0),
eBroadcastBitWarning = (1 << 1),
eBroadcastBitError = (1 << 2),
eBroadcastBitProgressCategory = (1 << 3),
eBroadcastBitProgressCategory = (1 << 4),
Copy link
Member

Choose a reason for hiding this comment

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

This one can go now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, will remove.

@@ -1339,6 +1339,14 @@ enum AddressMaskRange {
eAddressMaskRangeAll = eAddressMaskRangeAny,
};

/// Used by the debugger to indicate which events are being broadcasted.
enum DebuggerBroadcast {
Copy link
Member

Choose a reason for hiding this comment

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

DebuggerBroadcastBit maybe?

@medismailben medismailben self-requested a review April 10, 2024 21:08
Copy link
Member

@medismailben medismailben left a comment

Choose a reason for hiding this comment

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

LGTM if you address the comment and rewrite the PR description and title :)

eBroadcastBitProgress = (1 << 0),
eBroadcastBitWarning = (1 << 1),
eBroadcastBitError = (1 << 2),
eBroadcastBitProgressCategory = (1 << 4),
Copy link
Member

Choose a reason for hiding this comment

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

typo ?

Suggested change
eBroadcastBitProgressCategory = (1 << 4),
eBroadcastBitProgressCategory = (1 << 3),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, I guess since this is in lldb-enumerations it doesn't have to match the ones in Debugger.h anymore.

Removes the enum for broadcast bits from SBDebugger as they're now in
lldb-enumerations.h. This also requires uses of these bits to be updated
in some API tests.
@chelcassanova chelcassanova force-pushed the match-debugger-progress-category-bits branch from 3dc9c9f to 39b05ff Compare April 10, 2024 21:37
@chelcassanova chelcassanova changed the title [lldb][sbdebugger] Match progress category enum bit in Debugger.h [lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h Apr 10, 2024
@chelcassanova chelcassanova merged commit af7c196 into llvm:main Apr 10, 2024
4 checks passed
@chelcassanova chelcassanova deleted the match-debugger-progress-category-bits branch April 10, 2024 21:45
chelcassanova added a commit that referenced this pull request Apr 10, 2024
…db-enumerations.h" (#88324)

Reverts #87409 due a missed update to the broadcast bit
causing a build failure on the x86_64 Debian buildbot.
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Apr 26, 2024
llvm#87409 removed the broadcast
bits from SBDebugger and placed them in `lldb-enumerations.h`. This is
API-breaking so this commits places the enum back into `SBDebugger.h`
and references the bits from `lldb-enumerations.h`.
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Apr 26, 2024
llvm#87409 removed the broadcast
bits from SBDebugger and placed them in `lldb-enumerations.h`. This is
API-breaking so this commits places the enum back into `SBDebugger.h`
and references the bits from `lldb-enumerations.h`.
chelcassanova added a commit that referenced this pull request Apr 26, 2024
#87409 removed the broadcast
bits from SBDebugger and placed them in `lldb-enumerations.h`. This is
API-breaking so this commits places the enum back into `SBDebugger.h`
and references the bits from `lldb-enumerations.h`.

rdar://127128536
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Apr 26, 2024
llvm#87409 removed the broadcast
bits from SBDebugger and placed them in `lldb-enumerations.h`. This is
API-breaking so this commits places the enum back into `SBDebugger.h`
and references the bits from `lldb-enumerations.h`.

rdar://127128536
(cherry picked from commit a4c21d1)
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.

5 participants