Skip to content

Commit fcd590a

Browse files
committed
[lldb] Change the statusline format to print "no target"
Change the default statusline format to print "no target" when lldb is launched without a target. Currently, the statusline is empty, which looks rather odd.
1 parent aeeb9a3 commit fcd590a

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

lldb/source/Core/CoreProperties.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ let Definition = "debugger" in {
186186
: Property<"statusline-format", "FormatEntity">,
187187
Global,
188188
DefaultStringValue<
189-
"${ansi.negative}{${target.file.basename}}{ "
189+
"${ansi.negative}{${target.file.basename}|no target}{ "
190190
"${separator}${line.file.basename}:${line.number}:${line.column}}{ "
191191
"${separator}${thread.stop-reason}}{ "
192192
"${separator}{${progress.count} }${progress.message}}">,

lldb/test/API/functionalities/statusline/TestStatusline.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66
from lldbsuite.test.lldbpexpect import PExpectTest
77

88

9+
# PExpect uses many timeouts internally and doesn't play well
10+
# under ASAN on a loaded machine..
11+
@skipIfAsan
912
class TestStatusline(PExpectTest):
13+
14+
# Change this value to something smaller to make debugging this test less
15+
# tedious.
16+
TIMEOUT = 60
17+
18+
TERMINAL_HEIGHT = 10
19+
TERMINAL_WIDTH = 60
20+
1021
def do_setup(self):
1122
# Create a target and run to a breakpoint.
1223
exe = self.getBuildArtifact("a.out")
@@ -15,36 +26,34 @@ def do_setup(self):
1526
)
1627
self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
1728
self.expect("run", substrs=["stop reason"])
29+
self.resize()
30+
31+
def resize(self):
32+
# Change the terminal dimensions. When we launch the tests, we reset
33+
# all the settings, leaving the terminal dimensions unset.
34+
self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH)
1835

19-
# PExpect uses many timeouts internally and doesn't play well
20-
# under ASAN on a loaded machine..
21-
@skipIfAsan
2236
def test(self):
2337
"""Basic test for the statusline."""
2438
self.build()
25-
self.launch()
39+
self.launch(timeout=self.TIMEOUT)
2640
self.do_setup()
2741

28-
# Change the terminal dimensions.
29-
terminal_height = 10
30-
terminal_width = 60
31-
self.child.setwinsize(terminal_height, terminal_width)
32-
3342
# Enable the statusline and check for the control character and that we
3443
# can see the target, the location and the stop reason.
3544
self.expect('set set separator "| "')
3645
self.expect(
3746
"set set show-statusline true",
3847
[
39-
"\x1b[0;{}r".format(terminal_height - 1),
48+
"\x1b[0;{}r".format(self.TERMINAL_HEIGHT - 1),
4049
"a.out | main.c:2:11 | breakpoint 1.1 ",
4150
],
4251
)
4352

4453
# Change the terminal dimensions and make sure it's reflected immediately.
45-
self.child.setwinsize(terminal_height, 25)
54+
self.child.setwinsize(self.TERMINAL_HEIGHT, 25)
4655
self.child.expect(re.escape("a.out | main.c:2:11 | bre"))
47-
self.child.setwinsize(terminal_height, terminal_width)
56+
self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH)
4857

4958
# Change the separator.
5059
self.expect('set set separator "S "', ["a.out S main.c:2:11"])
@@ -58,23 +67,15 @@ def test(self):
5867

5968
# Hide the statusline and check or the control character.
6069
self.expect(
61-
"set set show-statusline false", ["\x1b[0;{}r".format(terminal_height)]
70+
"set set show-statusline false", ["\x1b[0;{}r".format(self.TERMINAL_HEIGHT)]
6271
)
6372

64-
# PExpect uses many timeouts internally and doesn't play well
65-
# under ASAN on a loaded machine..
66-
@skipIfAsan
6773
def test_no_color(self):
6874
"""Basic test for the statusline with colors disabled."""
6975
self.build()
70-
self.launch(use_colors=False)
76+
self.launch(use_colors=False, timeout=self.TIMEOUT)
7177
self.do_setup()
7278

73-
# Change the terminal dimensions.
74-
terminal_height = 10
75-
terminal_width = 60
76-
self.child.setwinsize(terminal_height, terminal_width)
77-
7879
# Enable the statusline and check for the "reverse video" control character.
7980
self.expect(
8081
"set set show-statusline true",
@@ -87,15 +88,20 @@ def test_deadlock(self):
8788
"""Regression test for lock inversion between the statusline mutex and
8889
the output mutex."""
8990
self.build()
90-
self.launch(extra_args=["-o", "settings set use-color false"])
91+
self.launch(
92+
extra_args=["-o", "settings set use-color false"], timeout=self.TIMEOUT
93+
)
9194
self.child.expect("(lldb)")
92-
93-
# Change the terminal dimensions.
94-
terminal_height = 10
95-
terminal_width = 60
96-
self.child.setwinsize(terminal_height, terminal_width)
95+
self.resize()
9796

9897
exe = self.getBuildArtifact("a.out")
9998

10099
self.expect("file {}".format(exe), ["Current executable"])
101100
self.expect("help", ["Debugger commands"])
101+
102+
def test_no_target(self):
103+
"""Test that we print "no target" when launched without a target."""
104+
self.launch(timeout=self.TIMEOUT)
105+
self.resize()
106+
107+
self.expect("set set show-statusline true", ["no target"])

0 commit comments

Comments
 (0)