[lldb] Change the statusline format to print "no target" (#139021)
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.
This commit is contained in:
parent
5c6cbe2517
commit
45cd708184
@ -186,7 +186,7 @@ let Definition = "debugger" in {
|
|||||||
: Property<"statusline-format", "FormatEntity">,
|
: Property<"statusline-format", "FormatEntity">,
|
||||||
Global,
|
Global,
|
||||||
DefaultStringValue<
|
DefaultStringValue<
|
||||||
"${ansi.negative}{${target.file.basename}}{ "
|
"${ansi.negative}{${target.file.basename}|no target}{ "
|
||||||
"${separator}${line.file.basename}:${line.number}:${line.column}}{ "
|
"${separator}${line.file.basename}:${line.number}:${line.column}}{ "
|
||||||
"${separator}${thread.stop-reason}}{ "
|
"${separator}${thread.stop-reason}}{ "
|
||||||
"${separator}{${progress.count} }${progress.message}}">,
|
"${separator}{${progress.count} }${progress.message}}">,
|
||||||
|
@ -6,7 +6,17 @@ from lldbsuite.test.lldbtest import *
|
|||||||
from lldbsuite.test.lldbpexpect import PExpectTest
|
from lldbsuite.test.lldbpexpect import PExpectTest
|
||||||
|
|
||||||
|
|
||||||
|
# PExpect uses many timeouts internally and doesn't play well
|
||||||
|
# under ASAN on a loaded machine..
|
||||||
|
@skipIfAsan
|
||||||
class TestStatusline(PExpectTest):
|
class TestStatusline(PExpectTest):
|
||||||
|
# Change this value to something smaller to make debugging this test less
|
||||||
|
# tedious.
|
||||||
|
TIMEOUT = 60
|
||||||
|
|
||||||
|
TERMINAL_HEIGHT = 10
|
||||||
|
TERMINAL_WIDTH = 60
|
||||||
|
|
||||||
def do_setup(self):
|
def do_setup(self):
|
||||||
# Create a target and run to a breakpoint.
|
# Create a target and run to a breakpoint.
|
||||||
exe = self.getBuildArtifact("a.out")
|
exe = self.getBuildArtifact("a.out")
|
||||||
@ -15,36 +25,34 @@ class TestStatusline(PExpectTest):
|
|||||||
)
|
)
|
||||||
self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
|
self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
|
||||||
self.expect("run", substrs=["stop reason"])
|
self.expect("run", substrs=["stop reason"])
|
||||||
|
self.resize()
|
||||||
|
|
||||||
|
def resize(self):
|
||||||
|
# Change the terminal dimensions. When we launch the tests, we reset
|
||||||
|
# all the settings, leaving the terminal dimensions unset.
|
||||||
|
self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH)
|
||||||
|
|
||||||
# PExpect uses many timeouts internally and doesn't play well
|
|
||||||
# under ASAN on a loaded machine..
|
|
||||||
@skipIfAsan
|
|
||||||
def test(self):
|
def test(self):
|
||||||
"""Basic test for the statusline."""
|
"""Basic test for the statusline."""
|
||||||
self.build()
|
self.build()
|
||||||
self.launch()
|
self.launch(timeout=self.TIMEOUT)
|
||||||
self.do_setup()
|
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
|
# Enable the statusline and check for the control character and that we
|
||||||
# can see the target, the location and the stop reason.
|
# can see the target, the location and the stop reason.
|
||||||
self.expect('set set separator "| "')
|
self.expect('set set separator "| "')
|
||||||
self.expect(
|
self.expect(
|
||||||
"set set show-statusline true",
|
"set set show-statusline true",
|
||||||
[
|
[
|
||||||
"\x1b[0;{}r".format(terminal_height - 1),
|
"\x1b[0;{}r".format(self.TERMINAL_HEIGHT - 1),
|
||||||
"a.out | main.c:2:11 | breakpoint 1.1 ",
|
"a.out | main.c:2:11 | breakpoint 1.1 ",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Change the terminal dimensions and make sure it's reflected immediately.
|
# Change the terminal dimensions and make sure it's reflected immediately.
|
||||||
self.child.setwinsize(terminal_height, 25)
|
self.child.setwinsize(self.TERMINAL_HEIGHT, 25)
|
||||||
self.child.expect(re.escape("a.out | main.c:2:11 | bre"))
|
self.child.expect(re.escape("a.out | main.c:2:11 | bre"))
|
||||||
self.child.setwinsize(terminal_height, terminal_width)
|
self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH)
|
||||||
|
|
||||||
# Change the separator.
|
# Change the separator.
|
||||||
self.expect('set set separator "S "', ["a.out S main.c:2:11"])
|
self.expect('set set separator "S "', ["a.out S main.c:2:11"])
|
||||||
@ -58,23 +66,15 @@ class TestStatusline(PExpectTest):
|
|||||||
|
|
||||||
# Hide the statusline and check or the control character.
|
# Hide the statusline and check or the control character.
|
||||||
self.expect(
|
self.expect(
|
||||||
"set set show-statusline false", ["\x1b[0;{}r".format(terminal_height)]
|
"set set show-statusline false", ["\x1b[0;{}r".format(self.TERMINAL_HEIGHT)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# PExpect uses many timeouts internally and doesn't play well
|
|
||||||
# under ASAN on a loaded machine..
|
|
||||||
@skipIfAsan
|
|
||||||
def test_no_color(self):
|
def test_no_color(self):
|
||||||
"""Basic test for the statusline with colors disabled."""
|
"""Basic test for the statusline with colors disabled."""
|
||||||
self.build()
|
self.build()
|
||||||
self.launch(use_colors=False)
|
self.launch(use_colors=False, timeout=self.TIMEOUT)
|
||||||
self.do_setup()
|
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 "reverse video" control character.
|
# Enable the statusline and check for the "reverse video" control character.
|
||||||
self.expect(
|
self.expect(
|
||||||
"set set show-statusline true",
|
"set set show-statusline true",
|
||||||
@ -87,15 +87,20 @@ class TestStatusline(PExpectTest):
|
|||||||
"""Regression test for lock inversion between the statusline mutex and
|
"""Regression test for lock inversion between the statusline mutex and
|
||||||
the output mutex."""
|
the output mutex."""
|
||||||
self.build()
|
self.build()
|
||||||
self.launch(extra_args=["-o", "settings set use-color false"])
|
self.launch(
|
||||||
|
extra_args=["-o", "settings set use-color false"], timeout=self.TIMEOUT
|
||||||
|
)
|
||||||
self.child.expect("(lldb)")
|
self.child.expect("(lldb)")
|
||||||
|
self.resize()
|
||||||
# Change the terminal dimensions.
|
|
||||||
terminal_height = 10
|
|
||||||
terminal_width = 60
|
|
||||||
self.child.setwinsize(terminal_height, terminal_width)
|
|
||||||
|
|
||||||
exe = self.getBuildArtifact("a.out")
|
exe = self.getBuildArtifact("a.out")
|
||||||
|
|
||||||
self.expect("file {}".format(exe), ["Current executable"])
|
self.expect("file {}".format(exe), ["Current executable"])
|
||||||
self.expect("help", ["Debugger commands"])
|
self.expect("help", ["Debugger commands"])
|
||||||
|
|
||||||
|
def test_no_target(self):
|
||||||
|
"""Test that we print "no target" when launched without a target."""
|
||||||
|
self.launch(timeout=self.TIMEOUT)
|
||||||
|
self.resize()
|
||||||
|
|
||||||
|
self.expect("set set show-statusline true", ["no target"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user