From patchwork Thu May 8 18:02:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 844 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id A58D1360098 for ; Thu, 8 May 2014 11:02:11 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 6CC9A41927AA5; Thu, 8 May 2014 11:02:11 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 4259F41860EA7 for ; Thu, 8 May 2014 11:02:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :content-type; q=dns; s=default; b=kq09wBPcQh7OEhPOl0Rn3fHuAAqYa XPgwpDt5e7VnA8GkTHifTr4OT6LjxNjXg1vF61Oiapkg2VjpIhD39IJm/AFpvC3y 9hqldA0Zmd+b0kfHqzmtoVxHcoRN794KyAXf1IgZMelsC5NvMkmYulnywH+bdkq+ NQ99K5BzwJqx0g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :content-type; s=default; bh=6uU/jLmtvRHk/Pdz4XmGG+9nxfY=; b=KeX KUySa1hlKViiOzHpoPnRSizwzLF3/s5iXIiHgC9wVTJJzd1NgKABiMYhePuIkxeE sDcJhPq7o2vrf9fhZRQNdp0G3yvGEUh2gtML4BPNBw7qqYgINqsEgUBzzNkH5wH2 ESTUtQvvFM2XLoFcgyxlXW0N1oTCBQt5/cX7kej4= Received: (qmail 14637 invoked by alias); 8 May 2014 18:02:09 -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 14626 invoked by uid 89); 8 May 2014 18:02:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham 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 ESMTP; Thu, 08 May 2014 18:02:08 +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 s48I2696020077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 8 May 2014 14:02:07 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s48I26RT014729 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 8 May 2014 14:02:06 -0400 Message-ID: <536BC69E.9060008@redhat.com> Date: Thu, 08 May 2014 11:02:06 -0700 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "gdb-patches@sourceware.org ml" Subject: [RFA 5/9] Explicit locations v2 - Add probe locations X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi, This patch adds support for probe locations. This is a new location type that I added in this v2 revision of this series. Like the previous patch for address locations, this patch does not add any new functionality. It is also "simply" an elaboration of the new location API. Keith ChangeLog 2014-05-08 Keith Seitz * break-catch-throw.c (re_set_exception_catchpoint): Convert linespec for stap probe to probe location. * breakpoint.c (create_longjmp_master_breakpoint): Likewise. (create_exception_master_breakpoint): Likewise. (break_command_1): Remove local variable `arg_cp'. Check location type to set appropriate breakpoint ops methods. (trace_command): Likewise. * linespec.c (event_location_to_sals): Handle probe locations. * location.c (copy_event_location): Likewise. (delete_event_location): Likewise. (event_location_to_string): Likewise. (string_to_event_location): Likewise. (event_location_empty_p): Handel probe locations. * location.h (enum event_location_type): Add EVENT_LOCATION_PROBE. (EVENT_LOCATION_PROBE): Define accessor macro. * probe.c (parse_probes): Assert that LOCATION is a probe location. Convert linespec into probe location. diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 31cce47..e352935 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -214,8 +214,8 @@ re_set_exception_catchpoint (struct breakpoint *self) { struct event_location location; - initialize_event_location (&location, EVENT_LOCATION_LINESPEC); - EVENT_LOCATION_LINESPEC (&location) + initialize_event_location (&location, EVENT_LOCATION_PROBE); + EVENT_LOCATION_PROBE (&location) = ASTRDUP (exception_functions[kind].probe); sals = parse_probes (&location, NULL); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index f509d7a..fdf7c10 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3387,8 +3387,8 @@ create_longjmp_master_breakpoint (void) objfile), bp_longjmp_master, &internal_breakpoint_ops); - b->location = new_event_location (EVENT_LOCATION_LINESPEC); - EVENT_LOCATION_LINESPEC (b->location) + b->location = new_event_location (EVENT_LOCATION_PROBE); + EVENT_LOCATION_PROBE (b->location) = xstrdup ("-probe-stap libc:longjmp"); b->enable_state = bp_disabled; } @@ -3554,8 +3554,8 @@ create_exception_master_breakpoint (void) objfile), bp_exception_master, &internal_breakpoint_ops); - b->location = new_event_location (EVENT_LOCATION_LINESPEC); - EVENT_LOCATION_LINESPEC (b->location) + b->location = new_event_location (EVENT_LOCATION_PROBE); + EVENT_LOCATION_PROBE (b->location) = xstrdup ("-probe-stap libgcc:unwind"); b->enable_state = bp_disabled; } @@ -10086,7 +10086,6 @@ break_command_1 (char *arg, int flag, int from_tty) ? bp_hardware_breakpoint : bp_breakpoint); struct breakpoint_ops *ops; - const char *arg_cp = arg; struct event_location *location; struct cleanup *cleanup; @@ -10094,7 +10093,8 @@ break_command_1 (char *arg, int flag, int from_tty) cleanup = make_cleanup (delete_event_location, location); /* Matching breakpoints on probes. */ - if (arg_cp != NULL && probe_linespec_to_ops (&arg_cp) != NULL) + if (location != NULL + && EVENT_LOCATION_TYPE (location) == EVENT_LOCATION_PROBE) ops = &bkpt_probe_breakpoint_ops; else ops = &bkpt_breakpoint_ops; @@ -15471,11 +15471,11 @@ trace_command (char *arg, int from_tty) struct breakpoint_ops *ops; struct event_location *location; struct cleanup *back_to; - const char *arg_cp = arg; location = string_to_event_location (&arg, current_language); back_to = make_cleanup (delete_event_location, location); - if (arg_cp != NULL && probe_linespec_to_ops (&arg_cp) != NULL) + if (location != NULL + && EVENT_LOCATION_TYPE (location) == EVENT_LOCATION_PROBE) ops = &tracepoint_probe_breakpoint_ops; else ops = &tracepoint_breakpoint_ops; diff --git a/gdb/linespec.c b/gdb/linespec.c index 07a84b5..069aab6 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2457,6 +2457,11 @@ event_location_to_sals (linespec_parser *parser, EVENT_LOCATION_ADDRESS (location)); break; + case EVENT_LOCATION_PROBE: + /* Probes are handled by their own decoders. */ + gdb_assert_not_reached ("attempt to decode probe location"); + break; + default: gdb_assert_not_reached ("unhandled event location type"); } diff --git a/gdb/location.c b/gdb/location.c index 22e7496..a64d37c 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -72,6 +72,10 @@ copy_event_location (const struct event_location *src) EVENT_LOCATION_ADDRESS (dst) = EVENT_LOCATION_ADDRESS (src); break; + case EVENT_LOCATION_PROBE: + EVENT_LOCATION_PROBE (dst) = xstrdup (EVENT_LOCATION_PROBE (src)); + break; + default: gdb_assert_not_reached ("unknown event location type"); } @@ -101,6 +105,10 @@ delete_event_location (void *data) /* Nothing to do. */ break; + case EVENT_LOCATION_PROBE: + xfree (EVENT_LOCATION_PROBE (location)); + break; + default: gdb_assert_not_reached ("unknown event location type"); } @@ -128,6 +136,10 @@ event_location_to_string (const struct event_location *location) result = EVENT_LOCATION_SAVE_SPEC (location); break; + case EVENT_LOCATION_PROBE: + result = EVENT_LOCATION_PROBE (location); + break; + default: gdb_assert_not_reached ("unknown event location type"); } @@ -158,12 +170,28 @@ string_to_event_location (char **stringp, } else { - /* Everything else is a linespec. */ - location = new_event_location (EVENT_LOCATION_LINESPEC); - if (*stringp != NULL) + const char *cs; + + /* Next, try the input as a probe spec. */ + cs = *stringp; + if (cs != NULL && probe_linespec_to_ops (&cs) != NULL) { - EVENT_LOCATION_LINESPEC (location) = xstrdup (*stringp); - *stringp += strlen (*stringp); + location = new_event_location (EVENT_LOCATION_PROBE); + if (*stringp != NULL) + { + EVENT_LOCATION_PROBE (location) = xstrdup (*stringp); + *stringp += strlen (*stringp); + } + } + else + { + /* Everything else is a linespec. */ + location = new_event_location (EVENT_LOCATION_LINESPEC); + if (*stringp != NULL) + { + EVENT_LOCATION_LINESPEC (location) = xstrdup (*stringp); + *stringp += strlen (*stringp); + } } } @@ -183,6 +211,9 @@ event_location_empty_p (const struct event_location *location) case EVENT_LOCATION_ADDRESS: return 0; + case EVENT_LOCATION_PROBE: + return EVENT_LOCATION_PROBE (location) == NULL; + default: gdb_assert_not_reached ("unknown event location type"); } diff --git a/gdb/location.h b/gdb/location.h index 8575daf..b207c87 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -30,7 +30,10 @@ enum event_location_type EVENT_LOCATION_LINESPEC, /* An address in the inferior. */ - EVENT_LOCATION_ADDRESS + EVENT_LOCATION_ADDRESS, + + /* A probe location. */ + EVENT_LOCATION_PROBE }; /* An event location used to set a stop event in the inferior. @@ -50,6 +53,7 @@ struct event_location probes. */ char *addr_string; #define EVENT_LOCATION_LINESPEC(S) ((S)->u.addr_string) +#define EVENT_LOCATION_PROBE(S) ((S)->u.addr_string) /* An address in the inferior. */ CORE_ADDR address; diff --git a/gdb/probe.c b/gdb/probe.c index f7afe0b..82bcdab 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -58,7 +58,8 @@ parse_probes (struct event_location *location, result.sals = NULL; result.nelts = 0; - arg_start = EVENT_LOCATION_LINESPEC (location); + gdb_assert (EVENT_LOCATION_TYPE (location) == EVENT_LOCATION_PROBE); + arg_start = EVENT_LOCATION_PROBE (location); cs = arg_start; probe_ops = probe_linespec_to_ops (&cs); @@ -173,12 +174,12 @@ parse_probes (struct event_location *location, { canonical->special_display = 1; canonical->pre_expanded = 1; - canonical->location = new_event_location (EVENT_LOCATION_LINESPEC); - EVENT_LOCATION_LINESPEC (canonical->location) + canonical->location = new_event_location (EVENT_LOCATION_PROBE); + EVENT_LOCATION_PROBE (canonical->location) = savestring (arg_start, arg_end - arg_start); } - EVENT_LOCATION_LINESPEC (location) = arg_end; + EVENT_LOCATION_PROBE (location) = arg_end; do_cleanups (cleanup); return result;