Skip to content

Conversation

@agontarek
Copy link
Contributor

This commit introduces a new log channel for the disassembler in LLDB, allowing for better logging of disassembler related activities. The LLDBLOG enum has been updated to include the Disassembler channel, and the relevant logging in the DisassemblerLLVMC plugin has been modified to utilize this new channel. This is in preparation for adding additional disassembler implementations.

Key Changes:

  • Added Disassembler to the LLDBLog enum.
  • Updated logging in DisassemblerLLVMC.cpp to use the new Disassembler log channel.

This commit introduces a new log channel for the disassembler in LLDB,
allowing for better logging of disassembler related activities. The
`LLDBLOG` enum has been updated to include the `Disassembler` channel,
and the relevant logging in the `DisassemblerLLVMC` plugin has been
modified to utilize this new channel. This is in preparation for adding
additional disassembler implementations.

Key Changes:
- Added `Disassembler` to the `LLDBLog` enum.
- Updated logging in `DisassemblerLLVMC.cpp` to use the new `Disassembler` log channel.
@agontarek agontarek requested a review from JDevlieghere as a code owner July 11, 2025 20:19
@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the lldb label Jul 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2025

@llvm/pr-subscribers-lldb

Author: Andrew Gontarek (agontarek)

Changes

This commit introduces a new log channel for the disassembler in LLDB, allowing for better logging of disassembler related activities. The LLDBLOG enum has been updated to include the Disassembler channel, and the relevant logging in the DisassemblerLLVMC plugin has been modified to utilize this new channel. This is in preparation for adding additional disassembler implementations.

Key Changes:

  • Added Disassembler to the LLDBLog enum.
  • Updated logging in DisassemblerLLVMC.cpp to use the new Disassembler log channel.

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

3 Files Affected:

  • (modified) lldb/include/lldb/Utility/LLDBLog.h (+1)
  • (modified) lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp (+1-1)
  • (modified) lldb/source/Utility/LLDBLog.cpp (+3)
diff --git a/lldb/include/lldb/Utility/LLDBLog.h b/lldb/include/lldb/Utility/LLDBLog.h
index c7de41e74e85b..03190c27986a0 100644
--- a/lldb/include/lldb/Utility/LLDBLog.h
+++ b/lldb/include/lldb/Utility/LLDBLog.h
@@ -49,6 +49,7 @@ enum class LLDBLog : Log::MaskType {
   Watchpoints = Log::ChannelFlag<30>,
   OnDemand = Log::ChannelFlag<31>,
   Source = Log::ChannelFlag<32>,
+  Disassembler = Log::ChannelFlag<33>,
   LLVM_MARK_AS_BITMASK_ENUM(OnDemand),
 };
 
diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index ed6047f8f4ef3..c48736ca0dd3b 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -1146,7 +1146,7 @@ class InstructionLLVMC : public lldb_private::Instruction {
       }
     }
 
-    if (Log *log = GetLog(LLDBLog::Process)) {
+    if (Log *log = GetLog(LLDBLog::Disassembler)) {
       StreamString ss;
 
       ss.Printf("[%s] expands to %zu operands:\n", operands_string,
diff --git a/lldb/source/Utility/LLDBLog.cpp b/lldb/source/Utility/LLDBLog.cpp
index b193bd4eb07dc..613dae42064a8 100644
--- a/lldb/source/Utility/LLDBLog.cpp
+++ b/lldb/source/Utility/LLDBLog.cpp
@@ -64,6 +64,9 @@ static constexpr Log::Category g_categories[] = {
      {"log symbol on-demand related activities"},
      LLDBLog::OnDemand},
     {{"source"}, {"log source related activities"}, LLDBLog::Source},
+    {{"disassembler"},
+     {"log disassembler related activities"},
+     LLDBLog::Disassembler},
 };
 
 static Log::Channel g_log_channel(g_categories,

@agontarek
Copy link
Contributor Author

Tagging @clayborg @walter-erquinigo for review.

OnDemand = Log::ChannelFlag<31>,
Source = Log::ChannelFlag<32>,
Disassembler = Log::ChannelFlag<33>,
LLVM_MARK_AS_BITMASK_ENUM(OnDemand),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to update this with the last enum. Someone forgot to do it when they added the Source enum. So this line should be:

LLVM_MARK_AS_BITMASK_ENUM(Disassembler),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. Done.

}

if (Log *log = GetLog(LLDBLog::Process)) {
if (Log *log = GetLog(LLDBLog::Disassembler)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We do have the option to specify multiple flag bits:

if (Log *log = GetLog(LLDBLog::Process  | LLDBLog::Disassembler)) {

We might want to add this to ensure that the logging behavior doesn't change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@clayborg clayborg merged commit 9e90788 into llvm:main Jul 11, 2025
7 of 9 checks passed
@github-actions
Copy link

@agontarek Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

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.

4 participants