[Lldb-commits] [PATCH] D70882: Add skipInitFiles option to lldb-vscode initialize
aadsm created this revision. aadsm added reviewers: clayborg, lanza, wallace. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. lldb has the -x option but this doesn't exist at all for lldb-vscode. To be honest my main goal is the ability to run the lldb-vscode tests without an lldbinit file polluting it. The DAP doesn't seem to have it (https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize) but it does seems like a good option to have overall. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70882 Files: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1194,7 +1194,10 @@ // }] // } void request_initialize(const llvm::json::Object &request) { - g_vsc.debugger = lldb::SBDebugger::Create(true /*source_init_files*/); + auto arguments = request.getObject("arguments"); + const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", true); + g_vsc.debugger = + lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); // Create an empty target right away since we might get breakpoint requests // before we are given an executable to launch in a "launch" request, or a // executable when attaching to a process by process ID in a "attach" Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -548,7 +548,8 @@ 'pathFormat': 'path', 'supportsRunInTerminalRequest': True, 'supportsVariablePaging': True, -'supportsVariableType': True +'supportsVariableType': True, +'skipInitFiles': True, } } response = self.send_recv(command_dict) Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1194,7 +1194,10 @@ // }] // } void request_initialize(const llvm::json::Object &request) { - g_vsc.debugger = lldb::SBDebugger::Create(true /*source_init_files*/); + auto arguments = request.getObject("arguments"); + const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", true); + g_vsc.debugger = + lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); // Create an empty target right away since we might get breakpoint requests // before we are given an executable to launch in a "launch" request, or a // executable when attaching to a process by process ID in a "attach" Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -548,7 +548,8 @@ 'pathFormat': 'path', 'supportsRunInTerminalRequest': True, 'supportsVariablePaging': True, -'supportsVariableType': True +'supportsVariableType': True, +'skipInitFiles': True, } } response = self.send_recv(command_dict) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70882: Add skipInitFiles option to lldb-vscode initialize
aadsm updated this revision to Diff 231629. aadsm added a comment. Oops, wrnog default Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70882/new/ https://reviews.llvm.org/D70882 Files: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1194,7 +1194,10 @@ // }] // } void request_initialize(const llvm::json::Object &request) { - g_vsc.debugger = lldb::SBDebugger::Create(true /*source_init_files*/); + auto arguments = request.getObject("arguments"); + const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", false); + g_vsc.debugger = + lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); // Create an empty target right away since we might get breakpoint requests // before we are given an executable to launch in a "launch" request, or a // executable when attaching to a process by process ID in a "attach" Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -548,7 +548,8 @@ 'pathFormat': 'path', 'supportsRunInTerminalRequest': True, 'supportsVariablePaging': True, -'supportsVariableType': True +'supportsVariableType': True, +'skipInitFiles': True, } } response = self.send_recv(command_dict) Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1194,7 +1194,10 @@ // }] // } void request_initialize(const llvm::json::Object &request) { - g_vsc.debugger = lldb::SBDebugger::Create(true /*source_init_files*/); + auto arguments = request.getObject("arguments"); + const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", false); + g_vsc.debugger = + lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); // Create an empty target right away since we might get breakpoint requests // before we are given an executable to launch in a "launch" request, or a // executable when attaching to a process by process ID in a "attach" Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -548,7 +548,8 @@ 'pathFormat': 'path', 'supportsRunInTerminalRequest': True, 'supportsVariablePaging': True, -'supportsVariableType': True +'supportsVariableType': True, +'skipInitFiles': True, } } response = self.send_recv(command_dict) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70883: [vscode.py] Make read_packet only return None when EOF
aadsm created this revision. aadsm added reviewers: clayborg, lanza, wallace. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. lldb-vscode has an issue when run in stdout/stdin mode because it will send all stdout generated by scripts through well.. stdout :) This is problematic for any adapter using lldb-vscode in that mode since it will not produce DAP messages. Even if we ignore that the method explicitly says that None is only returned in EOF situation which was not the case. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70883 Files: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -54,33 +54,32 @@ '''Decode a JSON packet that starts with the content length and is followed by the JSON bytes from a file 'f'. Returns None on EOF. ''' -line = f.readline().decode("utf-8") -if len(line) == 0: -return None # EOF. - -# Watch for line that starts with the prefix -prefix = 'Content-Length: ' -if line.startswith(prefix): -# Decode length of JSON bytes -if verbose: -print('content: "%s"' % (line)) -length = int(line[len(prefix):]) -if verbose: -print('length: "%u"' % (length)) -# Skip empty line -line = f.readline() -if verbose: -print('empty: "%s"' % (line)) -# Read JSON bytes -json_str = f.read(length) -if verbose: -print('json: "%s"' % (json_str)) -if trace_file: -trace_file.write('from adaptor:\n%s\n' % (json_str)) -# Decode the JSON bytes into a python dictionary -return json.loads(json_str) - -return None +while True: +line = f.readline().decode("utf-8") +if len(line) == 0: +return None # EOF. + +# Watch for line that starts with the prefix +prefix = 'Content-Length: ' +if line.startswith(prefix): +# Decode length of JSON bytes +if verbose: +print('content: "%s"' % (line)) +length = int(line[len(prefix):]) +if verbose: +print('length: "%u"' % (length)) +# Skip empty line +line = f.readline() +if verbose: +print('empty: "%s"' % (line)) +# Read JSON bytes +json_str = f.read(length) +if verbose: +print('json: "%s"' % (json_str)) +if trace_file: +trace_file.write('from adaptor:\n%s\n' % (json_str)) +# Decode the JSON bytes into a python dictionary +return json.loads(json_str) def packet_type_is(packet, packet_type): Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -54,33 +54,32 @@ '''Decode a JSON packet that starts with the content length and is followed by the JSON bytes from a file 'f'. Returns None on EOF. ''' -line = f.readline().decode("utf-8") -if len(line) == 0: -return None # EOF. - -# Watch for line that starts with the prefix -prefix = 'Content-Length: ' -if line.startswith(prefix): -# Decode length of JSON bytes -if verbose: -print('content: "%s"' % (line)) -length = int(line[len(prefix):]) -if verbose: -print('length: "%u"' % (length)) -# Skip empty line -line = f.readline() -if verbose: -print('empty: "%s"' % (line)) -# Read JSON bytes -json_str = f.read(length) -if verbose: -print('json: "%s"' % (json_str)) -if trace_file: -trace_file.write('from adaptor:\n%s\n' % (json_str)) -# Decode the JSON bytes into a python dictionary -return json.loads(json_str) - -return None +while True: +line = f.readline().decode("utf-8") +if len(line) == 0: +return None # EOF. + +# Watch for line that starts with the prefix +prefix = 'Content-Length: ' +if line.startswith(prefix): +# Decode length of JSON bytes +if verbose: +print('content: "%s"' % (line)) +length = int(line[len(prefix):]) +if verbose: +print('length: "%u"' % (length)) +# Skip empty line +line = f.readline() +if verbose: +print('empty: "%s"' % (line)) +# Read JSON bytes +
[Lldb-commits] [PATCH] D70884: [lldb] Fix TestFormattersSBAPI test
aadsm created this revision. aadsm added reviewers: clayborg, lanza, wallace. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. This test was broken in two ways: - Using the wrong API (e.g.: format = instead of SetFormat) - The hex checker was only checking "01" which will pass with 0x001 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70884 Files: lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py Index: lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py === --- lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py +++ lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py @@ -68,17 +68,17 @@ self.expect("frame variable foo.E", substrs=['b8cca70a']) -format.format = lldb.eFormatOctal +format.SetFormat(lldb.eFormatOctal) category.AddTypeFormat(lldb.SBTypeNameSpecifier("int"), format) self.expect("frame variable foo.A", -substrs=['01']) +substrs=[' 01']) self.expect("frame variable foo.E", substrs=['b8cca70a']) category.DeleteTypeFormat(lldb.SBTypeNameSpecifier("int")) category.DeleteTypeFormat(lldb.SBTypeNameSpecifier("long")) self.expect("frame variable foo.A", matching=False, -substrs=['01']) +substrs=[' 01']) self.expect("frame variable foo.E", matching=False, substrs=['b8cca70a']) @@ -90,10 +90,13 @@ new_category.IsValid(), "getting a non-existing category worked") new_category = self.dbg.CreateCategory("foobar") -new_category.enabled = True +new_category.SetEnabled(True) new_category.AddTypeSummary( lldb.SBTypeNameSpecifier( -"^.*t$", True), summary) +"^.*t$", +True, # is_regexp +), summary) + self.expect("frame variable foo.A", substrs=['hello world']) self.expect("frame variable foo.E", matching=False, @@ -102,7 +105,7 @@ substrs=['hello world']) self.expect("frame variable foo.F", substrs=['hello world']) -new_category.enabled = False +new_category.SetEnabled(False) self.expect("frame variable foo.A", matching=False, substrs=['hello world']) self.expect("frame variable foo.E", matching=False, @@ -379,7 +382,7 @@ lldb.SBTypeSummary.CreateWithScriptCode("return 'hello scripted world';")) self.expect("frame variable foo", matching=False, substrs=['hello scripted world']) -new_category.enabled = True +new_category.SetEnabled(True) self.expect("frame variable foo", matching=True, substrs=['hello scripted world']) Index: lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py === --- lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py +++ lldb/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py @@ -68,17 +68,17 @@ self.expect("frame variable foo.E", substrs=['b8cca70a']) -format.format = lldb.eFormatOctal +format.SetFormat(lldb.eFormatOctal) category.AddTypeFormat(lldb.SBTypeNameSpecifier("int"), format) self.expect("frame variable foo.A", -substrs=['01']) +substrs=[' 01']) self.expect("frame variable foo.E", substrs=['b8cca70a']) category.DeleteTypeFormat(lldb.SBTypeNameSpecifier("int")) category.DeleteTypeFormat(lldb.SBTypeNameSpecifier("long")) self.expect("frame variable foo.A", matching=False, -substrs=['01']) +substrs=[' 01']) self.expect("frame variable foo.E", matching=False, substrs=['b8cca70a']) @@ -90,10 +90,13 @@ new_category.IsValid(), "getting a non-existing category worked") new_category = self.dbg.CreateCategory("foobar") -new_category.enabled = True +new_category.SetEnabled(True) new_category.AddTypeSummary( lldb.SBTypeNameSpecifier( -"^.*t$", True), summary) +"^.*t$", +True, # is_regexp +), summary) + self.expect("frame variable foo.A", substrs=['hello world']) self.expect("frame variable foo.E", matching=False, @@ -102,7 +105,7 @@ substrs=['hello world']) self.expect("frame variable foo.F"
[Lldb-commits] [PATCH] D70885: [lldb] Use explicit lldb commands on tests
aadsm created this revision. aadsm added reviewers: clayborg, lanza, wallace. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Not a big deal but might be if in the future we had another command starting with br. I found this because I had an lldbinit that added a breakpad command. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70885 Files: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py @@ -350,8 +350,8 @@ # breakpoints get hit launchCommands = [ 'target create "%s"' % (program), -'br s -f main.c -l %d' % first_line, -'br s -f main.c -l %d' % second_line, +'breakpoint s -f main.c -l %d' % first_line, +'breakpoint s -f main.c -l %d' % second_line, 'process launch --stop-at-entry' ] Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py === --- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py +++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py @@ -350,8 +350,8 @@ # breakpoints get hit launchCommands = [ 'target create "%s"' % (program), -'br s -f main.c -l %d' % first_line, -'br s -f main.c -l %d' % second_line, +'breakpoint s -f main.c -l %d' % first_line, +'breakpoint s -f main.c -l %d' % second_line, 'process launch --stop-at-entry' ] ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70886: [lldb-vscode] capture the debuggers file handles before lldbinit runs
aadsm created this revision. aadsm added reviewers: clayborg, lanza, wallace. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. We need to do this before we create the debugger because the commands run in the lldbinit might do output to these handlers as well. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70886 Files: lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1194,14 +1194,6 @@ // }] // } void request_initialize(const llvm::json::Object &request) { - auto arguments = request.getObject("arguments"); - const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", false); - g_vsc.debugger = - lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); - // Create an empty target right away since we might get breakpoint requests - // before we are given an executable to launch in a "launch" request, or a - // executable when attaching to a process by process ID in a "attach" - // request. FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w"); if (out) { // Set the output and error file handles to redirect into nothing otherwise @@ -1212,6 +1204,14 @@ g_vsc.debugger.SetErrorFileHandle(out, false); } + auto arguments = request.getObject("arguments"); + const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", false); + g_vsc.debugger = + lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); + // Create an empty target right away since we might get breakpoint requests + // before we are given an executable to launch in a "launch" request, or a + // executable when attaching to a process by process ID in a "attach" + // request. g_vsc.target = g_vsc.debugger.CreateTarget(nullptr); lldb::SBListener listener = g_vsc.debugger.GetListener(); listener.StartListeningForEvents( Index: lldb/tools/lldb-vscode/lldb-vscode.cpp === --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1194,14 +1194,6 @@ // }] // } void request_initialize(const llvm::json::Object &request) { - auto arguments = request.getObject("arguments"); - const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", false); - g_vsc.debugger = - lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); - // Create an empty target right away since we might get breakpoint requests - // before we are given an executable to launch in a "launch" request, or a - // executable when attaching to a process by process ID in a "attach" - // request. FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w"); if (out) { // Set the output and error file handles to redirect into nothing otherwise @@ -1212,6 +1204,14 @@ g_vsc.debugger.SetErrorFileHandle(out, false); } + auto arguments = request.getObject("arguments"); + const auto skipInitFiles = GetBoolean(arguments, "skipInitFiles", false); + g_vsc.debugger = + lldb::SBDebugger::Create(!skipInitFiles /*source_init_files*/); + // Create an empty target right away since we might get breakpoint requests + // before we are given an executable to launch in a "launch" request, or a + // executable when attaching to a process by process ID in a "attach" + // request. g_vsc.target = g_vsc.debugger.CreateTarget(nullptr); lldb::SBListener listener = g_vsc.debugger.GetListener(); listener.StartListeningForEvents( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D70887: [lldb] Use realpath to avoid issues with symlinks in source paths
aadsm created this revision. aadsm added reviewers: clayborg, lanza, wallace. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. I was not able to sucessfully run TestDSYMSourcePathRemapping.py because the source mapping was using /tmp/ but the debugger was checking /private/tmp (which is a symlink to tmp). Maybe the debugger should realpath on it? Not sure but by making sure our tests always use the real path it avoids these kind of issues. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70887 Files: lldb/packages/Python/lldbsuite/test/lldbtest.py Index: lldb/packages/Python/lldbsuite/test/lldbtest.py === --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -656,15 +656,15 @@ def getSourceDir(self): """Return the full path to the current test.""" -return os.path.join(os.environ["LLDB_TEST"], self.mydir) +return os.path.realpath(os.path.join(os.environ["LLDB_TEST"], self.mydir)) def getBuildDirBasename(self): return self.__class__.__module__ + "." + self.testMethodName def getBuildDir(self): """Return the full path to the current test.""" -return os.path.join(os.environ["LLDB_BUILD"], self.mydir, -self.getBuildDirBasename()) +return os.path.realpath(os.path.join(os.environ["LLDB_BUILD"], self.mydir, +self.getBuildDirBasename())) def makeBuildDir(self): Index: lldb/packages/Python/lldbsuite/test/lldbtest.py === --- lldb/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -656,15 +656,15 @@ def getSourceDir(self): """Return the full path to the current test.""" -return os.path.join(os.environ["LLDB_TEST"], self.mydir) +return os.path.realpath(os.path.join(os.environ["LLDB_TEST"], self.mydir)) def getBuildDirBasename(self): return self.__class__.__module__ + "." + self.testMethodName def getBuildDir(self): """Return the full path to the current test.""" -return os.path.join(os.environ["LLDB_BUILD"], self.mydir, -self.getBuildDirBasename()) +return os.path.realpath(os.path.join(os.environ["LLDB_BUILD"], self.mydir, +self.getBuildDirBasename())) def makeBuildDir(self): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits