Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify "platform connect" to connect to processes as well
The standard remote debugging workflow with gdb is to start the application on the remote host under gdbserver (e.g.: gdbserver :5039 a.out) and then connect to it with gdb. The same workflow is supported by debugserver/lldb-gdbserver with a very similar syntax but to access all features of lldb we need to be connected also to an lldb-platform instance running on the target. Before this change this had to be done manually with starting a separate lldb-platform on the target machine and then connecting to it with lldb before connecting to the process. This change modifies the behavior of "platform connect" with automatically connecting to the process instance if it was started by the remote platform. With this command replacing gdbserver in a gdb based worflow is usually as simple as replacing the command to execute gdbserver with executing lldb-platform. Differential revision: http://reviews.llvm.org/D14952 llvm-svn: 255016
- Loading branch information
Tamas Berghammer
committed
Dec 8, 2015
1 parent
59d092f
commit ccd6cff
Showing
25 changed files
with
576 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
LEVEL = ../../../make | ||
|
||
CXX_SOURCES := main.cpp | ||
|
||
include $(LEVEL)/Makefile.rules |
55 changes: 55 additions & 0 deletions
55
...n/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from __future__ import print_function | ||
|
||
import gdbremote_testcase | ||
from lldbsuite.test.lldbtest import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase): | ||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
@llgs_test | ||
@no_debug_info_test | ||
@skipIf(remote=False) | ||
def test_platform_process_connect(self): | ||
self.build() | ||
self.init_llgs_test(False) | ||
|
||
working_dir = lldb.remote_platform.GetWorkingDirectory() | ||
err = lldb.remote_platform.Put(lldb.SBFileSpec(os.path.join(os.getcwd(), "a.out")), | ||
lldb.SBFileSpec(os.path.join(working_dir, "a.out"))) | ||
if err.Fail(): | ||
raise RuntimeError("Unable copy '%s' to '%s'.\n>>> %s" % (f, wd, err.GetCString())) | ||
|
||
port_file = "%s/port" % working_dir | ||
commandline_args = ["platform", "--listen", "*:0", "--socket-file", port_file, "--", "%s/a.out" % working_dir, "foo"] | ||
self.spawnSubprocess(self.debug_monitor_exe, commandline_args, install_remote=False) | ||
self.addTearDownHook(self.cleanupSubprocesses) | ||
new_port = self.run_shell_cmd("while [ ! -f %s ]; do sleep 0.25; done && cat %s" % (port_file, port_file)) | ||
|
||
new_debugger = lldb.SBDebugger.Create() | ||
new_debugger.SetAsync(False) | ||
def del_debugger(): | ||
del new_debugger | ||
self.addTearDownHook(del_debugger) | ||
|
||
new_platform = lldb.SBPlatform(lldb.remote_platform.GetName()) | ||
new_debugger.SetSelectedPlatform(new_platform) | ||
new_interpreter = new_debugger.GetCommandInterpreter() | ||
|
||
m = re.search("(.*):[0-9]+", configuration.lldb_platform_url) | ||
command = "platform connect %s:%s" % (m.group(1), new_port) | ||
result = lldb.SBCommandReturnObject() | ||
new_interpreter.HandleCommand(command, result) | ||
self.assertTrue(result.Succeeded(), "platform process connect failed: %s" % result.GetOutput()) | ||
|
||
target = new_debugger.GetSelectedTarget() | ||
process = target.GetProcess() | ||
thread = process.GetThreadAtIndex(0) | ||
|
||
breakpoint = target.BreakpointCreateByName("main") | ||
process.Continue() | ||
|
||
frame = thread.GetFrameAtIndex(0) | ||
self.assertEqual(frame.GetFunction().GetName(), "main") | ||
self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2) | ||
process.Continue() |
7 changes: 7 additions & 0 deletions
7
lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <cstdio> | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
printf("argc: %d\n", argc); | ||
return argv[0][0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.