[Lldb-commits] [lldb] 3ae6337 - [LLDB]Initialize accept_socket with nullptr
Author: George Hu Date: 2022-09-20T12:17:32-07:00 New Revision: 3ae633766b57717522644ef44c5602a9a6402ee6 URL: https://github.com/llvm/llvm-project/commit/3ae633766b57717522644ef44c5602a9a6402ee6 DIFF: https://github.com/llvm/llvm-project/commit/3ae633766b57717522644ef44c5602a9a6402ee6.diff LOG: [LLDB]Initialize accept_socket with nullptr Fix high impact issue of illegal access of memory. Initialize accept_socket with nullptr. Differential Revision: https://reviews.llvm.org/D134293 Added: Modified: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Removed: diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 745e3363ef74a..b67cd7efd8846 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1233,7 +1233,7 @@ GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client, listen_socket.Listen("localhost:0", backlog).ToError()) return error; - Socket *accept_socket; + Socket *accept_socket = nullptr; std::future accept_status = std::async( std::launch::async, [&] { return listen_socket.Accept(accept_socket); }); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0309081 - Override CalculateFrameVariableError in SymbolFileOnDemand
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 = { +'': { +'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'
[Lldb-commits] [lldb] 03c7cd3 - Revert "[lldb-vscode] Send Statistics Dump in terminated event"
Author: George Hu Date: 2022-11-04T15:37:18-07:00 New Revision: 03c7cd3a616b731cf041fbf164078b349223c4ef URL: https://github.com/llvm/llvm-project/commit/03c7cd3a616b731cf041fbf164078b349223c4ef DIFF: https://github.com/llvm/llvm-project/commit/03c7cd3a616b731cf041fbf164078b349223c4ef.diff LOG: Revert "[lldb-vscode] Send Statistics Dump in terminated event" This reverts commit e3ccbae309273900a42e30b606c15c873d57f1ea. There is a bug which is failing the test running on mac. Added: Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py lldb/tools/lldb-vscode/JSONUtils.cpp lldb/tools/lldb-vscode/JSONUtils.h lldb/tools/lldb-vscode/lldb-vscode.cpp Removed: lldb/test/API/tools/lldb-vscode/terminated-event/Makefile lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp lldb/test/API/tools/lldb-vscode/terminated-event/foo.h lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py index c2de4ad5c7d9a..d6a6abca53e38 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -369,13 +369,7 @@ def wait_for_stopped(self, timeout=None): def wait_for_exited(self): event_dict = self.wait_for_event('exited') if event_dict is None: -raise ValueError("didn't get exited event") -return event_dict - -def wait_for_terminated(self): -event_dict = self.wait_for_event('terminated') -if event_dict is None: -raise ValueError("didn't get terminated event") +raise ValueError("didn't get stopped event") return event_dict def get_initialize_value(self, key): diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile b/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile deleted file mode 100644 index b30baf48b972e..0 --- a/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -DYLIB_NAME := foo -DYLIB_CXX_SOURCES := foo.cpp -CXX_SOURCES := main.cpp - -LD_EXTRAS := -Wl,-rpath "-Wl,$(shell pwd)" -USE_LIBDL :=1 - -include Makefile.rules - -all: a.out.stripped - -a.out.stripped: - strip -o a.out.stripped a.out - -ifneq "$(CODESIGN)" "" - $(CODESIGN) -fs - a.out.stripped -endif \ No newline at end of file diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py b/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py deleted file mode 100644 index a288012530881..0 --- a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -Test lldb-vscode terminated event -""" - -import vscode -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil -import lldbvscode_testcase -import re -import json - -class TestVSCode_terminatedEvent(lldbvscode_testcase.VSCodeTestCaseBase): - -@skipIfWindows -@skipIfRemote -def test_terminated_event(self): -''' -Terminated Event -Now contains the statistics of a debug session: -metatdata: -totalDebugInfoByteSize > 0 -totalDebugInfoEnabled > 0 -totalModuleCountHasDebugInfo > 0 -... -targetInfo: -totalBreakpointResolveTime > 0 -breakpoints: -recognize function breakpoint -recognize source line breakpoint -It should contains the breakpoints info: function bp & source line bp -''' - -program_basename = "a.out.stripped" -program = self.getBuildArtifact(program_basename) -self.build_and_launch(program) -# Set breakpoints -functions = ['foo'] -breakpoint_ids = self.set_function_breakpoints(functions) -self.assertEquals(len(breakpoint_ids), len(functions), 'expect one breakpoint') -main_bp_line = line_number('main.cpp', '// main breakpoint 1') -breakpoint_ids.append(self.set_source_breakpoints('main.cpp', [main_bp_line])) - -self.continue_to_breakpoints(breakpoint_ids) -self.continue_to_exit() - -statistics = self.vscode.wait_for_terminated()['statistics'] -self.assertTrue(statistics['totalDebugInfoByteSize'] > 0) -self.assertTrue(statistics['totalDebugInfoEnabled'] > 0) -self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0) - -# lldb-vscode debugs one target at a time -target = json.loads(statistics['targets'])[0] -self.assert
[Lldb-commits] [lldb] 7fe3586 - Send statistics in initialized event
Author: George Hu Date: 2022-11-15T19:09:05-08:00 New Revision: 7fe3586cda5b683766ec6b6d5ca2d98c2baaf162 URL: https://github.com/llvm/llvm-project/commit/7fe3586cda5b683766ec6b6d5ca2d98c2baaf162 DIFF: https://github.com/llvm/llvm-project/commit/7fe3586cda5b683766ec6b6d5ca2d98c2baaf162.diff LOG: Send statistics in initialized event Differential Revision: https://reviews.llvm.org/D138077 Added: lldb/test/API/tools/lldb-vscode/eventStatistic/Makefile lldb/test/API/tools/lldb-vscode/eventStatistic/TestVSCode_eventStatistic.py lldb/test/API/tools/lldb-vscode/eventStatistic/foo.cpp lldb/test/API/tools/lldb-vscode/eventStatistic/foo.h lldb/test/API/tools/lldb-vscode/eventStatistic/main.cpp Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py lldb/tools/lldb-vscode/JSONUtils.cpp lldb/tools/lldb-vscode/JSONUtils.h lldb/tools/lldb-vscode/lldb-vscode.cpp Removed: lldb/test/API/tools/lldb-vscode/terminated-event/Makefile lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp lldb/test/API/tools/lldb-vscode/terminated-event/foo.h lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py index c2de4ad5c7d9a..49f268ae28793 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -134,6 +134,7 @@ def __init__(self, recv, send, init_commands, log_file=None): self.configuration_done_sent = False self.frame_scopes = {} self.init_commands = init_commands +self.initialized_event = None @classmethod def encode_content(cls, s): @@ -231,6 +232,8 @@ def handle_recv_packet(self, packet): self._process_stopped() tid = body['threadId'] self.thread_stop_reasons[tid] = body +elif event == 'initialized': +self.initialized_event = packet elif event == 'breakpoint': # Breakpoint events come in when a breakpoint has locations # added or removed. Keep track of them so we can look for them diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile b/lldb/test/API/tools/lldb-vscode/eventStatistic/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/terminated-event/Makefile rename to lldb/test/API/tools/lldb-vscode/eventStatistic/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py b/lldb/test/API/tools/lldb-vscode/eventStatistic/TestVSCode_eventStatistic.py similarity index 64% rename from lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py rename to lldb/test/API/tools/lldb-vscode/eventStatistic/TestVSCode_eventStatistic.py index ae364a5fe1f0d..b70e21ef7d9da 100644 --- a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py +++ b/lldb/test/API/tools/lldb-vscode/eventStatistic/TestVSCode_eventStatistic.py @@ -10,7 +10,27 @@ import re import json -class TestVSCode_terminatedEvent(lldbvscode_testcase.VSCodeTestCaseBase): +class TestVSCode_eventStatistic(lldbvscode_testcase.VSCodeTestCaseBase): + +def check_statistic(self, statistics): +self.assertTrue(statistics['totalDebugInfoByteSize'] > 0) +self.assertTrue(statistics['totalDebugInfoEnabled'] > 0) +self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0) + +self.assertIsNotNone(statistics['memory']) +self.assertNotIn('modules', statistics.keys()) + +def check_target(self, statistics): +# lldb-vscode debugs one target at a time +target = json.loads(statistics['targets'])[0] +self.assertTrue(target['totalBreakpointResolveTime'] > 0) + +breakpoints = target['breakpoints'] +self.assertIn('foo', + breakpoints[0]['details']['Breakpoint']['BKPTResolver']['Options']['SymbolNames'], + 'foo is a symbol breakpoint') + self.assertTrue(breakpoints[1]['details']['Breakpoint']['BKPTResolver']['Options']['FileName'].endswith('main.cpp'), +'target has source line breakpoint in main.cpp') @skipIfWindows @skipIfRemote @@ -45,20 +65,33 @@ def test_terminated_event(self): self.continue_to_exit() statistics = self.vscode.wait_for_terminated()['statistics'] -self.assertTrue(statistics['totalDebugInfoByteSize'] > 0) -self.assertTrue(statistics['totalDebugInfoEnabled'] > 0) -self.assertTrue(statistics['totalModuleCountHasDebugInfo'] > 0) +self.check_statistic(statistics) +self.ch