Skip to content

Commit 0b22fb3

Browse files
committed
Address David's feedback
1 parent 5678492 commit 0b22fb3

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,14 +765,15 @@ def setUpCommands(cls):
765765
# Disable fix-its by default so that incorrect expressions in tests don't
766766
# pass just because Clang thinks it has a fix-it.
767767
"settings set target.auto-apply-fixits false",
768-
# Disable the statusline in PExpect tests.
769-
"settings set show-statusline false",
770768
# Testsuite runs in parallel and the host can have also other load.
771769
"settings set plugin.process.gdb-remote.packet-timeout 60",
772770
'settings set symbols.clang-modules-cache-path "{}"'.format(
773771
configuration.lldb_module_cache_dir
774772
),
773+
# Disable colors by default.
775774
"settings set use-color false",
775+
# Disable the statusline by default.
776+
"settings set show-statusline false",
776777
]
777778

778779
# Set any user-overridden settings.

lldb/source/Core/CoreProperties.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ let Definition = "debugger" in {
179179
def StatuslineFormat: Property<"statusline-format", "FormatEntity">,
180180
Global,
181181
DefaultStringValue<"${ansi.bg.blue}${ansi.fg.black}{${target.file.basename}}{ | ${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ | {${progress.count} }${progress.message}}">,
182-
Desc<"List of statusline format entities.">;
182+
Desc<"The default statusline format string.">;
183183
def UseSourceCache: Property<"use-source-cache", "Boolean">,
184184
Global,
185185
DefaultTrue,

lldb/source/Core/FormatEntity.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,8 +1922,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
19221922

19231923
case Entry::Type::ProgressCount:
19241924
if (Target *target = Target::GetTargetFromContexts(exe_ctx, sc)) {
1925-
Debugger &debugger = target->GetDebugger();
1926-
if (auto progress = debugger.GetCurrentProgressReport()) {
1925+
if (auto progress = target->GetDebugger().GetCurrentProgressReport()) {
19271926
if (progress->total != UINT64_MAX) {
19281927
s.Format("[{0}/{1}]", progress->completed, progress->total);
19291928
return true;
@@ -1934,8 +1933,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
19341933

19351934
case Entry::Type::ProgressMessage:
19361935
if (Target *target = Target::GetTargetFromContexts(exe_ctx, sc)) {
1937-
Debugger &debugger = target->GetDebugger();
1938-
if (auto progress = debugger.GetCurrentProgressReport()) {
1936+
if (auto progress = target->GetDebugger().GetCurrentProgressReport()) {
19391937
s.PutCString(progress->message);
19401938
return true;
19411939
}

lldb/source/Core/Statusline.cpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,46 +71,50 @@ void Statusline::Disable() {
7171
}
7272

7373
void Statusline::Draw(std::string str) {
74-
static constexpr const size_t g_ellipsis = 3;
74+
lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP();
75+
if (!stream_sp)
76+
return;
77+
78+
static constexpr const size_t g_ellipsis_len = 3;
7579

7680
UpdateTerminalProperties();
7781

7882
m_last_str = str;
7983

8084
size_t column_width = ColumnWidth(str);
8185

82-
if (column_width + g_ellipsis >= m_terminal_width) {
86+
if (column_width + g_ellipsis_len >= m_terminal_width) {
8387
// FIXME: If there are hidden characters (e.g. UTF-8, ANSI escape
8488
// characters), this will strip the string more than necessary. Ideally we
8589
// want to strip until column_width == m_terminal_width.
8690
str = str.substr(0, m_terminal_width);
87-
str.replace(m_terminal_width - g_ellipsis, g_ellipsis, "...");
91+
str.replace(m_terminal_width - g_ellipsis_len, g_ellipsis_len, "...");
8892
column_width = ColumnWidth(str);
8993
}
9094

91-
if (lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP()) {
92-
LockedStreamFile locked_stream = stream_sp->Lock();
93-
locked_stream << ANSI_SAVE_CURSOR;
94-
locked_stream.Printf(ANSI_TO_START_OF_ROW,
95-
static_cast<unsigned>(m_terminal_height));
96-
locked_stream << ANSI_CLEAR_LINE;
97-
locked_stream << str;
98-
if (column_width < m_terminal_width)
99-
locked_stream << std::string(m_terminal_width - column_width, ' ');
100-
locked_stream << ANSI_NORMAL;
101-
locked_stream << ANSI_RESTORE_CURSOR;
102-
}
95+
LockedStreamFile locked_stream = stream_sp->Lock();
96+
locked_stream << ANSI_SAVE_CURSOR;
97+
locked_stream.Printf(ANSI_TO_START_OF_ROW,
98+
static_cast<unsigned>(m_terminal_height));
99+
locked_stream << ANSI_CLEAR_LINE;
100+
locked_stream << str;
101+
if (column_width < m_terminal_width)
102+
locked_stream << std::string(m_terminal_width - column_width, ' ');
103+
locked_stream << ANSI_NORMAL;
104+
locked_stream << ANSI_RESTORE_CURSOR;
103105
}
104106

105107
void Statusline::Reset() {
106-
if (lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP()) {
107-
LockedStreamFile locked_stream = stream_sp->Lock();
108-
locked_stream << ANSI_SAVE_CURSOR;
109-
locked_stream.Printf(ANSI_TO_START_OF_ROW,
110-
static_cast<unsigned>(m_terminal_height));
111-
locked_stream << ANSI_CLEAR_LINE;
112-
locked_stream << ANSI_RESTORE_CURSOR;
113-
}
108+
lldb::LockableStreamFileSP stream_sp = m_debugger.GetOutputStreamSP();
109+
if (!stream_sp)
110+
return;
111+
112+
LockedStreamFile locked_stream = stream_sp->Lock();
113+
locked_stream << ANSI_SAVE_CURSOR;
114+
locked_stream.Printf(ANSI_TO_START_OF_ROW,
115+
static_cast<unsigned>(m_terminal_height));
116+
locked_stream << ANSI_CLEAR_LINE;
117+
locked_stream << ANSI_RESTORE_CURSOR;
114118
}
115119

116120
void Statusline::UpdateTerminalProperties() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ def test(self):
3636
"set set show-statusline true",
3737
[
3838
"\x1b[0;{}r".format(terminal_height - 1),
39-
"a.out | main.c:4:15 | breakpoint 1.1 ",
39+
"a.out | main.c:2:11 | breakpoint 1.1 ",
4040
],
4141
)
4242

4343
# Change the terminal dimensions and make sure it's reflected immediately.
4444
self.child.setwinsize(terminal_height, 20)
45-
self.child.expect(re.escape("a.out | main.c:4:..."))
45+
self.child.expect(re.escape("a.out | main.c:2:..."))
4646
self.child.setwinsize(terminal_height, terminal_width)
4747

4848
# Change the format.

lldb/test/API/functionalities/statusline/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
int bar(int b) { return b * b; }
2-
31
int foo(int f) {
4-
int b = bar(f); // Break here
2+
int b = f * f; // Break here
53
return b;
64
}
75

0 commit comments

Comments
 (0)