This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Inject commands into log output when directed to file
Needs ReviewPublic

Authored by hawkinsw on May 4 2022, 6:44 AM.

Details

Summary

When logging for the lldb channel is enabled for any category and the
channel output is being directed to a file, inject a copy of every
command entered. This change will make it easier to contextualize the
debugging output with any commands that the user entered.

Diff Detail

Event Timeline

hawkinsw created this revision.May 4 2022, 6:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 6:44 AM
hawkinsw requested review of this revision.May 4 2022, 6:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 6:44 AM

As always, thank you for the work that you all do on lldb! An amazing tool! It is so much fun to be able to help and I hope that this is a helpful addition. Please let me know whether this is something that you find useful and whether or not there are changes that I can make to get this patch acceptable!

labath added a comment.May 4 2022, 8:08 AM

Just my opinion, but I wouldn't like to complicate the logging architecture with file-only log statements and cross-channel dependencies. If you want to cross-reference some other logging channel with the executed commands then I'd say you should enable both channels. We can definitely talk about making the command feature more prominently in the log stream.

Just my opinion, but I wouldn't like to complicate the logging architecture with file-only log statements and cross-channel dependencies. If you want to cross-reference some other logging channel with the executed commands then I'd say you should enable both channels. We can definitely talk about making the command feature more prominently in the log stream.

Thanks! I am just trying to be helpful!

You are suggesting that the user would always add commands to what you enable in order to have this feature? Ie,

log enable -f lldb.out lldb break commands

The only reason that would be less than ideal for me (personally) is that there is lots of other output that comes along with commands that I might not necessarily want.

Again, just trying to be helpful! Again, I am happy to do whatever the group consensus is!!

Just happy to participate!
Will

labath added a comment.May 4 2022, 8:22 AM

Yeah, I guess that what I am saying.

For me the commands channel gives 6 lines of output for a command. Compared to what some of our other logging channels do, that's nothing.

Yeah, I guess that what I am saying.

For me the commands channel gives 6 lines of output for a command. Compared to what some of our other logging channels do, that's nothing.

Totally understand.

Whatever the consensus is, I am happy to oblige. I just have been having so much fun working with LLDB. While I have your ear, are there any other pain points where I could contribute?

labath added a comment.May 4 2022, 8:42 AM

Heh, well.. there definitely are, though a lot of things that come to mind right now are not really suitable for a first-time contributor. Is there any specific are that you would like to know (or that you know already)?

One of the things that I ran into recently, but hadn't had time to fix is the relocation processing code in ObjectFileELF::ApplyRelocations. It's currently fairly messy, and mixes relocations of different architectures (which generally doesn't work as different constants mean different things depending on the architecture. If you could refactor the function such that it has a clear split between architectures, and still allows for code sharing for relocations that mean the same thing on each architecture, then that would be greatly appreciated.

You can try that out by compiling a .o file for some non-x86 architecture and checking whether lldb can read the debug info without asserting.

Heh, well.. there definitely are, though a lot of things that come to mind right now are not really suitable for a first-time contributor. Is there any specific are that you would like to know (or that you know already)?

One of the things that I ran into recently, but hadn't had time to fix is the relocation processing code in ObjectFileELF::ApplyRelocations. It's currently fairly messy, and mixes relocations of different architectures (which generally doesn't work as different constants mean different things depending on the architecture. If you could refactor the function such that it has a clear split between architectures, and still allows for code sharing for relocations that mean the same thing on each architecture, then that would be greatly appreciated.

You can try that out by compiling a .o file for some non-x86 architecture and checking whether lldb can read the debug info without asserting.

Thanks!!

If there is interest in pursuing this patch, I will keep it open!

I have committed several typo changes in the past and I am a fairly seasoned developer. In fact, I have another outstanding patch waiting for review.

I will definitely look in to what you suggest. I hope that you will see some submissions forthcoming. Thanks again!