From patchwork Sat Mar 22 04:43:44 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: 223 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (caibbdcaaahb.dreamhost.com [208.113.200.71]) by wilcox.dreamhost.com (Postfix) with ESMTP id 858CC3600C2 for ; Fri, 21 Mar 2014 21:44:22 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 32750C5E615; Fri, 21 Mar 2014 21:44:22 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.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-mx21.g.dreamhost.com (Postfix) with ESMTPS id E2E34C9DE10 for ; Fri, 21 Mar 2014 21:44:21 -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:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=hSC3zOrzCAIbdXcU/x0A2pEg0iRryIl +aqfleNaYYI9+fGgS0gS8ZrVVYGFpnHkVYdnKb/GuxWB43Q3lqMSOwO+Npdx+IuI e6RnGl5vf0ovB+LwcXnjM8mfZewpa9rqGhkpRxLxjqQ9BEGbj/HBx2IJQDeLB8sr CYr6ANaxdr+A= 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:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=TGiD/CBu1g6GYkj+I3tmyD0yYds=; b=T+zLG o7ffTTp45Yw2MKXpVAF890jdmLoHjD+NrqXv7Dy4okXIX1IZakuDh0FFyksk00G9 8gY0wdfSmsbHBgWG1jdeeDH2he9y2DheXOxRcGNsJyZy2OrHSSKMUrhDFrMrAE5U hJsH5mJ6T9xgZsGcyQzd5T35uXsxKD17ajUeN4= Received: (qmail 30333 invoked by alias); 22 Mar 2014 04:44:19 -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 30234 invoked by uid 89); 22 Mar 2014 04:44:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD, UNWANTED_LANGUAGE_BODY 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; Sat, 22 Mar 2014 04:44:15 +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 s2M4iDOr026915 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 22 Mar 2014 00:44:13 -0400 Received: from psique.redhat.com (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2M4i8XD001988; Sat, 22 Mar 2014 00:44:12 -0400 From: Sergio Durigan Junior To: GDB Patches Cc: Tom Tromey , Sergio Durigan Junior Subject: [PATCH v4 02/10] SystemTap integration Date: Sat, 22 Mar 2014 01:43:44 -0300 Message-Id: <1395463432-29750-3-git-send-email-sergiodj@redhat.com> In-Reply-To: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> References: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in This patch takes care of the SystemTap SDT probe integration code, making it aware of the new parser state mechanism. 2014-03-22 Sergio Durigan Junior * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) : New field. --- gdb/aarch64-linux-tdep.c | 26 +++++++------- gdb/arm-linux-tdep.c | 26 +++++++------- gdb/i386-tdep.c | 88 ++++++++++++++++++++++++++---------------------- gdb/ppc-linux-tdep.c | 6 ++-- gdb/stap-probe.c | 64 ++++++++++++++++++----------------- gdb/stap-probe.h | 6 ++++ 6 files changed, 115 insertions(+), 101 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 194e4cc..92d1248 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -352,28 +352,28 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch, return 0; /* The displacement. */ - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (displacement); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, displacement); + write_exp_elt_opcode (&p->pstate, OP_LONG); if (got_minus) - write_exp_elt_opcode (UNOP_NEG); + write_exp_elt_opcode (&p->pstate, UNOP_NEG); /* The register name. */ - write_exp_elt_opcode (OP_REGISTER); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); str.ptr = regname; str.length = len; - write_exp_string (str); - write_exp_elt_opcode (OP_REGISTER); + write_exp_string (&p->pstate, str); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); - write_exp_elt_opcode (BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); /* Casting to the expected type. */ - write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (lookup_pointer_type (p->arg_type)); - write_exp_elt_opcode (UNOP_CAST); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); + write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type)); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); - write_exp_elt_opcode (UNOP_IND); + write_exp_elt_opcode (&p->pstate, UNOP_IND); p->arg = tmp; } diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index de0c211..98b912b 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -1206,28 +1206,28 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch, return 0; /* The displacement. */ - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (displacement); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, displacement); + write_exp_elt_opcode (&p->pstate, OP_LONG); if (got_minus) - write_exp_elt_opcode (UNOP_NEG); + write_exp_elt_opcode (&p->pstate, UNOP_NEG); /* The register name. */ - write_exp_elt_opcode (OP_REGISTER); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); str.ptr = regname; str.length = len; - write_exp_string (str); - write_exp_elt_opcode (OP_REGISTER); + write_exp_string (&p->pstate, str); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); - write_exp_elt_opcode (BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); /* Casting to the expected type. */ - write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (lookup_pointer_type (p->arg_type)); - write_exp_elt_opcode (UNOP_CAST); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); + write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type)); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); - write_exp_elt_opcode (UNOP_IND); + write_exp_elt_opcode (&p->pstate, UNOP_IND); p->arg = tmp; } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index be40b20..5515afb 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3766,33 +3766,36 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch, for (i = 0; i < 3; i++) { - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (displacements[i]); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type + (&p->pstate, builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, displacements[i]); + write_exp_elt_opcode (&p->pstate, OP_LONG); if (got_minus[i]) - write_exp_elt_opcode (UNOP_NEG); + write_exp_elt_opcode (&p->pstate, UNOP_NEG); } - write_exp_elt_opcode (OP_REGISTER); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); str.ptr = regname; str.length = len; - write_exp_string (str); - write_exp_elt_opcode (OP_REGISTER); + write_exp_string (&p->pstate, str); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); - write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (builtin_type (gdbarch)->builtin_data_ptr); - write_exp_elt_opcode (UNOP_CAST); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); + write_exp_elt_type (&p->pstate, + builtin_type (gdbarch)->builtin_data_ptr); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); - write_exp_elt_opcode (BINOP_ADD); - write_exp_elt_opcode (BINOP_ADD); - write_exp_elt_opcode (BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); - write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (lookup_pointer_type (p->arg_type)); - write_exp_elt_opcode (UNOP_CAST); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); + write_exp_elt_type (&p->pstate, + lookup_pointer_type (p->arg_type)); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); - write_exp_elt_opcode (UNOP_IND); + write_exp_elt_opcode (&p->pstate, UNOP_IND); p->arg = s; @@ -3912,47 +3915,50 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch, if (offset) { - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (offset); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type (&p->pstate, + builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, offset); + write_exp_elt_opcode (&p->pstate, OP_LONG); if (offset_minus) - write_exp_elt_opcode (UNOP_NEG); + write_exp_elt_opcode (&p->pstate, UNOP_NEG); } - write_exp_elt_opcode (OP_REGISTER); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); base_token.ptr = base; base_token.length = len_base; - write_exp_string (base_token); - write_exp_elt_opcode (OP_REGISTER); + write_exp_string (&p->pstate, base_token); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); if (offset) - write_exp_elt_opcode (BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); - write_exp_elt_opcode (OP_REGISTER); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); index_token.ptr = index; index_token.length = len_index; - write_exp_string (index_token); - write_exp_elt_opcode (OP_REGISTER); + write_exp_string (&p->pstate, index_token); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); if (size) { - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (size); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type (&p->pstate, + builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, size); + write_exp_elt_opcode (&p->pstate, OP_LONG); if (size_minus) - write_exp_elt_opcode (UNOP_NEG); - write_exp_elt_opcode (BINOP_MUL); + write_exp_elt_opcode (&p->pstate, UNOP_NEG); + write_exp_elt_opcode (&p->pstate, BINOP_MUL); } - write_exp_elt_opcode (BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); - write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (lookup_pointer_type (p->arg_type)); - write_exp_elt_opcode (UNOP_CAST); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); + write_exp_elt_type (&p->pstate, + lookup_pointer_type (p->arg_type)); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); - write_exp_elt_opcode (UNOP_IND); + write_exp_elt_opcode (&p->pstate, UNOP_IND); p->arg = s; diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 08c5342..5278a24 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -978,11 +978,11 @@ ppc_stap_parse_special_token (struct gdbarch *gdbarch, error (_("Invalid register name `%s' on expression `%s'."), regname, p->saved_arg); - write_exp_elt_opcode (OP_REGISTER); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); str.ptr = regname; str.length = len; - write_exp_string (str); - write_exp_elt_opcode (OP_REGISTER); + write_exp_string (&p->pstate, str); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); p->arg = s; } diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index 986debd..dbe9f31 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -601,12 +601,12 @@ stap_parse_register_operand (struct stap_parse_info *p) p->arg = endp; /* Generating the expression for the displacement. */ - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (displacement); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, displacement); + write_exp_elt_opcode (&p->pstate, OP_LONG); if (got_minus) - write_exp_elt_opcode (UNOP_NEG); + write_exp_elt_opcode (&p->pstate, UNOP_NEG); } /* Getting rid of register indirection prefix. */ @@ -660,23 +660,23 @@ stap_parse_register_operand (struct stap_parse_info *p) error (_("Invalid register name `%s' on expression `%s'."), regname, p->saved_arg); - write_exp_elt_opcode (OP_REGISTER); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); str.ptr = regname; str.length = len; - write_exp_string (str); - write_exp_elt_opcode (OP_REGISTER); + write_exp_string (&p->pstate, str); + write_exp_elt_opcode (&p->pstate, OP_REGISTER); if (indirect_p) { if (disp_p) - write_exp_elt_opcode (BINOP_ADD); + write_exp_elt_opcode (&p->pstate, BINOP_ADD); /* Casting to the expected type. */ - write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (lookup_pointer_type (p->arg_type)); - write_exp_elt_opcode (UNOP_CAST); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); + write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type)); + write_exp_elt_opcode (&p->pstate, UNOP_CAST); - write_exp_elt_opcode (UNOP_IND); + write_exp_elt_opcode (&p->pstate, UNOP_IND); } /* Getting rid of the register name suffix. */ @@ -767,9 +767,9 @@ stap_parse_single_operand (struct stap_parse_info *p) ++p->arg; stap_parse_argument_conditionally (p); if (c == '-') - write_exp_elt_opcode (UNOP_NEG); + write_exp_elt_opcode (&p->pstate, UNOP_NEG); else if (c == '~') - write_exp_elt_opcode (UNOP_COMPLEMENT); + write_exp_elt_opcode (&p->pstate, UNOP_COMPLEMENT); } else { @@ -807,10 +807,11 @@ stap_parse_single_operand (struct stap_parse_info *p) const char *int_suffix; /* We are dealing with a numeric constant. */ - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (number); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type (&p->pstate, + builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, number); + write_exp_elt_opcode (&p->pstate, OP_LONG); p->arg = tmp; @@ -837,10 +838,10 @@ stap_parse_single_operand (struct stap_parse_info *p) number = strtol (p->arg, &endp, 10); p->arg = endp; - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type (gdbarch)->builtin_long); - write_exp_elt_longcst (number); - write_exp_elt_opcode (OP_LONG); + write_exp_elt_opcode (&p->pstate, OP_LONG); + write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long); + write_exp_elt_longcst (&p->pstate, number); + write_exp_elt_opcode (&p->pstate, OP_LONG); if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix)) p->arg += strlen (int_suffix); @@ -987,7 +988,7 @@ stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs, stap_parse_argument_1 (p, 1, lookahead_prec); } - write_exp_elt_opcode (opcode); + write_exp_elt_opcode (&p->pstate, opcode); } } @@ -1028,8 +1029,8 @@ stap_parse_argument (const char **arg, struct type *atype, /* We need to initialize the expression buffer, in order to begin our parsing efforts. The language here does not matter, since we are using our own parser. */ - initialize_expout (10, current_language, gdbarch); - back_to = make_cleanup (free_current_contents, &expout); + initialize_expout (&p.pstate, 10, current_language, gdbarch); + back_to = make_cleanup (free_current_contents, &p.pstate.expout); p.saved_arg = *arg; p.arg = *arg; @@ -1044,16 +1045,17 @@ stap_parse_argument (const char **arg, struct type *atype, gdb_assert (p.inside_paren_p == 0); /* Casting the final expression to the appropriate type. */ - write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (atype); - write_exp_elt_opcode (UNOP_CAST); + write_exp_elt_opcode (&p.pstate, UNOP_CAST); + write_exp_elt_type (&p.pstate, atype); + write_exp_elt_opcode (&p.pstate, UNOP_CAST); - reallocate_expout (); + reallocate_expout (&p.pstate); p.arg = skip_spaces_const (p.arg); *arg = p.arg; - return expout; + /* We can safely return EXPOUT here. */ + return p.pstate.expout; } /* Function which parses an argument string from PROBE, correctly splitting diff --git a/gdb/stap-probe.h b/gdb/stap-probe.h index 5b16201..6d3c12e 100644 --- a/gdb/stap-probe.h +++ b/gdb/stap-probe.h @@ -20,6 +20,9 @@ #if !defined (STAP_PROBE_H) #define STAP_PROBE_H 1 +/* For `struct parser_state'. */ +#include "parser-defs.h" + /* Structure which holds information about the parsing process of one probe's argument. */ @@ -28,6 +31,9 @@ struct stap_parse_info /* The probe's argument in a string format. */ const char *arg; + /* The parser state to be used when generating the expression. */ + struct parser_state pstate; + /* A pointer to the full chain of arguments. This is useful for printing error messages. The parser functions should not modify this argument directly; instead, they should use the ARG pointer above. */