gdbserver: do not report btrace support if target does not announce it
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Wed, 9 Nov 2022 16:46:21 +0000 (17:46 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Wed, 9 Nov 2022 16:46:21 +0000 (17:46 +0100)
Gdbserver unconditionally reports support for btrace packets.  Do not
report the support, if the underlying target does not say it supports
it.  Otherwise GDB would query the server with btrace-related packets
unnecessarily.

gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/server.cc
gdbserver/target.cc
gdbserver/target.h

index 1676328fc8875fb4a2cd44aaa3355cfec8a72813..0cbfeb99086a4d7835c974504d79507889d47456 100644 (file)
@@ -6712,6 +6712,12 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
 
 #ifdef HAVE_LINUX_BTRACE
 
+bool
+linux_process_target::supports_btrace ()
+{
+  return true;
+}
+
 btrace_target_info *
 linux_process_target::enable_btrace (thread_info *tp,
                                     const btrace_config *conf)
index 79be31b8f7295daf7e26aefc2d7b6f4cb2ef5c52..1594f063f47c42f2c1307497d473a0fa9261c9a4 100644 (file)
@@ -275,6 +275,8 @@ public:
   bool supports_agent () override;
 
 #ifdef HAVE_LINUX_BTRACE
+  bool supports_btrace () override;
+
   btrace_target_info *enable_btrace (thread_info *tp,
                                     const btrace_config *conf) override;
 
index 366a843ea894d784f87c86072e20eddec6c811c2..aaef38e00622d9b831385c31118e9927aa7140f0 100644 (file)
@@ -2475,7 +2475,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (target_supports_agent ())
        strcat (own_buf, ";QAgent+");
 
-      supported_btrace_packets (own_buf);
+      if (the_target->supports_btrace ())
+       supported_btrace_packets (own_buf);
 
       if (target_supports_stopped_by_sw_breakpoint ())
        strcat (own_buf, ";swbreak+");
index adcfe6e7bcc7b6a9f961fccb8bf4021dc9e49633..c06a67600b1ff1cd7cd43d9d7bd823c08ac8e28f 100644 (file)
@@ -694,6 +694,12 @@ process_stratum_target::supports_agent ()
   return false;
 }
 
+bool
+process_stratum_target::supports_btrace ()
+{
+  return false;
+}
+
 btrace_target_info *
 process_stratum_target::enable_btrace (thread_info *tp,
                                       const btrace_config *conf)
index 6c536a307786d7cab783a72bd574f49cebb416f0..18ab969dda70b2a695dea72121b19fa04ae4b8b9 100644 (file)
@@ -388,6 +388,9 @@ public:
   /* Return true if target supports debugging agent.  */
   virtual bool supports_agent ();
 
+  /* Return true if target supports btrace.  */
+  virtual bool supports_btrace ();
+
   /* Enable branch tracing for TP based on CONF and allocate a branch trace
      target information struct for reading and for disabling branch trace.  */
   virtual btrace_target_info *enable_btrace (thread_info *tp,