Call target_can_download_tracepoint if there are tracepoints to download
authorYao Qi <yao.qi@linaro.org>
Thu, 10 Sep 2015 11:31:36 +0000 (12:31 +0100)
committerYao Qi <yao.qi@linaro.org>
Thu, 10 Sep 2015 11:31:36 +0000 (12:31 +0100)
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

gdb:

2015-09-10  Yao Qi  <yao.qi@linaro.org>

* 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 ...
* common/common-types.h: ... here.

gdb/ChangeLog
gdb/breakpoint.c
gdb/common/common-types.h
gdb/linux-nat.h

index 85d8bc20ebee373c9978ff73bd1ccd018ea108d1..ba521c078c245e7819cb6e3e384b58bd9193180f 100644 (file)
@@ -1,3 +1,12 @@
+2015-09-10  Yao Qi  <yao.qi@linaro.org>
+
+       * 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 ...
+       * common/common-types.h: ... here.
+
 2015-09-09  Pedro Alves  <palves@redhat.com>
 
        * inf-loop.c (inferior_event_handler): Delete INF_TIMER case.
index 4709de72faf5b50729643083378e8e2da8dcff90..520793a72e1107c9aa4a26bbb108535533a6e4b9 100644 (file)
@@ -12146,9 +12146,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 ();
 
@@ -12163,6 +12161,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
index 55b41abb8fc38a5f9336a7e4a9cd58ebd35fca2c..3f60a9a9a5689aa162783b686770c48181d1e1d0 100644 (file)
@@ -58,4 +58,6 @@ typedef unsigned long long ULONGEST;
 /* * The largest CORE_ADDR value.  */
 #define CORE_ADDR_MAX (~ (CORE_ADDR) 0)
 
+enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
+
 #endif /* COMMON_TYPES_H */
index 81b3ded2b014a262d299664210bfc5247d0c7ed8..f7b45f7bc6935bfae0187b6eb9506d791b757fcb 100644 (file)
@@ -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).  */