public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC] fix probe-related internal error on AIX
@ 2014-03-06 18:06 Tom Tromey
  2014-03-11 17:44 ` Sergio Durigan Junior
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2014-03-06 18:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

While testing on AIX, I happened to notice an internal error coming
from parse_probes.  This happens because there are no probes defined
on this platform.  This patch fixes the problem by changing an assert
into an ordinary error, and then changing the relevant caller to cope.

This fixes a few tests on AIX; also regtested on x86-64 Fedora 18.

2014-03-06  Tom Tromey  <tromey@redhat.com>

	* probe.c (parse_probes): Turn assert into an ordinary error.
	* break-catch-throw.c (re_set_exception_catchpoint): Ignore
	exceptions when parsing probes.
---
 gdb/ChangeLog           | 6 ++++++
 gdb/break-catch-throw.c | 5 +++--
 gdb/probe.c             | 3 ++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 7283490..adfe777 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -227,8 +227,9 @@ re_set_exception_catchpoint (struct breakpoint *self)
 	    }
 	}
       /* NOT_FOUND_ERROR just means the breakpoint will be pending, so
-	 let it through.  */
-      if (e.reason < 0 && e.error != NOT_FOUND_ERROR)
+	 let it through.  We also keep going if probe-parsing failed,
+	 as this means that probes aren't supported here.  */
+      if (e.reason < 0 && e.error != NOT_FOUND_ERROR && pass != 0)
 	throw_exception (e);
     }
 
diff --git a/gdb/probe.c b/gdb/probe.c
index 623f65c..838d9f9 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -59,7 +59,8 @@ parse_probes (char **argptr, struct linespec_result *canonical)
 
   cs = *argptr;
   probe_ops = probe_linespec_to_ops (&cs);
-  gdb_assert (probe_ops != NULL);
+  if (probe_ops == NULL)
+    error (_("'%s' is not a probe linespec"), arg_start);
 
   arg = (char *) cs;
   arg = skip_spaces (arg);
-- 
1.8.1.4

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

* Re: [RFC] fix probe-related internal error on AIX
  2014-03-06 18:06 [RFC] fix probe-related internal error on AIX Tom Tromey
@ 2014-03-11 17:44 ` Sergio Durigan Junior
  2014-03-20 17:21   ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Sergio Durigan Junior @ 2014-03-11 17:44 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thursday, March 06 2014, Tom Tromey wrote:

> While testing on AIX, I happened to notice an internal error coming
> from parse_probes.  This happens because there are no probes defined
> on this platform.  This patch fixes the problem by changing an assert
> into an ordinary error, and then changing the relevant caller to cope.
>
> This fixes a few tests on AIX; also regtested on x86-64 Fedora 18.

Ouch, thanks for testing on other platforms!

By reading the patch (and the original code), I found it a little bit
obscure, so I took the liberty to try to improve it.  Here's the patch.
Could you please take a look and see if it works on AIX (and also if you
like the approach)?

Thanks,

2014-03-06  Tom Tromey  <tromey@redhat.com>
	    Sergio Durigan Junior  <sergiodj@redhat.com>

	* probe.c (parse_probes): Turn assert into an ordinary error.
	* break-catch-throw.c (re_set_exception_catchpoint): Ignore
	exceptions when parsing probes.  Rearrange the code for clarity.

diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 7283490..9831d96 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -207,29 +207,32 @@ re_set_exception_catchpoint (struct breakpoint *self)
   volatile struct gdb_exception e;
   struct cleanup *cleanup;
   enum exception_event_kind kind = classify_exception_breakpoint (self);
-  int pass;
 
-  for (pass = 0; sals.sals == NULL && pass < 2; ++pass)
+  /* We first try to use the probe interface.  */
+  TRY_CATCH (e, RETURN_MASK_ERROR)
     {
-      TRY_CATCH (e, RETURN_MASK_ERROR)
+      char *spec = ASTRDUP (exception_functions[kind].probe);
+
+      sals = parse_probes (&spec, NULL);
+    }
+
+  if (e.reason < 0)
+    {
+      volatile struct gdb_exception ex;
+
+      /* Using the probe interface failed.  Let's fallback to the normal
+	 catchpoint mode.  */
+      TRY_CATCH (ex, RETURN_MASK_ERROR)
 	{
-	  char *spec;
-
-	  if (pass == 0)
-	    {
-	      spec = ASTRDUP (exception_functions[kind].probe);
-	      sals = parse_probes (&spec, NULL);
-	    }
-	  else
-	    {
-	      spec = ASTRDUP (exception_functions[kind].function);
-	      self->ops->decode_linespec (self, &spec, &sals);
-	    }
+	  char *spec = ASTRDUP (exception_functions[kind].function);
+
+	  self->ops->decode_linespec (self, &spec, &sals);
 	}
+
       /* NOT_FOUND_ERROR just means the breakpoint will be pending, so
 	 let it through.  */
-      if (e.reason < 0 && e.error != NOT_FOUND_ERROR)
-	throw_exception (e);
+      if (ex.reason < 0 && ex.error != NOT_FOUND_ERROR)
+	throw_exception (ex);
     }
 
   cleanup = make_cleanup (xfree, sals.sals);
diff --git a/gdb/probe.c b/gdb/probe.c
index 623f65c..838d9f9 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -59,7 +59,8 @@ parse_probes (char **argptr, struct linespec_result *canonical)
 
   cs = *argptr;
   probe_ops = probe_linespec_to_ops (&cs);
-  gdb_assert (probe_ops != NULL);
+  if (probe_ops == NULL)
+    error (_("'%s' is not a probe linespec"), arg_start);
 
   arg = (char *) cs;
   arg = skip_spaces (arg);

-- 
Sergio

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

* Re: [RFC] fix probe-related internal error on AIX
  2014-03-11 17:44 ` Sergio Durigan Junior
@ 2014-03-20 17:21   ` Tom Tromey
  2014-03-20 21:11     ` Sergio Durigan Junior
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2014-03-20 17:21 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: gdb-patches

>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:

Sergio> By reading the patch (and the original code), I found it a little bit
Sergio> obscure, so I took the liberty to try to improve it.  Here's the patch.
Sergio> Could you please take a look and see if it works on AIX (and also if you
Sergio> like the approach)?

Thanks, this works fine.
Could you please put it in?

Tom

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

* Re: [RFC] fix probe-related internal error on AIX
  2014-03-20 17:21   ` Tom Tromey
@ 2014-03-20 21:11     ` Sergio Durigan Junior
  0 siblings, 0 replies; 4+ messages in thread
From: Sergio Durigan Junior @ 2014-03-20 21:11 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thursday, March 20 2014, Tom Tromey wrote:

> Thanks, this works fine.
> Could you please put it in?

Thanks, pushed.

  https://sourceware.org/ml/gdb-cvs/2014-03/msg00067.html

-- 
Sergio

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

end of thread, other threads:[~2014-03-20 21:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-06 18:06 [RFC] fix probe-related internal error on AIX Tom Tromey
2014-03-11 17:44 ` Sergio Durigan Junior
2014-03-20 17:21   ` Tom Tromey
2014-03-20 21:11     ` Sergio Durigan Junior

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