From patchwork Tue Sep 8 14:13:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 8599 Received: (qmail 37512 invoked by alias); 8 Sep 2015 14:13:42 -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 37500 invoked by uid 89); 8 Sep 2015 14:13:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 08 Sep 2015 14:13:41 +0000 Received: by padhk3 with SMTP id hk3so40396467pad.3 for ; Tue, 08 Sep 2015 07:13:39 -0700 (PDT) X-Received: by 10.68.163.5 with SMTP id ye5mr58001607pbb.120.1441721617607; Tue, 08 Sep 2015 07:13:37 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (power-aix.osuosl.org. [140.211.15.154]) by smtp.gmail.com with ESMTPSA id rh7sm3636382pdb.11.2015.09.08.07.13.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Sep 2015 07:13:37 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Call target_can_download_tracepoint if there are tracepoints to download Date: Tue, 8 Sep 2015 15:13:32 +0100 Message-Id: <1441721612-15314-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes Nowadays, GDB calls target_can_download_tracepoint at the entry of download_tracepoint_locations, which is called by. update_global_location_list. Sometimes, it is not needed to call target_can_download_tracepoint at all because there is no tracepoint created. In remote target, target_can_download_tracepoint send qTStatus to the remote in order to know whether tracepoint can be downloaded or not. This means some redundant qTStatus packets are sent. This patch is to teach GDB to call target_can_download_tracepoint lazily, only on the moment there are tracepoint to download. gdb.perf/single-step.exp (with a local patch to measure RSP packets) shows the number of RSP packets is reduced because there is no tracepoint at all, so GDB doesn't send qTStatus any more. # of RSP packets original patched single-step rsp 1000 7000 6000 single-step rsp 2000 14000 12000 single-step rsp 3000 21000 18000 single-step rsp 4000 28000 24000 Regression tested on x86_64-linux, both native and gdbserver. gdb: 2015-09-08 Yao Qi * breakpoint.c (download_tracepoint_locations): New local can_download_tracepoint. Check the result of target_can_download_tracepoint and save it in can_download_tracepoint if there are tracepoints to download. * linux-nat.h (enum tribool): Move it to ... * defs.h: ... here. --- gdb/breakpoint.c | 15 ++++++++++++--- gdb/defs.h | 2 ++ gdb/linux-nat.h | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 5067222..a295cdc 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -12078,9 +12078,7 @@ download_tracepoint_locations (void) { struct breakpoint *b; struct cleanup *old_chain; - - if (!target_can_download_tracepoint ()) - return; + enum tribool can_download_tracepoint = TRIBOOL_UNKNOWN; old_chain = save_current_space_and_thread (); @@ -12095,6 +12093,17 @@ download_tracepoint_locations (void) : !may_insert_tracepoints)) continue; + if (can_download_tracepoint == TRIBOOL_UNKNOWN) + { + if (target_can_download_tracepoint ()) + can_download_tracepoint = TRIBOOL_TRUE; + else + can_download_tracepoint = TRIBOOL_FALSE; + } + + if (can_download_tracepoint == TRIBOOL_FALSE) + break; + for (bl = b->loc; bl; bl = bl->next) { /* In tracepoint, locations are _never_ duplicated, so diff --git a/gdb/defs.h b/gdb/defs.h index 03f7e8a..b81d913 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -234,6 +234,8 @@ enum return_value_convention RETURN_VALUE_ABI_PRESERVES_ADDRESS, }; +enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 }; + /* Needed for various prototypes */ struct symtab; diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 81b3ded..f7b45f7 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -116,7 +116,6 @@ struct lwp_info extern struct lwp_info *lwp_list; /* Does the current host support PTRACE_GETREGSET? */ -enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 }; extern enum tribool have_ptrace_getregset; /* Iterate over each active thread (light-weight process). */