From patchwork Thu Feb 26 00:17:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5291 Received: (qmail 44843 invoked by alias); 26 Feb 2015 00:17:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 44727 invoked by uid 89); 26 Feb 2015 00:17:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 Feb 2015 00:17:36 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1Q0HZO1001970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 25 Feb 2015 19:17:35 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1Q0HXwD000814 for ; Wed, 25 Feb 2015 19:17:34 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/8] enum lwp_stop_reason -> enum target_stop_reason Date: Thu, 26 Feb 2015 00:17:25 +0000 Message-Id: <1424909852-25917-2-git-send-email-palves@redhat.com> In-Reply-To: <1424909852-25917-1-git-send-email-palves@redhat.com> References: <1424909852-25917-1-git-send-email-palves@redhat.com> We're going to need the same enum as enum lwp_stop_reason in more targets, so this promotes it to common code. gdb/gdbserver/ChangeLog: 2015-02-24 Pedro Alves enum lwp_stop_reason -> enum target_stop_reason * linux-low.c (check_stopped_by_breakpoint): Adjust. (thread_still_has_status_pending_p, check_stopped_by_watchpoint) (linux_wait_1, stuck_in_jump_pad_callback) (move_out_of_jump_pad_callback, linux_resume_one_lwp) (linux_stopped_by_watchpoint): * linux-low.h (enum lwp_stop_reason): Delete. (struct lwp_info) : Now an enum target_stop_reason. * linux-x86-low.c (x86_linux_prepare_to_resume): Adjust. gdb/ChangeLog: 2015-02-24 Pedro Alves enum lwp_stop_reason -> enum target_stop_reason * linux-nat.c (linux_resume_one_lwp, check_stopped_by_watchpoint) (linux_nat_stopped_by_watchpoint, status_callback) (linux_nat_wait_1): Adjust. * linux-nat.h (enum lwp_stop_reason): Delete. (struct lwp_info) : Now an enum target_stop_reason. * x86-linux-nat.c (x86_linux_prepare_to_resume): Adjust. * target/waitstatus.h (enum target_stop_reason): New. --- gdb/gdbserver/linux-low.c | 34 +++++++++++++++++----------------- gdb/gdbserver/linux-low.h | 21 ++------------------- gdb/gdbserver/linux-x86-low.c | 2 +- gdb/linux-nat.c | 20 ++++++++++---------- gdb/linux-nat.h | 20 +------------------- gdb/target/waitstatus.h | 19 +++++++++++++++++++ gdb/x86-linux-nat.c | 2 +- 7 files changed, 51 insertions(+), 67 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 1c66985..e24739f 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -528,7 +528,7 @@ check_stopped_by_breakpoint (struct lwp_info *lwp) } lwp->stop_pc = sw_breakpoint_pc; - lwp->stop_reason = LWP_STOPPED_BY_SW_BREAKPOINT; + lwp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT; current_thread = saved_thread; return 1; } @@ -544,7 +544,7 @@ check_stopped_by_breakpoint (struct lwp_info *lwp) } lwp->stop_pc = pc; - lwp->stop_reason = LWP_STOPPED_BY_HW_BREAKPOINT; + lwp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT; current_thread = saved_thread; return 1; } @@ -1221,8 +1221,8 @@ thread_still_has_status_pending_p (struct thread_info *thread) return 0; if (thread->last_resume_kind != resume_stop - && (lp->stop_reason == LWP_STOPPED_BY_SW_BREAKPOINT - || lp->stop_reason == LWP_STOPPED_BY_HW_BREAKPOINT)) + && (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT + || lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT)) { struct thread_info *saved_thread; CORE_ADDR pc; @@ -1242,7 +1242,7 @@ thread_still_has_status_pending_p (struct thread_info *thread) lwpid_of (thread)); discard = 1; } - else if (lp->stop_reason == LWP_STOPPED_BY_SW_BREAKPOINT + else if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT && !(*the_low_target.breakpoint_at) (pc)) { if (debug_threads) @@ -1250,7 +1250,7 @@ thread_still_has_status_pending_p (struct thread_info *thread) lwpid_of (thread)); discard = 1; } - else if (lp->stop_reason == LWP_STOPPED_BY_HW_BREAKPOINT + else if (lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT && !hardware_breakpoint_inserted_here (pc)) { if (debug_threads) @@ -1758,7 +1758,7 @@ check_stopped_by_watchpoint (struct lwp_info *child) if (the_low_target.stopped_by_watchpoint ()) { - child->stop_reason = LWP_STOPPED_BY_WATCHPOINT; + child->stop_reason = TARGET_STOPPED_BY_WATCHPOINT; if (the_low_target.stopped_data_address != NULL) child->stopped_data_address @@ -1770,7 +1770,7 @@ check_stopped_by_watchpoint (struct lwp_info *child) current_thread = saved_thread; } - return child->stop_reason == LWP_STOPPED_BY_WATCHPOINT; + return child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT; } /* Do low-level handling of the event, and check if we should go on @@ -2553,7 +2553,7 @@ linux_wait_1 (ptid_t ptid, Advance the PC manually past the breakpoint, otherwise the program would keep trapping the permanent breakpoint forever. */ if (!ptid_equal (step_over_bkpt, null_ptid) - && event_child->stop_reason == LWP_STOPPED_BY_SW_BREAKPOINT) + && event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT) { unsigned int increment_pc; @@ -2577,7 +2577,7 @@ linux_wait_1 (ptid_t ptid, (*the_low_target.set_pc) (regcache, event_child->stop_pc); if (!(*the_low_target.breakpoint_at) (event_child->stop_pc)) - event_child->stop_reason = LWP_STOPPED_BY_NO_REASON; + event_child->stop_reason = TARGET_STOPPED_BY_NO_REASON; } } @@ -2804,7 +2804,7 @@ linux_wait_1 (ptid_t ptid, report_to_gdb = (!maybe_internal_trap || (current_thread->last_resume_kind == resume_step && !in_step_range) - || event_child->stop_reason == LWP_STOPPED_BY_WATCHPOINT + || event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT || (!step_over_finished && !in_step_range && !bp_explains_trap && !trace_event) || (gdb_breakpoint_here (event_child->stop_pc) @@ -2868,7 +2868,7 @@ linux_wait_1 (ptid_t ptid, else if (!lwp_in_step_range (event_child)) debug_printf ("Out of step range, reporting event.\n"); } - if (event_child->stop_reason == LWP_STOPPED_BY_WATCHPOINT) + if (event_child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT) debug_printf ("Stopped by watchpoint.\n"); else if (gdb_breakpoint_here (event_child->stop_pc)) debug_printf ("Stopped by GDB breakpoint.\n"); @@ -2944,7 +2944,7 @@ linux_wait_1 (ptid_t ptid, /* Now that we've selected our final event LWP, un-adjust its PC if it was a software breakpoint. */ - if (event_child->stop_reason == LWP_STOPPED_BY_SW_BREAKPOINT) + if (event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT) { int decr_pc = the_low_target.decr_pc_after_break; @@ -3221,7 +3221,7 @@ stuck_in_jump_pad_callback (struct inferior_list_entry *entry, void *data) return (supports_fast_tracepoints () && agent_loaded_p () && (gdb_breakpoint_here (lwp->stop_pc) - || lwp->stop_reason == LWP_STOPPED_BY_WATCHPOINT + || lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT || thread->last_resume_kind == resume_step) && linux_fast_tracepoint_collecting (lwp, NULL)); } @@ -3240,7 +3240,7 @@ move_out_of_jump_pad_callback (struct inferior_list_entry *entry) /* Allow debugging the jump pad, gdb_collect, etc. */ if (!gdb_breakpoint_here (lwp->stop_pc) - && lwp->stop_reason != LWP_STOPPED_BY_WATCHPOINT + && lwp->stop_reason != TARGET_STOPPED_BY_WATCHPOINT && thread->last_resume_kind != resume_step && maybe_move_out_of_jump_pad (lwp, wstat)) { @@ -3505,7 +3505,7 @@ linux_resume_one_lwp (struct lwp_info *lwp, regcache_invalidate_thread (thread); errno = 0; lwp->stopped = 0; - lwp->stop_reason = LWP_STOPPED_BY_NO_REASON; + lwp->stop_reason = TARGET_STOPPED_BY_NO_REASON; lwp->stepping = step; ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0, @@ -4911,7 +4911,7 @@ linux_stopped_by_watchpoint (void) { struct lwp_info *lwp = get_thread_lwp (current_thread); - return lwp->stop_reason == LWP_STOPPED_BY_WATCHPOINT; + return lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT; } static CORE_ADDR diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index bea4a37..bbff3aa 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -24,6 +24,7 @@ /* Included for ptrace type definitions. */ #include "nat/linux-ptrace.h" +#include "target/waitstatus.h" /* For enum target_stop_reason. */ #define PTRACE_XFER_TYPE long @@ -230,24 +231,6 @@ extern struct linux_target_ops the_low_target; #define get_thread_lwp(thr) ((struct lwp_info *) (inferior_target_data (thr))) #define get_lwp_thread(lwp) ((lwp)->thread) -/* Reasons an LWP last stopped. */ - -enum lwp_stop_reason -{ - /* Either not stopped, or stopped for a reason that doesn't require - special tracking. */ - LWP_STOPPED_BY_NO_REASON, - - /* Stopped by a software breakpoint. */ - LWP_STOPPED_BY_SW_BREAKPOINT, - - /* Stopped by a hardware breakpoint. */ - LWP_STOPPED_BY_HW_BREAKPOINT, - - /* Stopped by a watchpoint. */ - LWP_STOPPED_BY_WATCHPOINT -}; - /* This struct is recorded in the target_data field of struct thread_info. On linux ``all_threads'' is keyed by the LWP ID, which we use as the @@ -299,7 +282,7 @@ struct lwp_info /* The reason the LWP last stopped, if we need to track it (breakpoint, watchpoint, etc.) */ - enum lwp_stop_reason stop_reason; + enum target_stop_reason stop_reason; /* On architectures where it is possible to know the data address of a triggered watchpoint, STOPPED_DATA_ADDRESS is non-zero, and diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index e58a7ac..a347e45 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -808,7 +808,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) lwp->arch_private->debug_registers_changed = 0; } - if (clear_status || lwp->stop_reason == LWP_STOPPED_BY_WATCHPOINT) + if (clear_status || lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT) x86_linux_dr_set (ptid, DR_STATUS, 0); } diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 2e1133d..aebae79 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1527,7 +1527,7 @@ linux_resume_one_lwp (struct lwp_info *lp, int step, enum gdb_signal signo) /* Convert to something the lower layer understands. */ ptid = pid_to_ptid (ptid_get_lwp (lp->ptid)); linux_ops->to_resume (linux_ops, ptid, step, signo); - lp->stop_reason = LWP_STOPPED_BY_NO_REASON; + lp->stop_reason = TARGET_STOPPED_BY_NO_REASON; lp->stopped = 0; registers_changed_ptid (lp->ptid); } @@ -2380,7 +2380,7 @@ check_stopped_by_watchpoint (struct lwp_info *lp) if (linux_ops->to_stopped_by_watchpoint (linux_ops)) { - lp->stop_reason = LWP_STOPPED_BY_WATCHPOINT; + lp->stop_reason = TARGET_STOPPED_BY_WATCHPOINT; if (linux_ops->to_stopped_data_address != NULL) lp->stopped_data_address_p = @@ -2392,7 +2392,7 @@ check_stopped_by_watchpoint (struct lwp_info *lp) do_cleanups (old_chain); - return lp->stop_reason == LWP_STOPPED_BY_WATCHPOINT; + return lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT; } /* Called when the LWP stopped for a trap that could be explained by a @@ -2401,7 +2401,7 @@ check_stopped_by_watchpoint (struct lwp_info *lp) static void save_sigtrap (struct lwp_info *lp) { - gdb_assert (lp->stop_reason == LWP_STOPPED_BY_NO_REASON); + gdb_assert (lp->stop_reason == TARGET_STOPPED_BY_NO_REASON); gdb_assert (lp->status != 0); if (check_stopped_by_watchpoint (lp)) @@ -2420,7 +2420,7 @@ linux_nat_stopped_by_watchpoint (struct target_ops *ops) gdb_assert (lp != NULL); - return lp->stop_reason == LWP_STOPPED_BY_WATCHPOINT; + return lp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT; } static int @@ -2540,8 +2540,8 @@ status_callback (struct lwp_info *lp, void *data) if (!lp->resumed) return 0; - if (lp->stop_reason == LWP_STOPPED_BY_SW_BREAKPOINT - || lp->stop_reason == LWP_STOPPED_BY_HW_BREAKPOINT) + if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT + || lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT) { struct regcache *regcache = get_thread_regcache (lp->ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); @@ -2694,7 +2694,7 @@ check_stopped_by_breakpoint (struct lwp_info *lp) regcache_write_pc (regcache, sw_bp_pc); lp->stop_pc = sw_bp_pc; - lp->stop_reason = LWP_STOPPED_BY_SW_BREAKPOINT; + lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT; return 1; } @@ -2706,7 +2706,7 @@ check_stopped_by_breakpoint (struct lwp_info *lp) target_pid_to_str (lp->ptid)); lp->stop_pc = pc; - lp->stop_reason = LWP_STOPPED_BY_HW_BREAKPOINT; + lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT; return 1; } @@ -3366,7 +3366,7 @@ linux_nat_wait_1 (struct target_ops *ops, /* Now that we've selected our final event LWP, un-adjust its PC if it was a software breakpoint. */ - if (lp->stop_reason == LWP_STOPPED_BY_SW_BREAKPOINT) + if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT) { struct regcache *regcache = get_thread_regcache (lp->ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 8c2ceb5..87bc75b 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -23,24 +23,6 @@ struct arch_lwp_info; -/* Reasons an LWP last stopped. */ - -enum lwp_stop_reason -{ - /* Either not stopped, or stopped for a reason that doesn't require - special tracking. */ - LWP_STOPPED_BY_NO_REASON, - - /* Stopped by a software breakpoint. */ - LWP_STOPPED_BY_SW_BREAKPOINT, - - /* Stopped by a hardware breakpoint. */ - LWP_STOPPED_BY_HW_BREAKPOINT, - - /* Stopped by a watchpoint. */ - LWP_STOPPED_BY_WATCHPOINT -}; - /* Structure describing an LWP. This is public only for the purposes of ALL_LWPS; target-specific code should generally not access it directly. */ @@ -93,7 +75,7 @@ struct lwp_info /* The reason the LWP last stopped, if we need to track it (breakpoint, watchpoint, etc.) */ - enum lwp_stop_reason stop_reason; + enum target_stop_reason stop_reason; /* On architectures where it is possible to know the data address of a triggered watchpoint, STOPPED_DATA_ADDRESS_P is non-zero, and diff --git a/gdb/target/waitstatus.h b/gdb/target/waitstatus.h index 8cb30f4..d4ef3b8 100644 --- a/gdb/target/waitstatus.h +++ b/gdb/target/waitstatus.h @@ -115,6 +115,25 @@ struct target_waitstatus } value; }; +/* Extended reasons that can explain why a target/thread stopped for a + trap signal. */ + +enum target_stop_reason +{ + /* Either not stopped, or stopped for a reason that doesn't require + special tracking. */ + TARGET_STOPPED_BY_NO_REASON, + + /* Stopped by a software breakpoint. */ + TARGET_STOPPED_BY_SW_BREAKPOINT, + + /* Stopped by a hardware breakpoint. */ + TARGET_STOPPED_BY_HW_BREAKPOINT, + + /* Stopped by a watchpoint. */ + TARGET_STOPPED_BY_WATCHPOINT +}; + /* Prototypes */ /* Return a pretty printed form of target_waitstatus. diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index 9d82be2..a09e32b 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -214,7 +214,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) lwp->arch_private->debug_registers_changed = 0; } - if (clear_status || lwp->stop_reason == LWP_STOPPED_BY_WATCHPOINT) + if (clear_status || lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT) x86_linux_dr_set (lwp->ptid, DR_STATUS, 0); }