diff options
author | Pavel Labath <labath@google.com> | 2018-04-18 11:56:21 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2018-04-18 11:56:21 +0000 |
commit | acebc4379988237f16c7c1167651756b1ac29a90 (patch) | |
tree | c6c8187848167601fc3a77a176297a1a2ba84c46 /lldb/packages/Python/lldbsuite | |
parent | 90d141a295e2c48505d6c37eca18384803c9f652 (diff) | |
download | bcm5719-llvm-acebc4379988237f16c7c1167651756b1ac29a90.tar.gz bcm5719-llvm-acebc4379988237f16c7c1167651756b1ac29a90.zip |
Report more precise error message when attach fails
Summary:
If the remote stub sends a specific error message instead of just a E??
code, we can use this to display a more informative error message
instead of just the generic "unable to attach" message.
I write a test for this using the SB API.
On the console this will show up like:
(lldb) process attach ...
error: attach failed: <STUB-MESSAGE>
if the stub supports error messages, or:
error: attach failed: Error ??
if it doesn't.
Reviewers: jingham, JDevlieghere
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D45573
llvm-svn: 330247
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
2 files changed, 36 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py index 1761350b2e2..7fef9df6fc2 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py @@ -11,3 +11,28 @@ class TestGDBRemoteClient(GDBRemoteTestBase): target = self.createTarget("a.yaml") process = self.connect(target) self.assertPacketLogContains(["qProcessInfo", "qfThreadInfo"]) + + def test_attach_fail(self): + error_msg = "mock-error-msg" + + class MyResponder(MockGDBServerResponder): + # Pretend we don't have any process during the initial queries. + def qC(self): + return "E42" + + def qfThreadInfo(self): + return "OK" # No threads. + + # Then, when we are asked to attach, error out. + def vAttach(self, pid): + return "E42;" + error_msg.encode("hex") + + self.server.responder = MyResponder() + + target = self.dbg.CreateTarget("") + process = self.connect(target) + lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateConnected]) + + error = lldb.SBError() + target.AttachToProcessWithID(lldb.SBListener(), 47, error) + self.assertEquals(error_msg, error.GetCString()) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py index d3c9f32910f..34e5dc3e163 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py @@ -126,6 +126,8 @@ class MockGDBServerResponder: return self.qfThreadInfo() if packet == "qC": return self.qC() + if packet == "QEnableErrorStrings": + return self.QEnableErrorStrings() if packet == "?": return self.haltReason() if packet[0] == "H": @@ -137,6 +139,9 @@ class MockGDBServerResponder: if data is not None: return self._qXferResponse(data, has_more) return "" + if packet.startswith("vAttach;"): + pid = packet.partition(';')[2] + return self.vAttach(int(pid, 16)) if packet[0] == "Z": return self.setBreakpoint(packet) return self.other(packet) @@ -177,6 +182,9 @@ class MockGDBServerResponder: def qC(self): return "QC0" + def QEnableErrorStrings(self): + return "OK" + def haltReason(self): # SIGINT is 2, return type is 2 digit hex string return "S02" @@ -187,6 +195,9 @@ class MockGDBServerResponder: def _qXferResponse(self, data, has_more): return "%s%s" % ("m" if has_more else "l", escape_binary(data)) + def vAttach(self, pid): + raise self.UnexpectedPacketException() + def selectThread(self, op, thread_id): return "OK" |