[Lldb-commits] [lldb] 0309081 - Override CalculateFrameVariableError in SymbolFileOnDemand
George Hu via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 3 15:09:33 PDT 2022
Author: George Hu
Date: 2022-11-03T15:09:07-07:00
New Revision: 0309081e1f4b564693dd4e4d3c7b1d700780c62b
URL: https://github.com/llvm/llvm-project/commit/0309081e1f4b564693dd4e4d3c7b1d700780c62b
DIFF: https://github.com/llvm/llvm-project/commit/0309081e1f4b564693dd4e4d3c7b1d700780c62b.diff
LOG: Override CalculateFrameVariableError in SymbolFileOnDemand
Differential Revision: https://reviews.llvm.org/D137284
Added:
Modified:
lldb/include/lldb/Symbol/SymbolFileOnDemand.h
lldb/source/Symbol/SymbolFileOnDemand.cpp
lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
index 05708395687f2..a215c7e32b26a 100644
--- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -117,6 +117,9 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
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
index b4c9ed002a8ea..737cb1042ca76 100644
--- a/lldb/source/Symbol/SymbolFileOnDemand.cpp
+++ b/lldb/source/Symbol/SymbolFileOnDemand.cpp
@@ -274,6 +274,15 @@ SymbolFileOnDemand::ResolveSymbolContext(const Address &so_addr,
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
index 9b9195561606b..a6a7e159169b6 100644
--- 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 @@ def verify_variables(self, verify_dict, variables, varref_dict=None):
'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 = {
+ '<error>': {
+ '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 @@ def test_darwin_dwarf_missing_obj(self):
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 = {
- '<error>': {
- '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 "<error>"
+ 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)
More information about the lldb-commits
mailing list