From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: Ulrich Weigand <uweigand@de.ibm.com>
Subject: [PATCH 1/6] S390: Avoid direct access to lwp_info structure
Date: Thu, 15 Sep 2016 11:59:00 -0000 [thread overview]
Message-ID: <1473940769-3870-1-git-send-email-arnez@linux.vnet.ibm.com> (raw)
In-Reply-To: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com>
When using the lwp_info structure, avoid accessing its members directly,
and use the advertised function interfaces instead. This is according
to the instructions in linux-nat.h and prepares for making some of the
code common between gdb and gdbserver.
gdb/ChangeLog:
* s390-linux-nat.c (s390_prepare_to_resume): Use advertised lwp
functions instead of accessing lwp_info structure members.
(s390_mark_per_info_changed): New function.
(s390_new_thread): Use it.
(s390_refresh_per_info_cb): New function.
(s390_refresh_per_info): Remove parameter. Refresh all lwps of
the current process.
(s390_insert_watchpoint): Adjust call to s390_refresh_per_info.
(s390_remove_watchpoint): Likewise.
---
gdb/s390-linux-nat.c | 60 +++++++++++++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 24 deletions(-)
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index e91297b..1e937f9 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -488,16 +488,16 @@ s390_prepare_to_resume (struct lwp_info *lp)
CORE_ADDR watch_lo_addr = (CORE_ADDR)-1, watch_hi_addr = 0;
struct watch_area *area;
+ struct arch_lwp_info *lp_priv = lwp_arch_private_info (lp);
- if (lp->arch_private == NULL
- || !lp->arch_private->per_info_changed)
+ if (lp_priv == NULL || !lp_priv->per_info_changed)
return;
- lp->arch_private->per_info_changed = 0;
+ lp_priv->per_info_changed = 0;
- tid = ptid_get_lwp (lp->ptid);
+ tid = ptid_get_lwp (ptid_of_lwp (lp));
if (tid == 0)
- tid = ptid_get_pid (lp->ptid);
+ tid = ptid_get_pid (ptid_of_lwp (lp));
for (area = watch_base; area; area = area->next)
{
@@ -528,19 +528,15 @@ s390_prepare_to_resume (struct lwp_info *lp)
perror_with_name (_("Couldn't modify watchpoint status"));
}
-/* Make sure that LP is stopped and mark its PER info as changed, so
- the next resume will update it. */
+/* Mark the PER info as changed, so the next resume will update it. */
static void
-s390_refresh_per_info (struct lwp_info *lp)
+s390_mark_per_info_changed (struct lwp_info *lp)
{
- if (lp->arch_private == NULL)
- lp->arch_private = XCNEW (struct arch_lwp_info);
+ if (lwp_arch_private_info (lp) == NULL)
+ lwp_set_arch_private_info (lp, XCNEW (struct arch_lwp_info));
- lp->arch_private->per_info_changed = 1;
-
- if (!lp->stopped)
- linux_stop_lwp (lp);
+ lwp_arch_private_info (lp)->per_info_changed = 1;
}
/* When attaching to a new thread, mark its PER info as changed. */
@@ -548,8 +544,30 @@ s390_refresh_per_info (struct lwp_info *lp)
static void
s390_new_thread (struct lwp_info *lp)
{
- lp->arch_private = XCNEW (struct arch_lwp_info);
- lp->arch_private->per_info_changed = 1;
+ s390_mark_per_info_changed (lp);
+}
+
+/* Iterator callback for s390_refresh_per_info. */
+
+static int
+s390_refresh_per_info_cb (struct lwp_info *lp, void *arg)
+{
+ s390_mark_per_info_changed (lp);
+
+ if (!lwp_is_stopped (lp))
+ linux_stop_lwp (lp);
+ return 0;
+}
+
+/* Make sure that threads are stopped and mark PER info as changed. */
+
+static int
+s390_refresh_per_info (void)
+{
+ ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
+
+ iterate_over_lwps (pid_ptid, s390_refresh_per_info_cb, NULL);
+ return 0;
}
static int
@@ -557,7 +575,6 @@ s390_insert_watchpoint (struct target_ops *self,
CORE_ADDR addr, int len, enum target_hw_bp_type type,
struct expression *cond)
{
- struct lwp_info *lp;
struct watch_area *area = XNEW (struct watch_area);
if (!area)
@@ -569,9 +586,7 @@ s390_insert_watchpoint (struct target_ops *self,
area->next = watch_base;
watch_base = area;
- ALL_LWPS (lp)
- s390_refresh_per_info (lp);
- return 0;
+ return s390_refresh_per_info ();
}
static int
@@ -579,7 +594,6 @@ s390_remove_watchpoint (struct target_ops *self,
CORE_ADDR addr, int len, enum target_hw_bp_type type,
struct expression *cond)
{
- struct lwp_info *lp;
struct watch_area *area, **parea;
for (parea = &watch_base; *parea; parea = &(*parea)->next)
@@ -598,9 +612,7 @@ s390_remove_watchpoint (struct target_ops *self,
*parea = area->next;
xfree (area);
- ALL_LWPS (lp)
- s390_refresh_per_info (lp);
- return 0;
+ return s390_refresh_per_info ();
}
static int
--
2.5.0
next prev parent reply other threads:[~2016-09-15 11:59 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 ` Andreas Arnez [this message]
2016-09-15 12:01 ` [PATCH 3/6] S390: Multi-inferior watchpoint support Andreas Arnez
2016-09-15 12:02 ` [PATCH 4/6] S390: Enable "maint set show-debug-regs" 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 ` [PATCH 6/6] S390: Hardware breakpoint support Andreas Arnez
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 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=1473940769-3870-1-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).