aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Durigan Junior <sergiodj@redhat.com>2014-10-14 14:45:13 -0400
committerSergio Durigan Junior <sergiodj@redhat.com>2014-10-14 14:46:18 -0400
commit0ea5cda8612bd2233f7a2f9d1eba0b62c2e6c015 (patch)
tree68a032cab73c270e981d6efe1d1ec726fee51b11
parentf7088df3b1c0370101edada54e26d24efb53125c (diff)
downloadgdb-0ea5cda8612bd2233f7a2f9d1eba0b62c2e6c015.zip
gdb-0ea5cda8612bd2233f7a2f9d1eba0b62c2e6c015.tar.gz
gdb-0ea5cda8612bd2233f7a2f9d1eba0b62c2e6c015.tar.bz2
Only call {set,clear}_semaphore probe function if they are not NULL
This patch is a response to what I commented on: <https://sourceware.org/ml/gdb-patches/2014-10/msg00046.html> When reviewing Jose's USDT probe support patches. Basically, in his patch he had to create dummy functions for the set_semaphore and the clear_semaphore methods of probe_ops (gdb/probe.h), because those functions were called inconditionally from inside gdb/breakpoint.c and gdb/tracepoint.c. However, the semaphore concept may not apply to all types of probes, and this is the case here: USDT probes do not have semaphores (although SDT probes do). Anyway, this is a simple (almost obvious) patch to guard the call to {set,clear}_semaphore. It does not introduce any regression on a Fedora 20 x86_64. I will apply it in a few days in case there is no comment. gdb/ChangeLog: 2014-10-14 Sergio Durigan Junior <sergiodj@redhat.com> * breakpoint.c (bkpt_probe_insert_location): Call set_semaphore only if it is not NULL. (bkpt_probe_remove_location): Likewise, for clear_semaphore. * probe.h (struct probe_ops) <set_semaphore>: Update comment. (struct probe_ops) <clear_semaphore>: Likewise. * tracepoint.c (start_tracing): Call set_semaphore only if it is not NULL. (stop_tracing): Likewise, for clear_semaphore.
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/breakpoint.c14
-rw-r--r--gdb/probe.h4
-rw-r--r--gdb/tracepoint.c6
4 files changed, 25 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ec05028..57ddd7b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2014-10-14 Sergio Durigan Junior <sergiodj@redhat.com>
+ * breakpoint.c (bkpt_probe_insert_location): Call set_semaphore
+ only if it is not NULL.
+ (bkpt_probe_remove_location): Likewise, for clear_semaphore.
+ * probe.h (struct probe_ops) <set_semaphore>: Update comment.
+ (struct probe_ops) <clear_semaphore>: Likewise.
+ * tracepoint.c (start_tracing): Call set_semaphore only if it is
+ not NULL.
+ (stop_tracing): Likewise, for clear_semaphore.
+
+2014-10-14 Sergio Durigan Junior <sergiodj@redhat.com>
+
* stap-probe.c (stap_parse_argument): Initialize expout explicitly
using language_c, instead of current_language.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index a144a7e..dc2e297 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -13696,9 +13696,10 @@ bkpt_probe_insert_location (struct bp_location *bl)
{
/* The insertion was successful, now let's set the probe's semaphore
if needed. */
- bl->probe.probe->pops->set_semaphore (bl->probe.probe,
- bl->probe.objfile,
- bl->gdbarch);
+ if (bl->probe.probe->pops->set_semaphore != NULL)
+ bl->probe.probe->pops->set_semaphore (bl->probe.probe,
+ bl->probe.objfile,
+ bl->gdbarch);
}
return v;
@@ -13708,9 +13709,10 @@ static int
bkpt_probe_remove_location (struct bp_location *bl)
{
/* Let's clear the semaphore before removing the location. */
- bl->probe.probe->pops->clear_semaphore (bl->probe.probe,
- bl->probe.objfile,
- bl->gdbarch);
+ if (bl->probe.probe->pops->clear_semaphore != NULL)
+ bl->probe.probe->pops->clear_semaphore (bl->probe.probe,
+ bl->probe.objfile,
+ bl->gdbarch);
return bkpt_remove_location (bl);
}
diff --git a/gdb/probe.h b/gdb/probe.h
index b4ff0a6..a128151 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -96,14 +96,14 @@ struct probe_ops
/* Set the semaphore associated with the PROBE. This function only makes
sense if the probe has a concept of semaphore associated to a
- probe. */
+ probe, otherwise it can be set to NULL. */
void (*set_semaphore) (struct probe *probe, struct objfile *objfile,
struct gdbarch *gdbarch);
/* Clear the semaphore associated with the PROBE. This function only
makes sense if the probe has a concept of semaphore associated to
- a probe. */
+ a probe, otherwise it can be set to NULL. */
void (*clear_semaphore) (struct probe *probe, struct objfile *objfile,
struct gdbarch *gdbarch);
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 51af2af..fc20063 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1858,7 +1858,8 @@ start_tracing (char *notes)
t->number_on_target = b->number;
for (loc = b->loc; loc; loc = loc->next)
- if (loc->probe.probe != NULL)
+ if (loc->probe.probe != NULL
+ && loc->probe.probe->pops->set_semaphore != NULL)
loc->probe.probe->pops->set_semaphore (loc->probe.probe,
loc->probe.objfile,
loc->gdbarch);
@@ -1957,7 +1958,8 @@ stop_tracing (char *note)
but we don't really care if this semaphore goes out of sync.
That's why we are decrementing it here, but not taking care
in other places. */
- if (loc->probe.probe != NULL)
+ if (loc->probe.probe != NULL
+ && loc->probe.probe->pops->clear_semaphore != NULL)
loc->probe.probe->pops->clear_semaphore (loc->probe.probe,
loc->probe.objfile,
loc->gdbarch);