mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
[lldb] Color the line marker
Highlight the color marker similar to what we do for the column marker. The default color matches the color of the current PC marker (->) in the default disassembly format. Differential revision: https://reviews.llvm.org/D75070
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "lldb/Symbol/SymbolContext.h"
|
||||
#include "lldb/Target/PathMappingList.h"
|
||||
#include "lldb/Target/Target.h"
|
||||
#include "lldb/Utility/AnsiTerminal.h"
|
||||
#include "lldb/Utility/ConstString.h"
|
||||
#include "lldb/Utility/DataBuffer.h"
|
||||
#include "lldb/Utility/DataBufferLLVM.h"
|
||||
@@ -148,6 +149,10 @@ static bool should_show_stop_column_with_caret(DebuggerSP debugger_sp) {
|
||||
return value == eStopShowColumnCaret;
|
||||
}
|
||||
|
||||
static bool should_show_stop_line_with_ansi(DebuggerSP debugger_sp) {
|
||||
return debugger_sp && debugger_sp->GetUseColor();
|
||||
}
|
||||
|
||||
size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
|
||||
uint32_t start_line, uint32_t count, uint32_t curr_line, uint32_t column,
|
||||
const char *current_line_cstr, Stream *s,
|
||||
@@ -191,8 +196,20 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
|
||||
::snprintf(prefix, sizeof(prefix), " ");
|
||||
}
|
||||
|
||||
s->Printf("%s%2.2s %-4u\t", prefix,
|
||||
line == curr_line ? current_line_cstr : "", line);
|
||||
char buffer[3];
|
||||
sprintf(buffer, "%2.2s", (line == curr_line) ? current_line_cstr : "");
|
||||
std::string current_line_highlight(buffer);
|
||||
|
||||
auto debugger_sp = m_debugger_wp.lock();
|
||||
if (should_show_stop_line_with_ansi(debugger_sp)) {
|
||||
current_line_highlight = ansi::FormatAnsiTerminalCodes(
|
||||
(debugger_sp->GetStopShowLineMarkerAnsiPrefix() +
|
||||
current_line_highlight +
|
||||
debugger_sp->GetStopShowLineMarkerAnsiSuffix())
|
||||
.str());
|
||||
}
|
||||
|
||||
s->Printf("%s%s %-4u\t", prefix, current_line_highlight.c_str(), line);
|
||||
|
||||
// So far we treated column 0 as a special 'no column value', but
|
||||
// DisplaySourceLines starts counting columns from 0 (and no column is
|
||||
@@ -204,7 +221,7 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
|
||||
size_t this_line_size =
|
||||
m_last_file_sp->DisplaySourceLines(line, columnToHighlight, 0, 0, s);
|
||||
if (column != 0 && line == curr_line &&
|
||||
should_show_stop_column_with_caret(m_debugger_wp.lock())) {
|
||||
should_show_stop_column_with_caret(debugger_sp)) {
|
||||
// Display caret cursor.
|
||||
std::string src_line;
|
||||
m_last_file_sp->GetLine(line, src_line);
|
||||
|
||||
Reference in New Issue
Block a user