diff options
author | David Spickett <david.spickett@linaro.org> | 2023-12-08 11:21:55 +0000 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2023-12-08 11:24:07 +0000 |
commit | ffd61c1e96e9c8a472f305585930b45be0d639d3 (patch) | |
tree | 121dd5e3ac2802cf59ca0e79dd3721bd7fd00b54 | |
parent | c90cb6eee8296953c097fcc9fc6e61f739c0dad3 (diff) | |
download | llvm-ffd61c1e96e9c8a472f305585930b45be0d639d3.zip llvm-ffd61c1e96e9c8a472f305585930b45be0d639d3.tar.gz llvm-ffd61c1e96e9c8a472f305585930b45be0d639d3.tar.bz2 |
[lldb] Add missing nullptr checks when colouring symbol output
This adds some checks missed by c90cb6eee8296953c097fcc9fc6e61f739c0dad3,
probably because some tests only run on certain platforms.
-rw-r--r-- | lldb/source/Core/Address.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Symbol/Symbol.cpp | 8 |
2 files changed, 14 insertions, 6 deletions
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index d86fb15..19d34db 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -516,10 +516,14 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, if (symbol) { const char *symbol_name = symbol->GetName().AsCString(); if (symbol_name) { - llvm::StringRef ansi_prefix = - target->GetDebugger().GetRegexMatchAnsiPrefix(); - llvm::StringRef ansi_suffix = - target->GetDebugger().GetRegexMatchAnsiSuffix(); + llvm::StringRef ansi_prefix; + llvm::StringRef ansi_suffix; + if (target) { + ansi_prefix = + target->GetDebugger().GetRegexMatchAnsiPrefix(); + ansi_suffix = + target->GetDebugger().GetRegexMatchAnsiSuffix(); + } s->PutCStringColorHighlighted(symbol_name, pattern, ansi_prefix, ansi_suffix); addr_t delta = diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 0d20d11..fcc45f8 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -254,8 +254,12 @@ void Symbol::GetDescription(Stream *s, lldb::DescriptionLevel level, s->Printf(", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset()); } - llvm::StringRef ansi_prefix = target->GetDebugger().GetRegexMatchAnsiPrefix(); - llvm::StringRef ansi_suffix = target->GetDebugger().GetRegexMatchAnsiSuffix(); + llvm::StringRef ansi_prefix; + llvm::StringRef ansi_suffix; + if (target) { + ansi_prefix = target->GetDebugger().GetRegexMatchAnsiPrefix(); + ansi_suffix = target->GetDebugger().GetRegexMatchAnsiSuffix(); + } if (ConstString demangled = m_mangled.GetDemangledName()) { s->PutCString(", name=\""); s->PutCStringColorHighlighted(demangled.GetStringRef(), pattern, |