mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user