-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Highlight basenames in backtraces #137301
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
[lldb] Highlight basenames in backtraces #137301
Conversation
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesBefore: After: Full diff: https://github.com/llvm/llvm-project/pull/137301.diff 2 Files Affected:
diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td
index f5d86b663de13..8c2ff934330b9 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -59,7 +59,7 @@ let Definition = "debugger" in {
Desc<"The default disassembly format string to use when disassembling instruction sequences.">;
def FrameFormat: Property<"frame-format", "FormatEntity">,
Global,
- DefaultStringValue<"frame #${frame.index}: ${ansi.fg.yellow}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
+ DefaultStringValue<"frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
Desc<"The default frame format string to use when displaying stack frame information for threads.">;
def NotiftVoid: Property<"notify-void", "Boolean">,
Global,
@@ -215,7 +215,7 @@ let Definition = "debugger" in {
Desc<"If true, LLDB will automatically escape non-printable and escape characters when formatting strings.">;
def FrameFormatUnique: Property<"frame-format-unique", "FormatEntity">,
Global,
- DefaultStringValue<"frame #${frame.index}: ${ansi.fg.yellow}${frame.pc}${ansi.normal}{ ${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
+ DefaultStringValue<"frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name-without-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\\\\n">,
Desc<"The default frame format string to use when displaying stack frame information for threads from thread backtrace unique.">;
def ShowAutosuggestion: Property<"show-autosuggestion", "Boolean">,
Global,
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td b/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
index 6ec87afe25758..348de256b154a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
+++ b/lldb/source/Plugins/Language/CPlusPlus/LanguageCPlusPlusProperties.td
@@ -3,6 +3,6 @@ include "../../../../include/lldb/Core/PropertiesBase.td"
let Definition = "language_cplusplus" in {
def FunctionNameFormat: Property<"function-name-format", "FormatEntity">,
Global,
- DefaultStringValue<"${function.return-left}${function.scope}${function.basename}${function.template-arguments}${function.formatted-arguments}${function.return-right}${function.qualifiers}">,
+ DefaultStringValue<"${function.return-left}${function.scope}${ansi.fg.yellow}${function.basename}${ansi.normal}${function.template-arguments}${function.formatted-arguments}${function.return-right}${function.qualifiers}">,
Desc<"C++ specific frame format string to use when displaying stack frame information for threads.">;
}
|
I kinda like how the (highlighted) PC value creates a column. What would you say to highlighting both? (I know I can change this locally if I want to, so this is really a question what's a better default => don't change this just because I said so) |
ac3116c
to
eac7bba
Compare
We could try a less aggressive color like the one used for the file names. I'm wondering if whoever came up with the current color scheme was trying to use a uniform color for all numbers. Even if so, that's not necessarily a property we need to preserve. When discussing color changes, it might be best to show screenshots of a "default" gray-on-white and a black-on-white terminal (i.e., the "Basic" and "Pro" presets in Terminal.app) to get a better idea of what it will look like with a spectrum of widely-used color schemes. |
How does this look in a light terminal background? |
I agree with Pavel, having the PC highlighted in yellow (or really in a colour that stands out) and having that column centers everything IMO. e.g. I like the cyan, but in the "Pro" scheme since it stands out from everything else. |
I think this works. |
Not to derail this too much, but I'm also thinking if we should stop coloring the column number. Happy to open a patch if people think this is a good idea? |
I don't have a strong opinion on this but I'm curious on why coloring the column number is bothering you specifically 😜 ? Should we also stop coloring the line number then ? |
I agree with @medismailben, the line number is super helpful (I copy/paste this into vim all the time) and visually it looks a bit weird without the column even thought it's not useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thanks for trying it out.
@Michael137, in the second screenshot in the PR description, Is that expected? (I'm pretty busy right now otherwise I'd check for myself) |
Yea the |
Maybe we should say that if the name is not mangled, the entire string is the name of the function (and so it should be highlighted)? |
Also changes the PC value color so it doesn't visually clash with the function names Before: <img width="1510" alt="Screenshot 2025-04-25 at 10 38 58 AM" src="https://github.com/user-attachments/assets/1ec35ba3-a3d9-4e5b-bac9-fc738bfe6d25" /> After: 
That could work. Just need to audit in which cases we might set a demangled name without specifying it's mangled name too. If the demangled name happens to include arguments/return types/etc., highlighting those may get confusing. But not sure that ever happens |
Also changes the PC value color so it doesn't visually clash with the function names Before: <img width="1510" alt="Screenshot 2025-04-25 at 10 38 58 AM" src="https://github.com/user-attachments/assets/1ec35ba3-a3d9-4e5b-bac9-fc738bfe6d25" /> After: 
Also changes the PC value color so it doesn't visually clash with the function names Before: <img width="1510" alt="Screenshot 2025-04-25 at 10 38 58 AM" src="https://github.com/user-attachments/assets/1ec35ba3-a3d9-4e5b-bac9-fc738bfe6d25" /> After: 
Also changes the PC value color so it doesn't visually clash with the function names Before: <img width="1510" alt="Screenshot 2025-04-25 at 10 38 58 AM" src="https://github.com/user-attachments/assets/1ec35ba3-a3d9-4e5b-bac9-fc738bfe6d25" /> After: 
Also changes the PC value color so it doesn't visually clash with the function names Before: <img width="1510" alt="Screenshot 2025-04-25 at 10 38 58 AM" src="https://github.com/user-attachments/assets/1ec35ba3-a3d9-4e5b-bac9-fc738bfe6d25" /> After: 
Also changes the PC value color so it doesn't visually clash with the function names
Before:

After:
