Author: David Spickett Date: 2023-12-08T11:24:07Z New Revision: ffd61c1e96e9c8a472f305585930b45be0d639d3
URL: https://github.com/llvm/llvm-project/commit/ffd61c1e96e9c8a472f305585930b45be0d639d3 DIFF: https://github.com/llvm/llvm-project/commit/ffd61c1e96e9c8a472f305585930b45be0d639d3.diff LOG: [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. Added: Modified: lldb/source/Core/Address.cpp lldb/source/Symbol/Symbol.cpp Removed: ################################################################################ diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index d86fb1520a896..19d34db44ea55 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 0d20d11b8c4ff..fcc45f861c225 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, _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits