https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/195853
>From 9e9786ce5d5de481af6f6b3df7f1d58c267a4393 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <[email protected]> Date: Tue, 5 May 2026 14:19:11 +0100 Subject: [PATCH 1/2] [lldb] Fix no compile unit crash. This crash happens in lldb-dap when hovering inspecting over instruction addresses in a frame that does not have debug information. --- lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp | 3 +++ lldb/source/ValueObject/DILEval.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp index fdc0caa8dd731..74c29e2b803e3 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -99,6 +99,9 @@ Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback( return eCallbackReturnContinue; CompileUnit *cu = context.comp_unit; + if (!cu) + return eCallbackReturnContinue; + FileSpec cu_file_spec = cu->GetPrimaryFile(); std::vector<uint32_t> line_matches; context.target_sp->GetSourceManager().FindLinesMatchingRegex( diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp index 38db893c923b8..d849a7a7d57c3 100644 --- a/lldb/source/ValueObject/DILEval.cpp +++ b/lldb/source/ValueObject/DILEval.cpp @@ -18,6 +18,7 @@ #include "lldb/ValueObject/ValueObject.h" #include "lldb/ValueObject/ValueObjectRegister.h" #include "lldb/ValueObject/ValueObjectVariable.h" +#include "llvm/Support/ErrorExtras.h" #include "llvm/Support/FormatAdapters.h" #include <memory> @@ -44,11 +45,14 @@ static lldb::ValueObjectSP ArrayToPointerConversion(ValueObject &valobj, } static llvm::Expected<lldb::TypeSystemSP> -GetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx) { +GetTypeSystemFromCU(const std::shared_ptr<StackFrame> &ctx) { SymbolContext symbol_context = ctx->GetSymbolContext(lldb::eSymbolContextCompUnit); - lldb::LanguageType language = symbol_context.comp_unit->GetLanguage(); + if (!symbol_context.comp_unit) + return llvm::createStringErrorV("no compile unit for frame: {}", + ctx->GetFunctionName()); + lldb::LanguageType language = symbol_context.comp_unit->GetLanguage(); symbol_context = ctx->GetSymbolContext(lldb::eSymbolContextModule); return symbol_context.module_sp->GetTypeSystemForLanguage(language); } >From e7ea8c1aa85ed318c828715746b2738293b3ea00 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <[email protected]> Date: Wed, 6 May 2026 16:16:48 +0100 Subject: [PATCH 2/2] add review changes --- lldb/source/ValueObject/DILEval.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp index d849a7a7d57c3..0253df6c9ad45 100644 --- a/lldb/source/ValueObject/DILEval.cpp +++ b/lldb/source/ValueObject/DILEval.cpp @@ -44,16 +44,15 @@ static lldb::ValueObjectSP ArrayToPointerConversion(ValueObject &valobj, /* do_deref */ false); } -static llvm::Expected<lldb::TypeSystemSP> -GetTypeSystemFromCU(const std::shared_ptr<StackFrame> &ctx) { +static llvm::Expected<lldb::TypeSystemSP> GetTypeSystemFromCU(StackFrame &ctx) { SymbolContext symbol_context = - ctx->GetSymbolContext(lldb::eSymbolContextCompUnit); + ctx.GetSymbolContext(lldb::eSymbolContextCompUnit); if (!symbol_context.comp_unit) return llvm::createStringErrorV("no compile unit for frame: {}", - ctx->GetFunctionName()); + ctx.GetFunctionName()); lldb::LanguageType language = symbol_context.comp_unit->GetLanguage(); - symbol_context = ctx->GetSymbolContext(lldb::eSymbolContextModule); + symbol_context = ctx.GetSymbolContext(lldb::eSymbolContextModule); return symbol_context.module_sp->GetTypeSystemForLanguage(language); } @@ -63,7 +62,7 @@ Interpreter::UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location) { return llvm::make_error<DILDiagnosticError>(m_expr, "invalid value object", location); llvm::Expected<lldb::TypeSystemSP> type_system = - GetTypeSystemFromCU(m_exe_ctx_scope); + GetTypeSystemFromCU(*m_exe_ctx_scope); if (!type_system) return type_system.takeError(); @@ -189,7 +188,7 @@ Interpreter::PromoteSignedInteger(CompilerType &lhs_type, if (*rhs_size == *lhs_size) { llvm::Expected<lldb::TypeSystemSP> type_system = - GetTypeSystemFromCU(m_exe_ctx_scope); + GetTypeSystemFromCU(*m_exe_ctx_scope); if (!type_system) return type_system.takeError(); CompilerType r_type_unsigned = GetBasicType( @@ -708,7 +707,7 @@ llvm::Expected<lldb::ValueObjectSP> Interpreter::EvaluateBinarySubtraction( diff /= item_size; llvm::Expected<lldb::TypeSystemSP> type_system = - GetTypeSystemFromCU(m_exe_ctx_scope); + GetTypeSystemFromCU(*m_exe_ctx_scope); if (!type_system) return type_system.takeError(); CompilerType ptrdiff_type = type_system.get()->GetPointerDiffType(true); @@ -1182,7 +1181,7 @@ Interpreter::PickIntegerType(lldb::TypeSystemSP type_system, llvm::Expected<lldb::ValueObjectSP> Interpreter::Visit(const IntegerLiteralNode &node) { llvm::Expected<lldb::TypeSystemSP> type_system = - GetTypeSystemFromCU(m_exe_ctx_scope); + GetTypeSystemFromCU(*m_exe_ctx_scope); if (!type_system) return type_system.takeError(); @@ -1206,7 +1205,7 @@ Interpreter::Visit(const IntegerLiteralNode &node) { llvm::Expected<lldb::ValueObjectSP> Interpreter::Visit(const FloatLiteralNode &node) { llvm::Expected<lldb::TypeSystemSP> type_system = - GetTypeSystemFromCU(m_exe_ctx_scope); + GetTypeSystemFromCU(*m_exe_ctx_scope); if (!type_system) return type_system.takeError(); @@ -1229,7 +1228,7 @@ llvm::Expected<lldb::ValueObjectSP> Interpreter::Visit(const BooleanLiteralNode &node) { bool value = node.GetValue(); llvm::Expected<lldb::TypeSystemSP> type_system = - GetTypeSystemFromCU(m_exe_ctx_scope); + GetTypeSystemFromCU(*m_exe_ctx_scope); if (!type_system) return type_system.takeError(); return ValueObject::CreateValueObjectFromBool(m_exe_ctx_scope, *type_system, _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
