summaryrefslogtreecommitdiff
path: root/lldb/source/Core/Statusline.cpp
AgeCommit message (Collapse)Author
2025-09-23[lldb] Rework how we pass the execution context to the statusline (#159887)Jonas Devlieghere
Currently, we always pass the "selected" execution context to the statusline. When handling a process or thread event, we can be more precise, and build an execution context from the event data. This PR also adopts the new `StoppedExecutionContext` that was recently introduced.
2025-07-03[lldb] Take a sledgehammer approach to resizing the statusline (#146578)Jonas Devlieghere
Terminal resizing continues to be a source of statusline bugs, so much so that some users have started disabling it altogether. Different operating systems and terminal emulators exhibit subtly different behaviors, making it nearly impossible to handle resizing reliably across the board. This patch sidesteps those issues by clearing the entire screen when the terminal is resized. This avoids having to account for the previous, potentially wrapped statusline, the underlying cause of many of the aforementioned bugs. The obvious downside is that this clears the on-screen history, but I believe that’s a reasonable trade-off. Note that this only happens when resizing the terminal; when launching LLDB, the statusline is drawn without clearing the screen. rdar://154778410
2025-06-30[lldb] Correctly restore the cursor column after resizing the statusline ↵Jonas Devlieghere
(#146132) This PR ensures we correctly restore the cursor column after resizing the statusline. To ensure we have space for the statusline, we have to emit a newline to move up everything on screen. The newline causes the cursor to move to the start of the next line, which needs to be undone. Normally, we would use escape codes to save & restore the cursor position, but that doesn't work here, as the cursor position may have (purposely) changed. Instead, we move the cursor up one line using an escape code, but we weren't restoring the column. Interestingly, Editline was able to recover from this issue through the LineInfo struct which contains the buffer and the cursor location, which allows us to compute the column. This PR addresses the bug by having Editline "refresh" the cursor position. Fixes #134064
2025-06-10[lldb] Use 1 based row and column for statusline (#143385)David Spickett
I can't find a proper source for this but many materials say that ANSI rows and columns start at 1 not 0. https://www2.math.upenn.edu/~kazdan/210/computer/ansi.html is as good as I can get: ``` <row> is a number from 1 through 25 that specifies the row to which the cursor is to be moved. <col> is a number from 1 through 80 that specifies the column to which the cursor is to be moved. ``` 0 does work in Windows terminal and Linux terminals, but we might as well be correct and it's one less thing to reason about when auditing this code. From what I read, some terminals correct 0 back to 1 and some treat 0 as a missing argument, which also defaults to 1.
2025-06-03[lldb] Fix data race in statusline format handling (#142489)Jonas Devlieghere
This fixes a data race between the main thread and the default event handler thread. The statusline format option value was protected by a mutex, but it was returned as a pointer, allowing one thread to access it while another was modifying it. Avoid the data race by returning format values by value instead of by pointer.
2025-05-28[lldb] Remove unused escape code defines from status line (#141770)David Spickett
2025-04-14[lldb] Make sure the process is stopped when computing the symbol context ↵Jonas Devlieghere
(#135458) Make sure the process is stopped when computing the symbol context. Both Adrian and Felipe reported a handful of crashes in GetSymbolContext called from Statusline::Redraw on the default event thread. Given that we're handling a StackFrameSP, it's not clear to me how that could have gotten invalidated, but Jim points out that it doesn't make sense to compute the symbol context for the frame when the process isn't stopped. Depends on #135455
2025-04-11Revert "[lldb] Make sure the process is stopped when computing the symbol ↵Jonas Devlieghere
context (#134757)" (#135408) This reverts commit e84a80408523a48d6eaacd795f1615e821ffb233 because on Linux there seems to be a race around GetRunLock. See #134757 for more context.
2025-04-08[lldb] Make sure the process is stopped when computing the symbol context ↵Jonas Devlieghere
(#134757) Make sure the process is stopped when computing the symbol context. Both Adrian and Felipe reported a handful of crashes in GetSymbolContext called from Statusline::Redraw on the default event thread. Given that we're handling a StackFrameSP, it's not clear to me how that could have gotten invalidated, but Jim points out that it doesn't make sense to compute the symbol context for the frame when the process isn't stopped.
2025-04-08Revert "[dsymutil] Avoid copying binary swiftmodules built from textual"Adrian Prantl
This reverts commit 39ace8a63012af7d6ad7bf065c233fd3d5df44a3. while investigating Linux bot failures.
2025-04-08[dsymutil] Avoid copying binary swiftmodules built from textual (#134719)Adrian Prantl
.swiftinterface files into the dSYM bundle. These typically come only from the SDK (since textual interfaces require library evolution) and thus are a waste of space to copy into the bundle. The information about this is being parsed out of the control block, which means duplicating 5 constants from the Swift frontend. If a file cannot be parsed, dsymutil errs on the side of copying the file anyway. rdar://138186524
2025-04-03[lldb] Use the "reverse video" effect when colors are disabled. (#134203)Jonas Devlieghere
When you run lldb without colors (`-X`), the status line looks weird because it doesn't have a background. You end up with what appears to be floating text at the bottom of your terminal. This patch changes the statusline to use the reverse video effect, even when colors are off. The effect doesn't introduce any new colors and just inverts the foreground and background color. I considered an alternative approach which changes the behavior of the `-X` option, so that turning off colors doesn't prevent emitting non-color related control characters such as bold, underline, and reverse video. I decided to go with this more targeted fix as (1) nobody is asking for this more general change and (2) it introduces significant complexity to plumb this through using a setting and driver flag so that it can be disabled when running the tests. Fixes #134112.
2025-03-31[lldb] Fix statusline terminal resizingJonas Devlieghere
Simplify and fix the logic to clear the old statusline when the terminal window dimensions have changed. I accidentally broke the terminal resizing behavior when addressing code review feedback. I'd really like to figure out a way to test this. PExpect isn't a good fit for this, because I really need to check the result, rather than the control characters, as the latter doesn't tell me whether any part of the old statusline is still visible.
2025-03-26[lldb] Avoid flickering by not clearing the statusline when redrawingJonas Devlieghere
When redrawing the statusline, the current implementation would clear the current line before drawing the new content. Since we always overwrite the whole statusline from beginning to end, there's no need to clear it and we can avoid the potential for flickering.
2025-03-26[lldb] Implement a statusline in LLDB (#121860)Jonas Devlieghere
Add a statusline to command-line LLDB to display information about the current state of the debugger. The statusline is a dedicated area displayed at the bottom of the screen. The information displayed is configurable through a setting consisting of LLDB’s format strings. Enablement ---------- The statusline is enabled by default, but can be disabled with the following setting: ``` (lldb) settings set show-statusline false ``` Configuration ------------- The statusline is configurable through the `statusline-format` setting. The default configuration shows the target name, the current file, the stop reason and any ongoing progress events. ``` (lldb) settings show statusline-format statusline-format (format-string) = "${ansi.bg.blue}${ansi.fg.black}{${target.file.basename}}{ | ${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ | {${progress.count} }${progress.message}}" ``` The statusline supersedes the current progress reporting implementation. Consequently, the following settings no longer have any effect (but continue to exist to not break anyone's `.lldbinit`): ``` show-progress -- Whether to show progress or not if the debugger's output is an interactive color-enabled terminal. show-progress-ansi-prefix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately before the progress message. show-progress-ansi-suffix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the progress message. ``` Format Strings -------------- LLDB's format strings are documented in the LLDB documentation and on the website: https://lldb.llvm.org/use/formatting.html#format-strings. The current implementation is relatively limited but various improvements have been discussed in the RFC. One such improvement is being to display a string when a format string is empty. Right now, when launching LLDB without a target, the statusline will be empty, which is expected, but looks rather odd. RFC --- The full RFC can be found on Discourse: https://discourse.llvm.org/t/rfc-lldb-statusline/83948