Skip to content

Commit ffd61c1

Browse files
committed
[lldb] Add missing nullptr checks when colouring symbol output
This adds some checks missed by c90cb6e, probably because some tests only run on certain platforms.
1 parent c90cb6e commit ffd61c1

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lldb/source/Core/Address.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,14 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
516516
if (symbol) {
517517
const char *symbol_name = symbol->GetName().AsCString();
518518
if (symbol_name) {
519-
llvm::StringRef ansi_prefix =
520-
target->GetDebugger().GetRegexMatchAnsiPrefix();
521-
llvm::StringRef ansi_suffix =
522-
target->GetDebugger().GetRegexMatchAnsiSuffix();
519+
llvm::StringRef ansi_prefix;
520+
llvm::StringRef ansi_suffix;
521+
if (target) {
522+
ansi_prefix =
523+
target->GetDebugger().GetRegexMatchAnsiPrefix();
524+
ansi_suffix =
525+
target->GetDebugger().GetRegexMatchAnsiSuffix();
526+
}
523527
s->PutCStringColorHighlighted(symbol_name, pattern,
524528
ansi_prefix, ansi_suffix);
525529
addr_t delta =

lldb/source/Symbol/Symbol.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ void Symbol::GetDescription(Stream *s, lldb::DescriptionLevel level,
254254
s->Printf(", value = 0x%16.16" PRIx64,
255255
m_addr_range.GetBaseAddress().GetOffset());
256256
}
257-
llvm::StringRef ansi_prefix = target->GetDebugger().GetRegexMatchAnsiPrefix();
258-
llvm::StringRef ansi_suffix = target->GetDebugger().GetRegexMatchAnsiSuffix();
257+
llvm::StringRef ansi_prefix;
258+
llvm::StringRef ansi_suffix;
259+
if (target) {
260+
ansi_prefix = target->GetDebugger().GetRegexMatchAnsiPrefix();
261+
ansi_suffix = target->GetDebugger().GetRegexMatchAnsiSuffix();
262+
}
259263
if (ConstString demangled = m_mangled.GetDemangledName()) {
260264
s->PutCString(", name=\"");
261265
s->PutCStringColorHighlighted(demangled.GetStringRef(), pattern,

0 commit comments

Comments
 (0)