diff options
author | Andreas Arnez <arnez@linux.vnet.ibm.com> | 2016-09-16 19:25:54 +0200 |
---|---|---|
committer | Andreas Arnez <arnez@linux.vnet.ibm.com> | 2016-09-16 19:25:54 +0200 |
commit | 9c2996c98278a95593afaa79db0dc00bb2aff189 (patch) | |
tree | 77ca3b3739cdd931515750cf410add2cdcbcffd7 /gdb/s390-linux-nat.c | |
parent | d41a5c096ec613f7df33d5d5ea4c0e512ac1e87a (diff) | |
download | gdb-9c2996c98278a95593afaa79db0dc00bb2aff189.zip gdb-9c2996c98278a95593afaa79db0dc00bb2aff189.tar.gz gdb-9c2996c98278a95593afaa79db0dc00bb2aff189.tar.bz2 |
S390: Avoid direct access to lwp_info structure
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.
Diffstat (limited to 'gdb/s390-linux-nat.c')
-rw-r--r-- | gdb/s390-linux-nat.c | 60 |
1 files 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 |