public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Check arguments for all probes before using them
@ 2019-09-02 13:20 Alan Hayward
  0 siblings, 0 replies; only message in thread
From: Alan Hayward @ 2019-09-02 13:20 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d90b8f2632cded4792f18d8bb92bacc21d93eb0a

commit d90b8f2632cded4792f18d8bb92bacc21d93eb0a
Author: Alan Hayward <alan.hayward@arm.com>
Date:   Wed Aug 21 15:36:37 2019 +0100

    Check arguments for all probes before using them
    
    There is a long standing bug in the Arm toolchain where invalid
    stap probes get created due to the probes referring to symbols which
    have been resolved away.
    
    More details are here:
    https://bugzilla.redhat.com/show_bug.cgi?id=1196181
    
    When these invalid probes are present, GDB will create the breakpoints
    and then fail to stop. The errors are only spotted the first time
    GDB stops, which is too late.
    
    The solution is to ensure the arguments for all the probes are
    resolved before using them.
    
    This fixes >100 timeouts when running break-interp.exp when using
    bad probes.
    
    gdb/ChangeLog:
    
    	* solib-svr4.c (svr4_find_and_create_probe_breakpoints): Check all
    	probe arguments.

Diff:
---
 gdb/ChangeLog    |  5 +++++
 gdb/solib-svr4.c | 18 ++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d0e4258..08615f4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2019-09-02  Alan Hayward  <alan.hayward@arm.com>
 
+	* solib-svr4.c (svr4_find_and_create_probe_breakpoints): Check all
+	probe arguments.
+
+2019-09-02  Alan Hayward  <alan.hayward@arm.com>
+
 	* break-catch-throw.c (fetch_probe_arguments): Use gdbarch.
 	* dtrace-probe.c (dtrace_probe::get_argument_count): Likewise.
 	* probe.c (probe_safe_evaluate_at_pc) (compute_probe_arg)
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 2a44dd6..ffae26b 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -2071,7 +2071,6 @@ svr4_find_and_create_probe_breakpoints (svr4_info *info,
 					bool with_prefix)
 {
   std::vector<probe *> probes[NUM_PROBES];
-  bool checked_can_use_probe_arguments = false;
 
   for (int i = 0; i < NUM_PROBES; i++)
     {
@@ -2102,12 +2101,23 @@ svr4_find_and_create_probe_breakpoints (svr4_info *info,
 	return false;
 
       /* Ensure probe arguments can be evaluated.  */
-      if (!checked_can_use_probe_arguments)
+      for (probe *p : probes[i])
 	{
-	  probe *p = probes[i][0];
 	  if (!p->can_evaluate_arguments ())
 	    return false;
-	  checked_can_use_probe_arguments = true;
+	  /* This will fail if the probe is invalid.  This has been seen on Arm
+	     due to references to symbols that have been resolved away.  */
+	  try
+	    {
+	      p->get_argument_count (gdbarch);
+	    }
+	  catch (const gdb_exception_error &ex)
+	    {
+	      exception_print (gdb_stderr, ex);
+	      warning (_("Initializing probes-based dynamic linker interface "
+			 "failed.\nReverting to original interface."));
+	      return false;
+	    }
 	}
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-02 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-02 13:20 [binutils-gdb] Check arguments for all probes before using them Alan Hayward

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