From 28b8ea1d551dea33232359329a63fd8d8b3e410d Mon Sep 17 00:00:00 2001 From: Chaoren Lin Date: Thu, 7 May 2015 01:42:53 +0000 Subject: [PATCH] Fix adb forward in gdbremote_testcase to support multiple devices. Summary: Update to D9510. Reviewers: chying, tberghammer, ovyalov Reviewed By: ovyalov Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9542 llvm-svn: 236688 --- .../tools/lldb-server/gdbremote_testcase.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lldb/test/tools/lldb-server/gdbremote_testcase.py b/lldb/test/tools/lldb-server/gdbremote_testcase.py index 81a794e4e876..6303c0685bef 100644 --- a/lldb/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/test/tools/lldb-server/gdbremote_testcase.py @@ -62,7 +62,12 @@ class GdbRemoteTestCaseBase(TestBase): self.stub_sends_two_stop_notifications_on_kill = False if lldb.platform_url: scheme, host = re.match('(.+)://(.+):\d+', lldb.platform_url).groups() - self.stub_hostname = 'localhost' if scheme == 'adb' else host + if scheme == 'adb': + self.stub_device = host + self.stub_hostname = 'localhost' + else: + self.stub_device = None + self.stub_hostname = host else: self.stub_hostname = "localhost" @@ -177,11 +182,12 @@ class GdbRemoteTestCaseBase(TestBase): # when the process truly dies. self.stub_sends_two_stop_notifications_on_kill = True - def forward_adb_port(self, source, target, direction): + def forward_adb_port(self, source, target, direction, device): + adb = [ 'adb' ] + ([ '-s', device ] if device else []) + [ direction ] def remove_port_forward(): - subprocess.call(["adb", direction, "--remove", "tcp:%d" % source]) - - subprocess.call(["adb", direction, "tcp:%d" % source, "tcp:%d" % target]) + subprocess.call(adb + [ "--remove", "tcp:%d" % source]) + + subprocess.call(adb + [ "tcp:%d" % source, "tcp:%d" % target]) self.addTearDownHook(remove_port_forward) def create_socket(self): @@ -190,7 +196,7 @@ class GdbRemoteTestCaseBase(TestBase): triple = self.dbg.GetSelectedPlatform().GetTriple() if re.match(".*-.*-.*-android", triple): - self.forward_adb_port(self.port, self.port, "forward") + self.forward_adb_port(self.port, self.port, "forward", self.stub_device) connect_info = (self.stub_hostname, self.port) sock.connect(connect_info)