public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdbserver: do not report btrace support if target does not announce it
@ 2022-11-09  7:34 Tankut Baris Aktemur
  2022-11-09 15:44 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tankut Baris Aktemur @ 2022-11-09  7:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: markus.t.metzger

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 | 6 ++++++
 gdbserver/linux-low.h  | 2 ++
 gdbserver/server.cc    | 3 ++-
 gdbserver/target.cc    | 6 ++++++
 gdbserver/target.h     | 3 +++
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 1676328fc88..0cbfeb99086 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -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)
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 79be31b8f72..1594f063f47 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -275,6 +275,8 @@ class linux_process_target : public process_stratum_target
   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;
 
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 366a843ea89..aaef38e0062 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -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+");
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index adcfe6e7bcc..c06a67600b1 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -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)
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 6c536a30778..18ab969dda7 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -388,6 +388,9 @@ class process_stratum_target
   /* 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,
-- 
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdbserver: do not report btrace support if target does not announce it
  2022-11-09  7:34 [PATCH] gdbserver: do not report btrace support if target does not announce it Tankut Baris Aktemur
@ 2022-11-09 15:44 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2022-11-09 15:44 UTC (permalink / raw)
  To: Tankut Baris Aktemur via Gdb-patches
  Cc: Tankut Baris Aktemur, markus.t.metzger

>>>>> Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> writes:

> 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.

Looks good to me.  Thank you.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-09 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09  7:34 [PATCH] gdbserver: do not report btrace support if target does not announce it Tankut Baris Aktemur
2022-11-09 15:44 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).