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
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
import lldb
|
|
import re
|
|
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test.lldbpexpect import PExpectTest
|
|
|
|
|
|
class TestStatusline(PExpectTest):
|
|
def do_setup(self):
|
|
# Create a target and run to a breakpoint.
|
|
exe = self.getBuildArtifact("a.out")
|
|
self.expect(
|
|
"target create {}".format(exe), substrs=["Current executable set to"]
|
|
)
|
|
self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
|
|
self.expect("run", substrs=["stop reason"])
|
|
|
|
# PExpect uses many timeouts internally and doesn't play well
|
|
# under ASAN on a loaded machine..
|
|
@skipIfAsan
|
|
def test(self):
|
|
"""Basic test for the statusline."""
|
|
self.build()
|
|
self.launch()
|
|
self.do_setup()
|
|
|
|
# Change the terminal dimensions.
|
|
terminal_height = 10
|
|
terminal_width = 60
|
|
self.child.setwinsize(terminal_height, terminal_width)
|
|
|
|
# Enable the statusline and check for the control character and that we
|
|
# can see the target, the location and the stop reason.
|
|
self.expect(
|
|
"set set show-statusline true",
|
|
[
|
|
"\x1b[0;{}r".format(terminal_height - 1),
|
|
"a.out | main.c:2:11 | breakpoint 1.1 ",
|
|
],
|
|
)
|
|
|
|
# Change the terminal dimensions and make sure it's reflected immediately.
|
|
self.child.setwinsize(terminal_height, 25)
|
|
self.child.expect(re.escape("a.out | main.c:2:11 | bre"))
|
|
self.child.setwinsize(terminal_height, terminal_width)
|
|
|
|
# Change the format.
|
|
self.expect(
|
|
'set set statusline-format "target = {${target.file.basename}}"',
|
|
["target = a.out"],
|
|
)
|
|
|
|
# Hide the statusline and check or the control character.
|
|
self.expect(
|
|
"set set show-statusline false", ["\x1b[0;{}r".format(terminal_height)]
|
|
)
|