From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20970 invoked by alias); 23 Dec 2013 17:18:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20959 invoked by uid 89); 23 Dec 2013 17:18:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 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; Mon, 23 Dec 2013 17:18:29 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBNHIP16030355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Dec 2013 12:18:26 -0500 Received: from psique ([10.3.113.9]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBNHIMEw027636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 23 Dec 2013 12:18:23 -0500 From: Sergio Durigan Junior To: Yufeng Zhang Cc: GDB Patches , Marcus Shawcroft , Tom Tromey Subject: Re: [PATCH v2] Fix for PR tdep/15653: Implement SystemTap SDT probe support for AArch64 References: <52B86A61.1010004@arm.com> X-URL: http://www.redhat.com Date: Mon, 23 Dec 2013 17:18:00 -0000 In-Reply-To: <52B86A61.1010004@arm.com> (Yufeng Zhang's message of "Mon, 23 Dec 2013 16:52:49 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00887.txt.bz2 On Monday, December 23 2013, Yufeng Zhang wrote: > Hi Sergio, Hey Yufeng, > Thanks for the updated patch. It looks OK to me and the only comment > I have is about the '$' character. In A64, only '#' can be the > optional prefix for immediate. I didn't see '$' checked in your > original patch; is there a particular reason that you added support > for '$' in this patch? Thanks a lot. You are right, only '#' is an optional prefix in AArch64. Here's an updated patch. -- Sergio 2013-12-23 Sergio Durigan Junior * NEWS: Mention SystemTap SDT probe support for AArch64 GNU/Linux. * aarch64-linux-tdep.c: Include necessary headers for parsing of SystemTap SDT probes. (aarch64_stap_is_single_operand): New function. (aarch64_stap_parse_special_token): Likewise. (aarch64_linux_init_abi): Declare SystemTap SDT probe argument prefixes and suffixes. Initialize gdbarch with them. diff --git a/gdb/NEWS b/gdb/NEWS index e4baf50..b64967e 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,8 @@ *** Changes since GDB 7.6 +* GDB now supports SystemTap SDT probes on AArch64 GNU/Linux. + * GDB now supports Fission DWP file format version 2. http://gcc.gnu.org/wiki/DebugFission diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index bcfcce2..b828afd 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -35,6 +35,12 @@ #include "regcache.h" #include "regset.h" +#include "cli/cli-utils.h" +#include "stap-probe.h" +#include "parser-defs.h" +#include "user-regs.h" +#include + /* The general-purpose regset consists of 31 X registers, plus SP, PC, and PSTATE registers, as defined in the AArch64 port of the Linux kernel. */ @@ -263,9 +269,126 @@ aarch64_linux_regset_from_core_section (struct gdbarch *gdbarch, return NULL; } +static int +aarch64_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) +{ + return (*s == '#' || isdigit (*s) /* Literal number. */ + || *s == '[' /* Register indirection. */ + || isalpha (*s)); /* Register value. */ +} + +/* This routine is used to parse a special token in AArch64's assembly. + + The special tokens parsed by it are: + + - Register displacement (e.g, [fp, #-8]) + + It returns one if the special token has been parsed successfully, + or zero if the current token is not considered special. */ + +static int +aarch64_stap_parse_special_token (struct gdbarch *gdbarch, + struct stap_parse_info *p) +{ + if (*p->arg == '[') + { + /* Temporary holder for lookahead. */ + const char *tmp = p->arg; + char *endp; + /* Used to save the register name. */ + const char *start; + char *regname; + int len; + int got_minus = 0; + long displacement; + struct stoken str; + + ++tmp; + start = tmp; + + /* Register name. */ + while (isalnum (*tmp)) + ++tmp; + + if (*tmp != ',') + return 0; + + len = tmp - start; + regname = alloca (len + 2); + + strncpy (regname, start, len); + regname[len] = '\0'; + + if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1) + error (_("Invalid register name `%s' on expression `%s'."), + regname, p->saved_arg); + + ++tmp; + tmp = skip_spaces_const (tmp); + /* Now we expect a number. It can begin with '#' or simply + a digit. */ + if (*tmp == '#') + ++tmp; + + if (*tmp == '-') + { + ++tmp; + got_minus = 1; + } + else if (*tmp == '+') + ++tmp; + + if (!isdigit (*tmp)) + return 0; + + displacement = strtol (tmp, &endp, 10); + tmp = endp; + + /* Skipping last `]'. */ + if (*tmp++ != ']') + 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); + if (got_minus) + write_exp_elt_opcode (UNOP_NEG); + + /* The register name. */ + write_exp_elt_opcode (OP_REGISTER); + str.ptr = regname; + str.length = len; + write_exp_string (str); + write_exp_elt_opcode (OP_REGISTER); + + write_exp_elt_opcode (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 (UNOP_IND); + + p->arg = tmp; + } + else + return 0; + + return 1; +} + static void aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { + static const char *const stap_integer_prefixes[] = { "#", "", NULL }; + static const char *const stap_register_prefixes[] = { "", NULL }; + static const char *const stap_register_indirection_prefixes[] = { "[", + NULL }; + static const char *const stap_register_indirection_suffixes[] = { "]", + NULL }; struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); tdep->lowest_pc = 0x8000; @@ -290,6 +413,17 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_regset_from_core_section (gdbarch, aarch64_linux_regset_from_core_section); + + /* SystemTap related. */ + set_gdbarch_stap_integer_prefixes (gdbarch, stap_integer_prefixes); + set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes); + set_gdbarch_stap_register_indirection_prefixes (gdbarch, + stap_register_indirection_prefixes); + set_gdbarch_stap_register_indirection_suffixes (gdbarch, + stap_register_indirection_suffixes); + set_gdbarch_stap_is_single_operand (gdbarch, aarch64_stap_is_single_operand); + set_gdbarch_stap_parse_special_token (gdbarch, + aarch64_stap_parse_special_token); } /* Provide a prototype to silence -Wmissing-prototypes. */