public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-sergiodj-stap-patch-split: Cleanup, comments.
@ 2011-09-09 19:03 sergiodj
  0 siblings, 0 replies; only message in thread
From: sergiodj @ 2011-09-09 19:03 UTC (permalink / raw)
  To: archer-commits

The branch, archer-sergiodj-stap-patch-split has been updated
       via  62e2c58e8ec35b12b11da53e2e434f86f689f5f9 (commit)
       via  8dbe0e63610406b1b211583461680d67525ca914 (commit)
       via  a69609c3affa6484cc2a40d5365a56e01e2c5506 (commit)
      from  3128661e5b855982895772e73c4405aa26c456b4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 62e2c58e8ec35b12b11da53e2e434f86f689f5f9
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Fri Sep 9 16:03:04 2011 -0300

    Cleanup, comments.

commit 8dbe0e63610406b1b211583461680d67525ca914
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Fri Sep 9 15:30:55 2011 -0300

    Few cleanups

commit a69609c3affa6484cc2a40d5365a56e01e2c5506
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Fri Sep 9 15:29:26 2011 -0300

    Fixing arm bug.  Everything is apparently working OK now.

-----------------------------------------------------------------------

Summary of changes:
 gdb/amd64-linux-tdep.c |    2 -
 gdb/arm-linux-tdep.c   |    6 +-
 gdb/i386-linux-tdep.c  |    2 -
 gdb/ppc-linux-tdep.c   |    2 +-
 gdb/stap-probe.c       |  747 +++++-------------------------------------------
 5 files changed, 70 insertions(+), 689 deletions(-)

First 500 lines of diff:
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index dd22c3a..0e504e0 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1371,8 +1371,6 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
   set_gdbarch_stap_register_indirection_sufix (gdbarch, ")");
   set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand);
-  set_gdbarch_stap_parse_special_token (gdbarch, NULL);
-  set_gdbarch_stap_evaluate_special_token (gdbarch, NULL);
 #if 0
   set_gdbarch_stap_parse_arg (gdbarch, i386_stap_parse_arg);
   set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand);
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index c016581..bdab71c 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -1057,9 +1057,9 @@ static int
 arm_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
 {
   return (*s == '#' /* Literal number.  */
-	  || (*s == '[' && s[1] == 'r') /* Register indirection or
-					   displacement.  */
-	  || *s == 'r'); /* Register value.  */
+	  || *s == '[' /* Register indirection or
+			  displacement.  */
+	  || isalpha (*s)); /* Register value.  */
 }
 
 static int
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index a4bc0a9..a491771 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -913,8 +913,6 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
   set_gdbarch_stap_register_indirection_sufix (gdbarch, ")");
   set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand);
-  set_gdbarch_stap_parse_special_token (gdbarch, NULL);
-  set_gdbarch_stap_evaluate_special_token (gdbarch, NULL);
 #if 0
   set_gdbarch_stap_parse_arg (gdbarch, i386_stap_parse_arg);
   set_gdbarch_stap_is_single_operand (gdbarch, i386_stap_is_single_operand);
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 8677e42..764c345 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1623,7 +1623,7 @@ static int
 ppc_stap_parse_special_token (struct gdbarch *gdbarch,
 			      const char **token)
 {
-  char *s = (char *) *token;
+  const char *s = *token;
 
   /* The special tokens to be parsed here are:
 
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 247532e..5861f3e 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -82,17 +82,32 @@ static struct value *stap_evaluate_probe_argument_2
 
 static int stap_is_operator (char op);
 
-#if 0
-static int
-stap_validate_reg_name (const char **s, const char *reg_prefix)
-{
-  char *n = (char *) *s;
+/* Parse a probe's argument.
 
-  *s = n;
+   Assuming that:
 
-  return 1;
-}
-#endif
+   LP = literal integer prefix
+   LS = literal integer sufix
+
+   RP = register prefix
+   RS = register sufix
+
+   RIP = register indirection prefix
+   RIS = register indirection sufix
+
+   This routine assumes that arguments' tokens are of the form:
+
+   - [LP] NUMBER [LS]
+   - [RP] REGISTER [RS]
+   - [RIP] [RP] REGISTER [RS] [RIS]
+   - If we find a number without LP, we try to parse it as a literal integer
+   constant (if LP == NULL), or as a register displacement.
+   - We count parenthesis, and only skip whitespaces if we are inside them.
+   - If we find an operator, we skip it.
+
+   This function can also call a special function that will try to match
+   unknown tokens.  It will return 1 if the argument has been parsed
+   successfully, or zero otherwise.  */
 
 static int
 stap_parse_arg (const char **arg, struct gdbarch *gdbarch)
@@ -106,20 +121,22 @@ stap_parse_arg (const char **arg, struct gdbarch *gdbarch)
   int handle_special_case = 0;
 
   /* Prefixes for the parser.  */
-  const char *const_prefix = gdbarch_stap_integer_prefix (gdbarch),
-	*reg_prefix = gdbarch_stap_register_prefix (gdbarch),
-	*reg_ind_prefix = gdbarch_stap_register_indirection_prefix (gdbarch);
-  int const_prefix_len = const_prefix ? strlen (const_prefix) : 0,
-      reg_prefix_len = reg_prefix ? strlen (reg_prefix) : 0,
-      reg_ind_prefix_len = reg_ind_prefix ? strlen (reg_ind_prefix) : 0;
+  const char *const_prefix = gdbarch_stap_integer_prefix (gdbarch);
+  const char *reg_prefix = gdbarch_stap_register_prefix (gdbarch);
+  const char *reg_ind_prefix
+    = gdbarch_stap_register_indirection_prefix (gdbarch);
+  int const_prefix_len = const_prefix ? strlen (const_prefix) : 0;
+  int reg_prefix_len = reg_prefix ? strlen (reg_prefix) : 0;
+  int reg_ind_prefix_len = reg_ind_prefix ? strlen (reg_ind_prefix) : 0;
 
   /* Sufixes for the parser.  */
-  const char *const_sufix = gdbarch_stap_integer_sufix (gdbarch),
-	*reg_sufix = gdbarch_stap_register_sufix (gdbarch),
-	*reg_ind_sufix = gdbarch_stap_register_indirection_sufix (gdbarch);
-  int const_sufix_len = const_sufix ? strlen (const_sufix) : 0,
-      reg_sufix_len = reg_sufix ? strlen (reg_sufix) : 0,
-      reg_ind_sufix_len = reg_ind_sufix ? strlen (reg_ind_sufix) : 0;
+  const char *const_sufix = gdbarch_stap_integer_sufix (gdbarch);
+  const char *reg_sufix = gdbarch_stap_register_sufix (gdbarch);
+  const char *reg_ind_sufix
+    = gdbarch_stap_register_indirection_sufix (gdbarch);
+  int const_sufix_len = const_sufix ? strlen (const_sufix) : 0;
+  int reg_sufix_len = reg_sufix ? strlen (reg_sufix) : 0;
+  int reg_ind_sufix_len = reg_ind_sufix ? strlen (reg_ind_sufix) : 0;
 
   while (1)
     {
@@ -327,321 +344,6 @@ stap_parse_arg (const char **arg, struct gdbarch *gdbarch)
   return 1;
 }
 
-#if 0
-/* Helper function which parses a single argument in a probe's argument
-   string, based on various rules (which can be learned from the `gas'
-   manual).  It returns 1 on success, or 0 otherwise.  */
-
-static int
-stap_parse_arg (const char **p, enum stap_asm_arch arch)
-{
-  char *cur = (char *) *p;
-  int done = 0;
-  int paren_open = 0;
-
-  while (!done)
-    {
-      switch (*cur)
-	{
-	case ' ': case 0:
-	  /* If we're here, then we have already parsed everything
-	     from this argument.  */
-	  if (paren_open)
-	    return 0;
-	  done = 1;
-	  break;
-
-	case '(':
-	  ++paren_open;
-	  ++cur;
-	  stap_skip_whitespace_cond (&cur, paren_open);
-	  break;
-
-	case ')':
-	  if (!paren_open)
-	    return 0;
-
-	  --paren_open;
-	  ++cur;
-	  if (paren_open)
-	    cur = skip_spaces (cur);
-	  break;
-
-	case '[':
-	    {
-	      ++cur;
-	      cur = skip_spaces (cur);
-
-	      if (arch == STAP_ASM_IA64)
-		{
-		  /* It can only be an indirection of a register.  */
-		  EXPECT_DIGITS (cur);
-		}
-	      else if (arch == STAP_ASM_ARM)
-		{
-		  EXPECT_DIGITS (cur);
-
-		  if (*cur == ',')
-		    {
-		      /* Register displacement.  */
-		      ++cur;
-		      cur = skip_spaces (cur);
-
-		      EXPECT_CHAR (cur, '#');
-		      EXPECT_DIGITS (cur);
-		    }
-		}
-	      else
-		/* This shouldn't happen on this architecture.  */
-		return 0;
-
-	      EXPECT_CHAR (cur, ']');
-	      stap_skip_whitespace_cond (&cur, paren_open);
-	    }
-	  break;
-
-	case 'i':
-	    {
-	      /* This is an integer constant in PPC.  */
-	      if (arch != STAP_ASM_PPC)
-		return 0;
-
-	      ++cur;
-	      if (!isdigit (*cur))
-		return 0;
-
-	      while (isdigit (*cur))
-		++cur;
-
-	      stap_skip_whitespace_cond (&cur, paren_open);
-	    }
-	  break;
-
-	case '+': case '-':
-	case '*': case '/':
-	case '>': case '<':
-	case '|': case '&':
-	case '^': case '!':
-	    {
-	      char c = *cur;
-
-	      ++cur;
-	      switch (*cur)
-		{
-		case '>':
-		  if (c != '<' && c != '>')
-		    return 0;
-
-		  ++cur;
-		  break;
-
-		case '<':
-		  if (c != '<')
-		    return 0;
-
-		  ++cur;
-		  break;
-
-		case '=':
-		  if (c != '=' && c != '<' && c != '>' && c != '!')
-		    return 0;
-
-		  ++cur;
-		  break;
-
-		case '|':
-		  if (c != '|')
-		    return 0;
-
-		  ++cur;
-		  break;
-
-		case '&':
-		  if (c != '&')
-		    return 0;
-
-		  ++cur;
-		  break;
-
-		default:
-		  break;
-		}
-	      /* Infix operators take two arguments, one on either
-		 side.  Skipping the whitespaces that may happen on the
-		 right side.  */
-	      stap_skip_whitespace_cond (&cur, paren_open);
-	    }
-	  break;
-
-	case '%':
-	    {
-	      ++cur;
-	      stap_skip_whitespace_cond (&cur, paren_open);
-	      if (*cur >= 'a' && *cur <= 'z')
-		{
-		  /* We're dealing with a register name, x86{,_64}.  */
-		  if (arch != STAP_ASM_X86)
-		    return 0;
-
-		  while (isalnum (*cur))
-		    ++cur;
-
-		  stap_skip_whitespace_cond (&cur, paren_open);
-
-		  /* Some registers (e.g. floating-point register stack
-		     registers on Intel i386) have the following syntax:
-
-		     `%st(0)', `%st(1)', and so on.
-
-		     So it's ok to expect parenthesis here.  */
-		  if (*cur == '(')
-		    {
-		      ++cur;
-		      stap_skip_whitespace_cond (&cur, paren_open);
-		      if (!isdigit (*cur))
-			/* This is an error, since we only expect numbers
-			   inside this parenthesis.  */
-			return 0;
-		      ++cur;
-		      stap_skip_whitespace_cond (&cur, paren_open);
-		      /* We only expect one number.  */
-		      EXPECT_CLOSE_PAREN (cur);
-		      stap_skip_whitespace_cond (&cur, paren_open);
-		    }
-		}
-	    }
-	  break;
-
-	case '$':
-	    {
-	      /* This is an integer constant on x86{,_64}.  */
-	      if (arch != STAP_ASM_X86)
-		return 0;
-
-	      ++cur;
-	      while (isdigit (*cur))
-		++cur;
-
-	      stap_skip_whitespace_cond (&cur, paren_open);
-	    }
-	  break;
-
-	case '0': case '1': case '2': case '3': case '4':
-	case '5': case '6': case '7': case '8': case '9':
-	    {
-	      char *tmp = cur;
-
-	      /* We have to do a lookahead here, because we may be looking
-		 at the beginning of the next argument, which would look:
-
-		    [+|-][4|8]@
-
-		 or we could be looking at:
-
-		  - a register name or register displacement in PPC;
-		  - a register displacement in x86{,_64};
-		  - a literal number in IA64 and S390;
-		  - a register indirection or displacement in S390.  */
-	      while (isdigit (*tmp))
-		++tmp;
-
-	      tmp = skip_spaces (tmp);
-
-	      if ((*tmp == '+' || *tmp == '-')
-		  && ((tmp[1] == '4' || tmp[1] == '8') && tmp[2] == '@'))
-		{
-		  cur = tmp;
-		  break;
-		}
-
-	      /* Advance the number, since we won't need it.  */
-	      while (isdigit (*cur))
-		++cur;
-
-	      /* We are not at the end of the argument, so let's find out
-		 what this really is based on the architecture.  */
-	      if (arch == STAP_ASM_X86)
-		{
-		  /* Register displacement.  */
-		  if (*cur != '(' || cur[1] != '%')
-		    return 0;
-
-		  cur += 2;
-
-		  if (*cur <= 'a' || *cur >= 'z')
-		    return 0;
-
-		  while (isalnum (*cur))
-		    ++cur;
-
-		  stap_skip_whitespace_cond (&cur, paren_open);
-
-		  /* Some registers (e.g. floating-point register stack
-		     registers on Intel i386) have the following syntax:
-
-		     `%st(0)', `%st(1)', and so on.
-
-		     So it's ok to expect parenthesis here.  */
-		  if (*cur == '(')
-		    {
-		      ++cur;
-		      stap_skip_whitespace_cond (&cur, paren_open);
-		      if (!isdigit (*cur))
-			/* This is an error, since we only expect numbers
-			   inside this parenthesis.  */
-			return 0;
-		      ++cur;
-		      stap_skip_whitespace_cond (&cur, paren_open);
-		      if (*cur != ')')
-			/* We only expect one number.  */
-			return 0;
-		      ++cur;
-		      stap_skip_whitespace_cond (&cur, paren_open);
-		    }
-
-		  EXPECT_CLOSE_PAREN (cur);
-		}
-	      else if (arch == STAP_ASM_PPC)
-		{
-		  /* Register name or displacement.  */
-		  if (*cur == '(')
-		    {
-		      /* Displacement.  */
-		      ++cur;
-		      if (!isdigit (*cur))
-			return 0;
-
-		      while (isdigit (*cur))
-			++cur;
-
-		      EXPECT_CLOSE_PAREN (cur);
-		    }
-		}
-	      else if (arch == STAP_ASM_S390)
-		{
-		  /* Register indirection or displacement.  */
-		  EXPECT_OPEN_PAREN (cur);
-
-		  if (!isdigit (*cur))
-		    return 0;
-
-		  while (isdigit (*cur))
-		    ++cur;
-
-		  EXPECT_CLOSE_PAREN (cur);
-		}
-	      stap_skip_whitespace_cond (&cur, paren_open);
-	    }
-	  break;
-	}
-    }
-
-  *p = cur;
-
-  return 1;
-}
-#endif
-
 /* Helper function which is responsible for freeing the space allocated to
    hold information about a probe's arguments.  */
 
@@ -662,7 +364,7 @@ stap_free_args_info (void *args_info_ptr)
    the arguments and storing their information in properly ways.  This function
    only separates the arguments, but does not evaluate them.
 
-   Consider the following argument string:
+   Consider the following argument string (x86 syntax):
 
    `4@%eax 4@$10'
 
@@ -780,8 +482,6 @@ stap_parse_probe_arguments (struct stap_probe *probe)
 	      const char *start = cur;
 
 	      if (!stap_parse_arg (&cur, probe->gdbarch))
-//	      if (!gdbarch_stap_parse_arg_p (probe->gdbarch)
-//		  || !gdbarch_stap_parse_arg (probe->gdbarch, &cur))
 		{
 		  /* We have tried to parse this argument, but it's
 		     malformed.  This is an error.  */
@@ -902,16 +602,7 @@ stap_get_opcode (char **s, enum exp_opcode *op)
       break;
 
     case '%':
-      {
-	if (isalpha (**s))
-	  {
-	    /* Dealing with a register name.  */
-	    ret = 0;
-	    break;
-	  }
-
-	*op = BINOP_REM;
-      }
+      *op = BINOP_REM;
     break;
 
     case '<':
@@ -1114,27 +805,25 @@ stap_fetch_reg_value (struct stap_evaluation_info *eval_info,
 		      struct value *displacement)
 {
   const char *start;
-  struct gdbarch *gdbarch = eval_info->gdbarch;


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-09-09 19:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-09 19:03 [SCM] archer-sergiodj-stap-patch-split: Cleanup, comments sergiodj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).