diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -960,8 +960,9 @@ // See if we can find the Module, if so stick it in the SymbolContext. FileSpec module_file_spec(spec_string); ModuleSpec module_spec(module_file_spec); - lldb::ModuleSP module_sp( - m_target_sp->GetImages().FindFirstModule(module_spec)); + lldb::ModuleSP module_sp = + m_target_sp ? m_target_sp->GetImages().FindFirstModule(module_spec) + : nullptr; m_type |= eModuleSpecified; if (module_sp) m_module_sp = module_sp; diff --git a/lldb/test/Shell/Commands/command-stop-hook-no-target.test b/lldb/test/Shell/Commands/command-stop-hook-no-target.test new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/Commands/command-stop-hook-no-target.test @@ -0,0 +1,4 @@ +# RUN: %clang_host -g %S/Inputs/main.c -o %t +# RUN: %lldb -b -o 'target stop-hook add --name test --shlib test -o "p 95000 + 126"' -o 'file %t' -o 'b main' -o 'r' 2>&1 | FileCheck %s +# CHECK: Stop hook #1 added +# CHECK-NOT: 95126