From: Tim Wiederhake <tim.wiederhake@intel.com>
To: gdb-patches@sourceware.org
Cc: palves@redhat.com, markus.t.metzger@intel.com
Subject: [PATCH 2/7] btrace: Export btrace_decode_error function.
Date: Thu, 27 Oct 2016 06:29:00 -0000 [thread overview]
Message-ID: <1477549711-2603-3-git-send-email-tim.wiederhake@intel.com> (raw)
In-Reply-To: <1477549711-2603-1-git-send-email-tim.wiederhake@intel.com>
2016-10-26 Tim Wiederhake <tim.wiederhake@intel.com>
gdb/ChangeLog:
* record-btrace.c (btrace_ui_out_decode_error): Move most of it ...
* btrace.c (btrace_decode_error): ... here. New function.
* btrace.h (btrace_decode_error): New export.
---
gdb/btrace.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
gdb/btrace.h | 5 +++++
gdb/record-btrace.c | 59 ++++-------------------------------------------------
3 files changed, 58 insertions(+), 55 deletions(-)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index 16ce2ef..0d1ba39 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1278,6 +1278,55 @@ btrace_maint_clear (struct btrace_thread_info *btinfo)
/* See btrace.h. */
+const char *
+btrace_decode_error (enum btrace_format format, int errcode)
+{
+ switch (format)
+ {
+ case BTRACE_FORMAT_BTS:
+ switch (errcode)
+ {
+ case BDE_BTS_OVERFLOW:
+ return _("instruction overflow");
+
+ case BDE_BTS_INSN_SIZE:
+ return _("unknown instruction");
+
+ default:
+ break;
+ }
+ break;
+
+#if defined (HAVE_LIBIPT)
+ case BTRACE_FORMAT_PT:
+ switch (errcode)
+ {
+ case BDE_PT_USER_QUIT:
+ return _("trace decode cancelled");
+
+ case BDE_PT_DISABLED:
+ return _("disabled");
+
+ case BDE_PT_OVERFLOW:
+ return _("overflow");
+
+ default:
+ if (errcode < 0)
+ return pt_errstr (pt_errcode (errcode));
+ break;
+ }
+ break;
+#endif /* defined (HAVE_LIBIPT) */
+
+ default:
+ break;
+ }
+
+ return _("unknown");
+}
+
+/* See btrace.h. */
+
void
btrace_fetch (struct thread_info *tp)
{
diff --git a/gdb/btrace.h b/gdb/btrace.h
index 114242d..d0497b4 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -384,6 +384,11 @@ extern void btrace_disable (struct thread_info *);
target_teardown_btrace instead of target_disable_btrace. */
extern void btrace_teardown (struct thread_info *);
+/* Return a human readable error string for the given ERRCODE in FORMAT.
+ The pointer will never be NULL and must not be freed. */
+
+extern const char *btrace_decode_error (enum btrace_format format, int errcode);
+
/* Fetch the branch trace for a single thread. */
extern void btrace_fetch (struct thread_info *);
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 84ce3ea..e57678b 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -464,63 +464,12 @@ static void
btrace_ui_out_decode_error (struct ui_out *uiout, int errcode,
enum btrace_format format)
{
- const char *errstr;
- int is_error;
-
- errstr = _("unknown");
- is_error = 1;
-
- switch (format)
- {
- default:
- break;
-
- case BTRACE_FORMAT_BTS:
- switch (errcode)
- {
- default:
- break;
-
- case BDE_BTS_OVERFLOW:
- errstr = _("instruction overflow");
- break;
-
- case BDE_BTS_INSN_SIZE:
- errstr = _("unknown instruction");
- break;
- }
- break;
-
-#if defined (HAVE_LIBIPT)
- case BTRACE_FORMAT_PT:
- switch (errcode)
- {
- case BDE_PT_USER_QUIT:
- is_error = 0;
- errstr = _("trace decode cancelled");
- break;
-
- case BDE_PT_DISABLED:
- is_error = 0;
- errstr = _("disabled");
- break;
-
- case BDE_PT_OVERFLOW:
- is_error = 0;
- errstr = _("overflow");
- break;
-
- default:
- if (errcode < 0)
- errstr = pt_errstr (pt_errcode (errcode));
- break;
- }
- break;
-#endif /* defined (HAVE_LIBIPT) */
- }
+ const char *errstr = btrace_decode_error (format, errcode);
ui_out_text (uiout, _("["));
- if (is_error)
+
+ /* ERRCODE > 0 indicates notifications on BTRACE_FORMAT_PT. */
+ if (!(format == BTRACE_FORMAT_PT && errcode > 0))
{
ui_out_text (uiout, _("decode error ("));
ui_out_field_int (uiout, "errcode", errcode);
--
2.7.4
prev parent reply other threads:[~2016-10-27 6:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-27 6:29 [PATCH 0/7] Python bindings for btrace recordings Tim Wiederhake
2016-10-27 6:29 ` [PATCH 1/7] btrace: Count gaps as one instruction explicitly Tim Wiederhake
2016-10-27 6:29 ` [PATCH 6/7] python: Add tests for record Python bindings Tim Wiederhake
2016-10-27 15:59 ` Simon Marchi
2016-10-28 13:49 ` Wiederhake, Tim
2016-10-28 17:47 ` Simon Marchi
2016-10-27 6:29 ` [PATCH 3/7] btrace: Use binary search to find instruction Tim Wiederhake
2016-10-27 14:28 ` Simon Marchi
2016-11-02 10:01 ` Wiederhake, Tim
2016-11-02 11:24 ` Simon Marchi
2016-10-27 6:29 ` [PATCH 7/7] Add documentation for new instruction record Python bindings Tim Wiederhake
2016-10-27 15:02 ` Eli Zaretskii
2016-10-27 16:10 ` Simon Marchi
2016-10-27 6:29 ` [PATCH 5/7] python: Implement btrace Python bindings for record history Tim Wiederhake
2016-10-27 6:29 ` [PATCH 4/7] python: Create " Tim Wiederhake
2016-10-27 15:53 ` Simon Marchi
2016-10-28 14:12 ` Wiederhake, Tim
2016-10-27 6:29 ` Tim Wiederhake [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477549711-2603-3-git-send-email-tim.wiederhake@intel.com \
--to=tim.wiederhake@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox