From patchwork Thu Oct 22 19:58:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tremblay X-Patchwork-Id: 9335 Received: (qmail 119525 invoked by alias); 22 Oct 2015 19:58:57 -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 119467 invoked by uid 89); 22 Oct 2015 19:58:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 22 Oct 2015 19:58:55 +0000 Received: from EUSAAHC005.ericsson.se (Unknown_Domain [147.117.188.87]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 27.5C.26730.133D8265; Thu, 22 Oct 2015 14:14:41 +0200 (CEST) Received: from elxa4wqvvz1.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.87) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Oct 2015 15:58:44 -0400 From: Antoine Tremblay To: CC: Antoine Tremblay Subject: [PATCH 1/3] Refactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer. Date: Thu, 22 Oct 2015 15:58:35 -0400 Message-ID: <1445543917-16839-2-git-send-email-antoine.tremblay@ericsson.com> In-Reply-To: <1445543917-16839-1-git-send-email-antoine.tremblay@ericsson.com> References: <1445543917-16839-1-git-send-email-antoine.tremblay@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch moves default_breakpoint_kind_from_pc to target.c and creates a macro so that all targets can easily use it. This allows the breakpoint_kind_from_pc operation to be left unimplemented in targets that do not need it. This is preparation to fix the win32/nto/spu build that was broken by this patch: https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended} gdb/gdbserver/ChangeLog: * linux-low.c (default_breakpoint_kind_from_pc): Move to target.c. * mem-break.c (set_breakpoint_at): Use target_breakpoint_kind_from_pc. * target.c (default_breakpoint_kind_from_pc): Moved from linux-low.c * target.h (target_breakpoint_kind_from_pc): New macro. --- gdb/gdbserver/linux-low.c | 13 ------------- gdb/gdbserver/mem-break.c | 2 +- gdb/gdbserver/target.c | 16 ++++++++++++++++ gdb/gdbserver/target.h | 7 +++++++ 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index ac8fae3..0c552b8 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -6937,19 +6937,6 @@ current_lwp_ptid (void) return ptid_of (current_thread); } -/* Return the default breakpoint kind as the size of the breakpoint. */ - -static int -default_breakpoint_kind_from_pc (CORE_ADDR *pcptr) -{ - int size = 0; - - gdb_assert (the_low_target.sw_breakpoint_from_kind != NULL); - - (*the_low_target.sw_breakpoint_from_kind) (0, &size); - return size; -} - /* Implementation of the target_ops method "breakpoint_kind_from_pc". */ static int diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c index a676ea2..656402a 100644 --- a/gdb/gdbserver/mem-break.c +++ b/gdb/gdbserver/mem-break.c @@ -784,7 +784,7 @@ set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR)) { int err_ignored; CORE_ADDR placed_address = where; - int breakpoint_kind = the_target->breakpoint_kind_from_pc (&placed_address); + int breakpoint_kind = target_breakpoint_kind_from_pc (&placed_address); return set_breakpoint (other_breakpoint, raw_bkpt_type_sw, placed_address, breakpoint_kind, handler, diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c index 301f90e..80512d86 100644 --- a/gdb/gdbserver/target.c +++ b/gdb/gdbserver/target.c @@ -224,3 +224,19 @@ target_can_do_hardware_single_step (void) { return 1; } + +/* Default implementation for breakpoint_kind_for_pc. + + The default behavior for targets that don't implement breakpoint_kind_for_pc + is to use the size of a breakpoint as the kind. */ + +int +default_breakpoint_kind_from_pc (CORE_ADDR *pcptr) +{ + int size = 0; + + gdb_assert (the_target->sw_breakpoint_from_kind != NULL); + + (*the_target->sw_breakpoint_from_kind) (0, &size); + return size; +} diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index e4c0639..a14c6ff 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -633,6 +633,11 @@ int kill_inferior (int); (the_target->stopped_by_hw_breakpoint ? \ (*the_target->stopped_by_hw_breakpoint) () : 0) +#define target_breakpoint_kind_from_pc(pcptr) \ + (the_target->breakpoint_kind_from_pc \ + ? (*the_target->breakpoint_kind_from_pc) (pcptr) \ + : default_breakpoint_kind_from_pc (pcptr)) + /* Start non-stop mode, returns 0 on success, -1 on failure. */ int start_non_stop (int nonstop); @@ -667,4 +672,6 @@ const char *target_pid_to_str (ptid_t); int target_can_do_hardware_single_step (void); +int default_breakpoint_kind_from_pc (CORE_ADDR *pcptr); + #endif /* TARGET_H */