From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19479 invoked by alias); 19 Dec 2013 22:20:27 -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 19468 invoked by uid 89); 19 Dec 2013 22:20:26 -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; Thu, 19 Dec 2013 22:20:24 +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 rBJMKK5T005633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 19 Dec 2013 17:20:20 -0500 Received: from psique (ovpn-113-148.phx2.redhat.com [10.3.113.148]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBJMKGtw025116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 19 Dec 2013 17:20:18 -0500 From: Sergio Durigan Junior To: GDB Patches Cc: Marcus Shawcroft , Tom Tromey Subject: [PATCH v2] Fix for PR tdep/15653: Implement SystemTap SDT probe support for AArch64 X-URL: http://www.redhat.com Date: Thu, 19 Dec 2013 22:20:00 -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/msg00812.txt.bz2 Hi, This is the second attempt to implement SystemTap SDT probe support for AArch64 GNU/Linux targets. You can see the first attempt here: After my last patch for the SystemTap SDT API, which extends it in order to accept multiple prefixes and suffixes, this patch became simpler. I also followed Marcus suggestion and did not shared code between 32- and 64-bit ARM. Tom asked me in a previous message how I did my tests. I believe I replied that, but just in case: I ran the tests on gdb.base/stap-probe.exp by hand. As I write this message, I'm working on getting a way to run the full testsuite. Will update this thread if/when I succeed. I'd like to apply this before Joel creates the 7.7 branch. Let's see :-). OK to apply? Thanks, -- Sergio 2013-12-19 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..d2e3ee0 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 == '#' || *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 != '$' && !isdigit (*tmp)) + return 0; + + if (*tmp == '#' || *tmp == '$') + ++tmp; + + if (*tmp == '-') + { + ++tmp; + got_minus = 1; + } + else if (*tmp == '+') + ++tmp; + + 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. */