From patchwork Wed Jul 1 13:58:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 7453 Received: (qmail 90685 invoked by alias); 1 Jul 2015 13:59:00 -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 90603 invoked by uid 89); 1 Jul 2015 13:59:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f175.google.com Received: from mail-pd0-f175.google.com (HELO mail-pd0-f175.google.com) (209.85.192.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 01 Jul 2015 13:58:52 +0000 Received: by pdjd13 with SMTP id d13so26444114pdj.0 for ; Wed, 01 Jul 2015 06:58:50 -0700 (PDT) X-Received: by 10.66.65.229 with SMTP id a5mr56257282pat.11.1435759130548; Wed, 01 Jul 2015 06:58:50 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id sc7sm2417503pbb.85.2015.07.01.06.58.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jul 2015 06:58:49 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 09/11] [gdbserver] Rename supports_conditional_breakpoints to supports_hardware_single_step Date: Wed, 1 Jul 2015 14:58:29 +0100 Message-Id: <1435759111-22856-10-git-send-email-yao.qi@linaro.org> In-Reply-To: <1435759111-22856-1-git-send-email-yao.qi@linaro.org> References: <1435759111-22856-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes In my patch https://sourceware.org/ml/gdb-patches/2015-04/msg01110.html a new target_ops hook supports_conditional_breakpoints was added to disable conditional breakpoints if target doesn't have hardware single step. This patch is to generalize this hook from supports_conditional_breakpoints to supports_hardware_single_step, so that the following patch can use it. gdb/gdbserver: 2015-06-30 Yao Qi * linux-low.c (linux_supports_conditional_breakpoints): Rename it to ... (linux_supports_hardware_single_step): ... New function. (linux_target_ops): Update. * lynx-low.c (lynx_target_ops): Set field supports_hardware_single_step to target_can_do_hardware_single_step. * nto-low.c (nto_target_ops): Likewise. * spu-low.c (spu_target_ops): Likewise. * win32-low.c (win32_target_ops): Likewise. * target.c (target_can_do_hardware_single_step): New function. * target.h (struct target_ops) : Remove. : New field. (target_supports_conditional_breakpoints): Remove. (target_supports_hardware_single_step): New macro. (target_can_do_hardware_single_step): Declare. * server.c (handle_query): Use target_supports_hardware_single_step instead of target_supports_conditional_breakpoints. --- gdb/gdbserver/linux-low.c | 11 +++-------- gdb/gdbserver/lynx-low.c | 5 +---- gdb/gdbserver/nto-low.c | 5 +---- gdb/gdbserver/server.c | 10 ++++++++-- gdb/gdbserver/spu-low.c | 2 +- gdb/gdbserver/target.c | 8 ++++++++ gdb/gdbserver/target.h | 13 +++++++------ gdb/gdbserver/win32-low.c | 5 +---- 8 files changed, 30 insertions(+), 29 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 3774d17..6467ca8 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -5313,16 +5313,11 @@ linux_supports_stopped_by_hw_breakpoint (void) return USE_SIGTRAP_SIGINFO; } -/* Implement the supports_conditional_breakpoints target_ops - method. */ +/* Implement the supports_hardware_single_step target_ops method. */ static int -linux_supports_conditional_breakpoints (void) +linux_supports_hardware_single_step (void) { - /* GDBserver needs to step over the breakpoint if the condition is - false. GDBserver software single step is too simple, so disable - conditional breakpoints if the target doesn't have hardware single - step. */ return can_hardware_single_step (); } @@ -6582,7 +6577,7 @@ static struct target_ops linux_target_ops = { linux_supports_stopped_by_sw_breakpoint, linux_stopped_by_hw_breakpoint, linux_supports_stopped_by_hw_breakpoint, - linux_supports_conditional_breakpoints, + linux_supports_hardware_single_step, linux_stopped_by_watchpoint, linux_stopped_data_address, #if defined(__UCLIBC__) && defined(HAS_NOMMU) \ diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c index ee7b28a..f636377 100644 --- a/gdb/gdbserver/lynx-low.c +++ b/gdb/gdbserver/lynx-low.c @@ -746,10 +746,7 @@ static struct target_ops lynx_target_ops = { NULL, /* supports_stopped_by_sw_breakpoint */ NULL, /* stopped_by_hw_breakpoint */ NULL, /* supports_stopped_by_hw_breakpoint */ - /* Although lynx has hardware single step, still disable this - feature for lynx, because it is implemented in linux-low.c instead - of in generic code. */ - NULL, /* supports_conditional_breakpoints */ + target_can_do_hardware_single_step, NULL, /* stopped_by_watchpoint */ NULL, /* stopped_data_address */ NULL, /* read_offsets */ diff --git a/gdb/gdbserver/nto-low.c b/gdb/gdbserver/nto-low.c index 9276736..6c50e95 100644 --- a/gdb/gdbserver/nto-low.c +++ b/gdb/gdbserver/nto-low.c @@ -949,10 +949,7 @@ static struct target_ops nto_target_ops = { NULL, /* supports_stopped_by_sw_breakpoint */ NULL, /* stopped_by_hw_breakpoint */ NULL, /* supports_stopped_by_hw_breakpoint */ - /* Although nto has hardware single step, still disable this - feature for not, because it is implemented in linux-low.c instead - of in generic code. */ - NULL, /* supports_conditional_breakpoints */ + target_can_do_hardware_single_step, nto_stopped_by_watchpoint, nto_stopped_data_address, NULL, /* nto_read_offsets */ diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index c9effc2..858fbe5 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -2142,8 +2142,14 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) } /* Support target-side breakpoint conditions and commands. */ - if (target_supports_conditional_breakpoints ()) - strcat (own_buf, ";ConditionalBreakpoints+"); + if (target_supports_hardware_single_step ()) + { + /* GDBserver needs to step over the breakpoint if the condition + is false. GDBserver software single step is too simple, so + disable conditional breakpoints if the target doesn't have + hardware single step. */ + strcat (own_buf, ";ConditionalBreakpoints+"); + } strcat (own_buf, ";BreakpointCommands+"); if (target_supports_agent ()) diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c index a56a889..b5501c4 100644 --- a/gdb/gdbserver/spu-low.c +++ b/gdb/gdbserver/spu-low.c @@ -662,7 +662,7 @@ static struct target_ops spu_target_ops = { NULL, /* supports_stopped_by_sw_breakpoint */ NULL, /* stopped_by_hw_breakpoint */ NULL, /* supports_stopped_by_hw_breakpoint */ - NULL, /* supports_conditional_breakpoints */ + NULL, /* supports_hardware_single_step */ NULL, NULL, NULL, diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c index 14999e6..dd04642 100644 --- a/gdb/gdbserver/target.c +++ b/gdb/gdbserver/target.c @@ -218,3 +218,11 @@ kill_inferior (int pid) return (*the_target->kill) (pid); } + +/* Target can do hardware single step. */ + +int +target_can_do_hardware_single_step (void) +{ + return 1; +} diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index 9a40867..c16f55b 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -222,9 +222,8 @@ struct target_ops HW breakpoint triggering. */ int (*supports_stopped_by_hw_breakpoint) (void); - /* Returns true if the target can evaluate conditions of - breakpoints. */ - int (*supports_conditional_breakpoints) (void); + /* Returns true if the target can do hardware single step. */ + int (*supports_hardware_single_step) (void); /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */ @@ -599,9 +598,9 @@ int kill_inferior (int); (the_target->supports_stopped_by_hw_breakpoint ? \ (*the_target->supports_stopped_by_hw_breakpoint) () : 0) -#define target_supports_conditional_breakpoints() \ - (the_target->supports_conditional_breakpoints ? \ - (*the_target->supports_conditional_breakpoints) () : 0) +#define target_supports_hardware_single_step() \ + (the_target->supports_hardware_single_step ? \ + (*the_target->supports_hardware_single_step) () : 0) #define target_stopped_by_hw_breakpoint() \ (the_target->stopped_by_hw_breakpoint ? \ @@ -639,4 +638,6 @@ void set_desired_thread (int id); const char *target_pid_to_str (ptid_t); +int target_can_do_hardware_single_step (void); + #endif /* TARGET_H */ diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index 64caf24..ff3feff 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -1809,10 +1809,7 @@ static struct target_ops win32_target_ops = { NULL, /* supports_stopped_by_sw_breakpoint */ NULL, /* stopped_by_hw_breakpoint */ NULL, /* supports_stopped_by_hw_breakpoint */ - /* Although win32-i386 has hardware single step, still disable this - feature for win32, because it is implemented in linux-low.c instead - of in generic code. */ - NULL, /* supports_conditional_breakpoints */ + target_can_do_hardware_single_step, win32_stopped_by_watchpoint, win32_stopped_data_address, NULL, /* read_offsets */