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
This commit is contained in:
Chaoren Lin 2015-05-07 01:42:53 +00:00
parent 3514f27456
commit 28b8ea1d55
1 changed files with 12 additions and 6 deletions

View File

@ -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)