Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Tom Tromey <tromey@redhat.com>,
	       Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH 02/10] SystemTap integration
Date: Sat, 02 Jun 2012 19:33:00 -0000	[thread overview]
Message-ID: <1338665528-5932-3-git-send-email-sergiodj@redhat.com> (raw)
In-Reply-To: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>

With the inclusion of the SystemTap integration patch, I had to create
this other patch to make it compile with this refactoring.  It simply
uses the new field `pstate' present in `struct stap_parse_info'.

---
 gdb/arm-linux-tdep.c |   26 ++++++++--------
 gdb/i386-tdep.c      |   85 ++++++++++++++++++++++++++------------------------
 gdb/ppc-linux-tdep.c |    6 ++--
 gdb/stap-probe.c     |   64 +++++++++++++++++++------------------
 gdb/stap-probe.h     |    6 +++
 5 files changed, 99 insertions(+), 88 deletions(-)

diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index f4eaa5c..be4f202 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1147,28 +1147,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 5b04505..5751a2d 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3499,34 +3499,36 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
 
 		  for (i = 0; i < 3; i++)
 		    {
-		      write_exp_elt_opcode (OP_LONG);
+		      write_exp_elt_opcode (&p->pstate, OP_LONG);
 		      write_exp_elt_type
-			(builtin_type (gdbarch)->builtin_long);
-		      write_exp_elt_longcst (displacements[i]);
-		      write_exp_elt_opcode (OP_LONG);
+			(&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;
 
@@ -3627,49 +3629,50 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
 
 		  if (offset)
 		    {
-		      write_exp_elt_opcode (OP_LONG);
+		      write_exp_elt_opcode (&p->pstate, OP_LONG);
 		      write_exp_elt_type
-			(builtin_type (gdbarch)->builtin_long);
-		      write_exp_elt_longcst (offset);
-		      write_exp_elt_opcode (OP_LONG);
+			(&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_opcode (&p->pstate, OP_LONG);
 		      write_exp_elt_type
-			(builtin_type (gdbarch)->builtin_long);
-		      write_exp_elt_longcst (size);
-		      write_exp_elt_opcode (OP_LONG);
+			(&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 98704c1..2bf3259 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1335,11 +1335,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 506e6c3..80b0671 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -427,12 +427,12 @@ stap_parse_register_operand (struct stap_parse_info *p)
       displacement = strtol (p->arg, (char **) &p->arg, 10);
 
       /* 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.  */
@@ -487,23 +487,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.  */
@@ -608,9 +608,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
 	{
@@ -639,10 +639,11 @@ stap_parse_single_operand (struct stap_parse_info *p)
 	  && strncmp (tmp, reg_ind_prefix, reg_ind_prefix_len) != 0)
 	{
 	  /* 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;
 
@@ -671,10 +672,10 @@ stap_parse_single_operand (struct stap_parse_info *p)
       p->arg += const_prefix_len;
       number = strtol (p->arg, (char **) &p->arg, 10);
 
-      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 (const_suffix)
 	{
@@ -822,7 +823,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);
     }
 }
 
@@ -863,8 +864,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;
@@ -879,16 +880,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 e30d56a..003fad9 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.  */
-- 
1.7.7.6


  parent reply	other threads:[~2012-06-02 19:33 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-02 19:33 [PATCH 00/10] Remove `expout*' globals from parser-defs.h Sergio Durigan Junior
2012-06-02 19:33 ` [PATCH 01/10] Language independent bits Sergio Durigan Junior
2012-06-04 20:20   ` Tom Tromey
2012-06-05  0:39     ` Sergio Durigan Junior
2012-06-02 19:33 ` Sergio Durigan Junior [this message]
2012-06-04 20:23   ` [PATCH 02/10] SystemTap integration Tom Tromey
2012-06-02 19:34 ` [PATCH 03/10] C language Sergio Durigan Junior
2012-06-04  4:25   ` Doug Evans
2012-06-04  4:32     ` Sergio Durigan Junior
2012-06-04 20:32   ` Tom Tromey
2012-06-04 20:39     ` Sergio Durigan Junior
2012-06-04 20:42     ` Mark Kettenis
2012-06-04 20:49       ` Sergio Durigan Junior
2012-06-04 21:19         ` Mark Kettenis
2012-06-06 19:17           ` Tom Tromey
2012-06-02 20:23 ` [PATCH 04/10] Ada language Sergio Durigan Junior
2012-06-13  4:57   ` Sergio Durigan Junior
2012-06-13 14:50     ` Joel Brobecker
2012-06-02 20:23 ` [PATCH 10/10] Go programming language Sergio Durigan Junior
2012-06-13  4:58   ` Sergio Durigan Junior
2012-06-13 17:02     ` Doug Evans
2012-06-02 20:24 ` [PATCH 05/10] Fortran language Sergio Durigan Junior
2012-06-13  4:59   ` Sergio Durigan Junior
2012-06-13 14:55     ` Joel Brobecker
2012-06-02 20:24 ` [PATCH 08/10] Objective-C language Sergio Durigan Junior
2012-06-13  4:59   ` Sergio Durigan Junior
2012-06-13 14:54     ` Joel Brobecker
2012-06-13 16:02     ` Tom Tromey
2012-06-02 20:33 ` [PATCH 07/10] Modula-2 language Sergio Durigan Junior
2012-06-13  4:59   ` Sergio Durigan Junior
2012-06-13 14:51     ` Joel Brobecker
2012-06-16 14:29       ` Gaius Mulley
2012-06-02 20:33 ` [PATCH 09/10] Pascal language Sergio Durigan Junior
2012-06-05  7:39   ` Pierre Muller
2012-06-02 20:34 ` [PATCH 06/10] Java language Sergio Durigan Junior
2012-06-04 20:27   ` Tom Tromey
2012-06-05  0:35     ` Sergio Durigan Junior
2012-06-06 20:02       ` Tom Tromey
2012-06-07  0:57         ` Joel Brobecker
2012-06-04 20:38 ` [PATCH 00/10] Remove `expout*' globals from parser-defs.h Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338665528-5932-3-git-send-email-sergiodj@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox