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: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH 2/2] Extend recognized types of SDT probe's arguments
Date: Thu, 01 May 2014 21:52:00 -0000	[thread overview]
Message-ID: <1398981131-11720-3-git-send-email-sergiodj@redhat.com> (raw)
In-Reply-To: <1398981131-11720-1-git-send-email-sergiodj@redhat.com>

This commit is actually an update to make the parser in
gdb/stap-probe.c be aware of all the possible prefixes that a probe
argument can have.  According to the section "Argument Format" in:

  <https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation>

The bitness of the arguments can be 8, 16, 32 or 64 bits, signed or
unsigned.  Currently GDB recognizes only 32 and 64-bit arguments.
This commit extends this.  Since this is a straightforward extension,
I am not submitting a testcase; I can do that if anybody wants.

gdb/
2014-05-01  Sergio Durigan Junior  <sergiodj@redhat.com>

	stap-probe.c (enum stap_arg_bitness): New enums to represent 8
	and 16-bit signed and unsigned arguments.
	(stap_parse_probe_arguments): Extend code to handle such
	arguments.
---
 gdb/stap-probe.c | 62 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 48 insertions(+), 14 deletions(-)

diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index ef45495..bc7f54a 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -68,6 +68,10 @@ static unsigned int stap_expression_debug = 0;
 enum stap_arg_bitness
 {
   STAP_ARG_BITNESS_UNDEFINED,
+  STAP_ARG_BITNESS_8BIT_UNSIGNED,
+  STAP_ARG_BITNESS_8BIT_SIGNED,
+  STAP_ARG_BITNESS_16BIT_UNSIGNED,
+  STAP_ARG_BITNESS_16BIT_SIGNED,
   STAP_ARG_BITNESS_32BIT_UNSIGNED,
   STAP_ARG_BITNESS_32BIT_SIGNED,
   STAP_ARG_BITNESS_64BIT_UNSIGNED,
@@ -329,6 +333,18 @@ stap_get_expected_argument_type (struct gdbarch *gdbarch,
       else
 	return builtin_type (gdbarch)->builtin_uint64;
 
+    case STAP_ARG_BITNESS_8BIT_UNSIGNED:
+      return builtin_type (gdbarch)->builtin_uint8;
+
+    case STAP_ARG_BITNESS_8BIT_SIGNED:
+      return builtin_type (gdbarch)->builtin_int8;
+
+    case STAP_ARG_BITNESS_16BIT_UNSIGNED:
+      return builtin_type (gdbarch)->builtin_uint16;
+
+    case STAP_ARG_BITNESS_16BIT_SIGNED:
+      return builtin_type (gdbarch)->builtin_int16;
+
     case STAP_ARG_BITNESS_32BIT_SIGNED:
       return builtin_type (gdbarch)->builtin_int32;
 
@@ -1095,7 +1111,7 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch)
 
 	 N@OP
 
-	 Where `N' can be [+,-][4,8].  This is not mandatory, so
+	 Where `N' can be [+,-][1,2,4,8].  This is not mandatory, so
 	 we check it here.  If we don't find it, go to the next
 	 state.  */
       if ((cur[0] == '-' && isdigit (cur[1]) && cur[2] == '@')
@@ -1108,20 +1124,38 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch)
 	      got_minus = 1;
 	    }
 
-	  if (*cur == '4')
-	    b = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
-		 : STAP_ARG_BITNESS_32BIT_UNSIGNED);
-	  else if (*cur == '8')
-	    b = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
-		 : STAP_ARG_BITNESS_64BIT_UNSIGNED);
-	  else
+	  /* Defining the bitness.  */
+	  switch (*cur)
 	    {
-	      /* We have an error, because we don't expect anything
-		 except 4 and 8.  */
-	      complaint (&symfile_complaints,
-			 _("unrecognized bitness `%c' for probe `%s'"),
-			 *cur, probe->p.name);
-	      return;
+	    case '1':
+	      b = (got_minus ? STAP_ARG_BITNESS_8BIT_SIGNED
+		   : STAP_ARG_BITNESS_8BIT_UNSIGNED);
+	      break;
+
+	    case '2':
+	      b = (got_minus ? STAP_ARG_BITNESS_16BIT_SIGNED
+		   : STAP_ARG_BITNESS_16BIT_UNSIGNED);
+	      break;
+
+	    case '4':
+	      b = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
+		   : STAP_ARG_BITNESS_32BIT_UNSIGNED);
+	      break;
+
+	    case '8':
+	      b = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
+		   : STAP_ARG_BITNESS_64BIT_UNSIGNED);
+	      break;
+
+	    default:
+	      {
+		/* We have an error, because we don't expect anything
+		   except 4 and 8.  */
+		complaint (&symfile_complaints,
+			   _("unrecognized bitness `%c' for probe `%s'"),
+			   *cur, probe->p.name);
+		return;
+	      }
 	    }
 
 	  arg.bitness = b;
-- 
1.7.11.7


  parent reply	other threads:[~2014-05-01 21:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-01 21:52 [PATCH 0/2] Fix a bug and extend SDT probe parser Sergio Durigan Junior
2014-05-01 21:52 ` [PATCH 1/2] Fix PR breakpoints/16889: gdb segfaults when printing ASM SDT arguments Sergio Durigan Junior
2014-05-02  9:44   ` Pedro Alves
2014-05-02 16:14     ` Sergio Durigan Junior
2014-05-02 18:06       ` Sergio Durigan Junior
2014-05-02 18:56         ` Pedro Alves
2014-05-02 20:57           ` Sergio Durigan Junior
2014-05-01 21:52 ` Sergio Durigan Junior [this message]
2014-05-02  9:49   ` [PATCH 2/2] Extend recognized types of SDT probe's arguments Pedro Alves
2014-05-02 19:25     ` Sergio Durigan Junior
2014-05-02 19:36       ` Pedro Alves
2014-05-02 20:57         ` Sergio Durigan Junior

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=1398981131-11720-3-git-send-email-sergiodj@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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