diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2018-01-19 09:41:42 +0100 |
---|---|---|
committer | Markus Metzger <markus.t.metzger@intel.com> | 2018-02-09 14:03:19 +0100 |
commit | 9ee23a853c18da3c83530c7957464bc6b6e9fb16 (patch) | |
tree | cc521ddfe1933136fba498948eb2729ee48a9f55 /gdb/x86-linux-nat.c | |
parent | 5c3284c1ec2edc28b0697532fd094d93d5ecf31b (diff) | |
download | binutils-gdb-9ee23a853c18da3c83530c7957464bc6b6e9fb16.tar.gz |
btrace, gdbserver: use exceptions to convey btrace enable/disable errors
Change error reporting to use exceptions and be prepared to catch them in
gdbserver. We use the exception message in our error reply to GDB.
This may remove some detail from the error message in the native case since
errno is no longer printed. Later patches will improve that.
We're still using error strings on the RSP level. This patch does not affect
the interoperability of older/newer GDB/gdbserver.
gdbserver/
* server.c (handle_btrace_enable_bts, handle_btrace_enable_pt)
(handle_btrace_disable): Change return type to void. Use exceptions
to report errors.
(handle_btrace_general_set): Catch exception and copy message to
return message.
gdb/
* nat/linux-btrace.c (linux_enable_btrace): Throw exception if enabling
btrace failed.
* x86-linux-nat.c (x86_linux_enable_btrace): Catch btrace enabling
exception and use message in own exception.
Diffstat (limited to 'gdb/x86-linux-nat.c')
-rw-r--r-- | gdb/x86-linux-nat.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index 46bb6a4dca7..75f68de9c2d 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -216,14 +216,17 @@ static struct btrace_target_info * x86_linux_enable_btrace (struct target_ops *self, ptid_t ptid, const struct btrace_config *conf) { - struct btrace_target_info *tinfo; - - errno = 0; - tinfo = linux_enable_btrace (ptid, conf); - - if (tinfo == NULL) - error (_("Could not enable branch tracing for %s: %s."), - target_pid_to_str (ptid), safe_strerror (errno)); + struct btrace_target_info *tinfo = nullptr; + TRY + { + tinfo = linux_enable_btrace (ptid, conf); + } + CATCH (exception, RETURN_MASK_ERROR) + { + error (_("Could not enable branch tracing for %s: %s"), + target_pid_to_str (ptid), exception.message); + } + END_CATCH return tinfo; } |