From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: Ulrich Weigand <uweigand@de.ibm.com>
Subject: [PATCH 4/6] S390: Enable "maint set show-debug-regs"
Date: Thu, 15 Sep 2016 12:02:00 -0000 [thread overview]
Message-ID: <1473940907-4449-3-git-send-email-arnez@linux.vnet.ibm.com> (raw)
In-Reply-To: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com>
Implement a new function for dumping the S390 "debug
registers" (actually, the PER info) and invoke it at appropriate places.
Respect the variable show_debug_regs and make it settable by the user.
gdb/ChangeLog:
* s390-linux-nat.c (gdbcmd.h): New include.
(s390_show_debug_regs): New function.
(s390_stopped_by_watchpoint): Call it, if show_debug_regs is set.
(s390_prepare_to_resume): Likewise.
(_initialize_s390_nat): Register the command "maint set
show-debug-regs".
---
gdb/s390-linux-nat.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index b549246..c5d9bd3 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -28,6 +28,7 @@
#include "gregset.h"
#include "regset.h"
#include "nat/linux-ptrace.h"
+#include "gdbcmd.h"
#include "s390-linux-tdep.h"
#include "elf/common.h"
@@ -565,6 +566,37 @@ s390_linux_new_fork (struct lwp_info *parent, pid_t child_pid)
parent_state->watch_areas);
}
+/* Dump PER state. */
+
+static void
+s390_show_debug_regs (int tid, const char *where)
+{
+ per_struct per_info;
+ ptrace_area parea;
+
+ parea.len = sizeof (per_info);
+ parea.process_addr = (addr_t) &per_info;
+ parea.kernel_addr = offsetof (struct user_regs_struct, per_info);
+
+ if (ptrace (PTRACE_PEEKUSR_AREA, tid, &parea, 0) < 0)
+ perror_with_name (_("Couldn't retrieve debug regs"));
+
+ debug_printf ("PER (debug) state for %d -- %s\n"
+ " cr9-11: %lx %lx %lx\n"
+ " start, end: %lx %lx\n"
+ " code/ATMID: %x address: %lx PAID: %x\n",
+ tid,
+ where,
+ per_info.control_regs.words.cr[0],
+ per_info.control_regs.words.cr[1],
+ per_info.control_regs.words.cr[2],
+ per_info.starting_addr,
+ per_info.ending_addr,
+ per_info.lowcore.words.perc_atmid,
+ per_info.lowcore.words.address,
+ per_info.lowcore.words.access_id);
+}
+
static int
s390_stopped_by_watchpoint (struct target_ops *ops)
{
@@ -574,6 +606,9 @@ s390_stopped_by_watchpoint (struct target_ops *ops)
ptrace_area parea;
int result;
+ if (show_debug_regs)
+ s390_show_debug_regs (s390_inferior_tid (), "stop");
+
/* Speed up common case. */
if (VEC_empty (s390_watch_area, state->watch_areas))
return 0;
@@ -653,6 +688,9 @@ s390_prepare_to_resume (struct lwp_info *lp)
if (ptrace (PTRACE_POKEUSR_AREA, tid, &parea, 0) < 0)
perror_with_name (_("Couldn't modify watchpoint status"));
+
+ if (show_debug_regs)
+ s390_show_debug_regs (tid, "resume");
}
/* Mark the PER info as changed, so the next resume will update it. */
@@ -882,4 +920,17 @@ _initialize_s390_nat (void)
linux_nat_set_prepare_to_resume (t, s390_prepare_to_resume);
linux_nat_set_forget_process (t, s390_forget_process);
linux_nat_set_new_fork (t, s390_linux_new_fork);
+
+ /* A maintenance command to enable showing the PER state. */
+ add_setshow_boolean_cmd ("show-debug-regs", class_maintenance,
+ &show_debug_regs, _("\
+Set whether to show the PER (debug) hardware state."), _("\
+Show whether to show the PER (debug) hardware state."), _("\
+Use \"on\" to enable, \"off\" to disable.\n\
+If enabled, the PER state is shown after it is changed by GDB,\n\
+and when the inferior triggers a breakpoint or watchpoint."),
+ NULL,
+ NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
}
--
2.5.0
next prev parent reply other threads:[~2016-09-15 12:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-15 11:53 [PATCH 0/6] S390: Watchpoint enhancements and hardware breakpoints Andreas Arnez
2016-09-15 11:54 ` [PATCH] Fix order of inferiors in "thread apply all" Andreas Arnez
2016-09-15 12:03 ` Andreas Arnez
2016-09-15 11:59 ` [PATCH 1/6] S390: Avoid direct access to lwp_info structure Andreas Arnez
2016-09-15 12:01 ` [PATCH 3/6] S390: Multi-inferior watchpoint support Andreas Arnez
2016-09-15 12:02 ` [PATCH 2/6] S390: Migrate watch areas from list to VEC type Andreas Arnez
2016-09-15 12:02 ` Andreas Arnez [this message]
2016-09-15 12:02 ` [PATCH 5/6] linux-nat: Add function lwp_is_stepping Andreas Arnez
2016-09-15 15:08 ` Yao Qi
2016-09-15 12:02 ` [PATCH 6/6] S390: Hardware breakpoint support Andreas Arnez
2016-09-15 14:11 ` [PATCH 0/6] S390: Watchpoint enhancements and hardware breakpoints Pedro Alves
2016-09-16 12:43 ` Ulrich Weigand
2016-09-16 15:43 ` Pedro Alves
2016-09-16 17:30 ` Andreas Arnez
2016-09-15 14:58 ` Yao Qi
2016-09-15 17:14 ` Andreas Arnez
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=1473940907-4449-3-git-send-email-arnez@linux.vnet.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).