diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h --- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h +++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h @@ -117,6 +117,9 @@ lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override; + lldb_private::Status + CalculateFrameVariableError(lldb_private::StackFrame &frame) override; + uint32_t ResolveSymbolContext( const lldb_private::SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, diff --git a/lldb/source/Symbol/SymbolFileOnDemand.cpp b/lldb/source/Symbol/SymbolFileOnDemand.cpp --- a/lldb/source/Symbol/SymbolFileOnDemand.cpp +++ b/lldb/source/Symbol/SymbolFileOnDemand.cpp @@ -274,6 +274,15 @@ return m_sym_file_impl->ResolveSymbolContext(so_addr, resolve_scope, sc); } +Status SymbolFileOnDemand::CalculateFrameVariableError(StackFrame &frame) { + if (!m_debug_info_enabled) { + LLDB_LOG(GetLog(), "[{0}] {1} is skipped", GetSymbolFileName(), + __FUNCTION__); + return Status(); + } + return m_sym_file_impl->CalculateFrameVariableError(frame); +} + uint32_t SymbolFileOnDemand::ResolveSymbolContext( const SourceLocationSpec &src_location_spec, SymbolContextItem resolve_scope, SymbolContextList &sc_list) { diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py --- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py +++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py @@ -85,6 +85,40 @@ 'variable "%s" in verify dictionary' % (name)) self.verify_values(verify_dict[name], variable, varref_dict) + def darwin_dwarf_missing_obj(self, initCommands): + self.build(debug_info="dwarf") + program = self.getBuildArtifact("a.out") + main_obj = self.getBuildArtifact("main.o") + self.assertTrue(os.path.exists(main_obj)) + # Delete the main.o file that contains the debug info so we force an + # error when we run to main and try to get variables + os.unlink(main_obj) + + self.create_debug_adaptor() + self.assertTrue(os.path.exists(program), 'executable must exist') + + self.launch(program=program, + initCommands=initCommands) + + functions = ['main'] + breakpoint_ids = self.set_function_breakpoints(functions) + self.assertEquals(len(breakpoint_ids), len(functions), "expect one breakpoint") + self.continue_to_breakpoints(breakpoint_ids) + + locals = self.vscode.get_local_variables() + + verify_locals = { + '': { + 'equals': {'type': 'const char *'}, + 'contains': { 'value': [ + 'debug map object file ', + 'main.o" containing debug info does not exist, debug info will not be loaded'] + } + }, + } + varref_dict = {} + self.verify_variables(verify_locals, locals, varref_dict) + @skipIfWindows @skipIfRemote def test_scopes_variables_setVariable_evaluate(self): @@ -529,33 +563,16 @@ changing compiler options and are designed to give better feedback to the user. ''' - self.build(debug_info="dwarf") - program = self.getBuildArtifact("a.out") - main_obj = self.getBuildArtifact("main.o") - self.assertTrue(os.path.exists(main_obj)) - # Delete the main.o file that contains the debug info so we force an - # error when we run to main and try to get variables - os.unlink(main_obj) - - self.create_debug_adaptor() - self.assertTrue(os.path.exists(program), 'executable must exist') - self.launch(program) - - functions = ['main'] - breakpoint_ids = self.set_function_breakpoints(functions) - self.assertEquals(len(breakpoint_ids), len(functions), "expect one breakpoint") - self.continue_to_breakpoints(breakpoint_ids) + self.darwin_dwarf_missing_obj(None) - locals = self.vscode.get_local_variables() - verify_locals = { - '': { - 'equals': {'type': 'const char *'}, - 'contains': { 'value': [ - 'debug map object file ', - 'main.o" containing debug info does not exist, debug info will not be loaded'] - } - }, - } - varref_dict = {} - self.verify_variables(verify_locals, locals, varref_dict) + @no_debug_info_test + @skipUnlessDarwin + def test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled(self): + ''' + Test that if we build a binary with DWARF in .o files and we remove + the .o file for main.cpp, that we get a variable named "" + whose value matches the appriopriate error. Test with symbol_ondemand_enabled. + ''' + initCommands = ['settings set symbols.load-on-demand true'] + self.darwin_dwarf_missing_obj(initCommands)