Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lldb/include/lldb/Core/Debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
const FormatEntity::Entry *GetStatuslineFormat() const;
bool SetStatuslineFormat(const FormatEntity::Entry &format);

llvm::StringRef GetSeparator() const;
bool SetSeparator(llvm::StringRef s);

llvm::StringRef GetShowProgressAnsiPrefix() const;

llvm::StringRef GetShowProgressAnsiSuffix() const;
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/Core/FormatEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ struct Entry {
CurrentPCArrow,
ProgressCount,
ProgressMessage,
Separator,
};

struct Definition {
Expand Down
17 changes: 13 additions & 4 deletions lldb/source/Core/CoreProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,19 @@ let Definition = "debugger" in {
Global,
DefaultTrue,
Desc<"Whether to show a statusline at the bottom of the terminal.">;
def StatuslineFormat: Property<"statusline-format", "FormatEntity">,
Global,
DefaultStringValue<"${ansi.negative}{${target.file.basename}}{ | ${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ | {${progress.count} }${progress.message}}">,
Desc<"The default statusline format string.">;
def Separator : Property<"separator", "String">,
Global,
DefaultStringValue<"│ ">,
Desc<"A separator used, e.g., in the status line.">;
def StatuslineFormat
: Property<"statusline-format", "FormatEntity">,
Global,
DefaultStringValue<
"${ansi.negative}{${target.file.basename}}{ "
"${separator}${line.file.basename}:${line.number}:${line.column}}{ "
"${separator}${thread.stop-reason}}{ "
"${separator}{${progress.count} }${progress.message}}">,
Desc<"The default statusline format string.">;
def UseSourceCache: Property<"use-source-cache", "Boolean">,
Global,
DefaultTrue,
Expand Down
22 changes: 20 additions & 2 deletions lldb/source/Core/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,19 @@ bool Debugger::SetStatuslineFormat(const FormatEntity::Entry &format) {
return ret;
}

llvm::StringRef Debugger::GetSeparator() const {
constexpr uint32_t idx = ePropertySeparator;
return GetPropertyAtIndexAs<llvm::StringRef>(
idx, g_debugger_properties[idx].default_cstr_value);
}

bool Debugger::SetSeparator(llvm::StringRef s) {
constexpr uint32_t idx = ePropertySeparator;
bool ret = SetPropertyAtIndex(idx, s);
RedrawStatusline();
return ret;
}

bool Debugger::GetUseAutosuggestion() const {
const uint32_t idx = ePropertyShowAutosuggestion;
return GetPropertyAtIndexAs<bool>(
Expand Down Expand Up @@ -999,11 +1012,16 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)

// Turn off use-color if this is a dumb terminal.
const char *term = getenv("TERM");
if (term && !strcmp(term, "dumb"))
auto disable_color = [&]() {
SetUseColor(false);
SetSeparator("| ");
};

if (term && !strcmp(term, "dumb"))
disable_color();
// Turn off use-color if we don't write to a terminal with color support.
if (!GetOutputFileSP()->GetIsTerminalWithColors())
SetUseColor(false);
disable_color();

if (Diagnostics::Enabled()) {
m_diagnostics_callback_id = Diagnostics::Instance().AddCallback(
Expand Down
9 changes: 9 additions & 0 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ constexpr Definition g_top_level_entries[] = {
g_var_child_entries, true),
Entry::DefinitionWithChildren("progress", EntryType::Invalid,
g_progress_child_entries),
Definition("separator", EntryType::Separator),
};

constexpr Definition g_root = Entry::DefinitionWithChildren(
Expand Down Expand Up @@ -367,6 +368,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
ENUM_TO_CSTR(CurrentPCArrow);
ENUM_TO_CSTR(ProgressCount);
ENUM_TO_CSTR(ProgressMessage);
ENUM_TO_CSTR(Separator);
}
return "???";
}
Expand Down Expand Up @@ -1901,6 +1903,13 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
}
}
return false;

case Entry::Type::Separator:
if (Target *target = Target::GetTargetFromContexts(exe_ctx, sc)) {
s << target->GetDebugger().GetSeparator();
return true;
}
return false;
}

return false;
Expand Down
7 changes: 5 additions & 2 deletions lldb/test/API/functionalities/statusline/TestStatusline.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test(self):

# 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 separator "| "')
self.expect(
"set set show-statusline true",
[
Expand All @@ -46,10 +47,12 @@ def test(self):
self.child.setwinsize(terminal_height, terminal_width)

# Change the format.
self.expect('set set separator "S"')
self.expect(
'set set statusline-format "target = {${target.file.basename}}"',
["target = a.out"],
'set set statusline-format "target = {${target.file.basename}} ${separator}"',
["target = a.out S"],
)
self.expect('set set separator "| "')

# Hide the statusline and check or the control character.
self.expect(
Expand Down
Loading