From patchwork Fri Oct 10 21:36:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 3200 Received: (qmail 29512 invoked by alias); 10 Oct 2014 21:36:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 29503 invoked by uid 89); 10 Oct 2014 21:36:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, LIKELY_SPAM_BODY, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 10 Oct 2014 21:36:41 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9ALadv6011004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 Oct 2014 17:36:39 -0400 Received: from psique.yyz.redhat.com (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9ALacfl025394; Fri, 10 Oct 2014 17:36:38 -0400 From: Sergio Durigan Junior To: GDB Patches Cc: "Jose E. Marchesi" , Sergio Durigan Junior Subject: [PATCH] Only call {set, clear}_semaphore probe function if they are not NULL Date: Fri, 10 Oct 2014 17:36:33 -0400 Message-Id: <1412976993-9465-1-git-send-email-sergiodj@redhat.com> X-IsSubscribed: yes This patch is a response to what I commented on: 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-10 Sergio Durigan Junior * 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) : Update comment. (struct probe_ops) : Likewise. * tracepoint.c (start_tracing): Call set_semaphore only if it is not NULL. (stop_tracing): Likewise, for clear_semaphore. --- gdb/breakpoint.c | 14 ++++++++------ gdb/probe.h | 4 ++-- gdb/tracepoint.c | 6 ++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3044916..6de5804 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);