static int ppc_stap_parse_special_token (struct gdbarch *gdbarch, struct stap_parse_info *p) { if (isdigit (*p->arg)) { /* This temporary pointer is needed because we have to do a lookahead. We could be dealing with a register displacement, and in such case we would not need to do anything. */ const char *s = p->arg; char *regname; int len; struct stoken str; while (isdigit (*s)) ++s; if (*s == '(') { /* It is a register displacement indeed. Returning 0 means we are deferring the treatment of this case to the generic parser. */ return 0; } len = s - p->arg; regname = alloca (len + 2); regname[0] = 'r'; strncpy (regname + 1, p->arg, len); ++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); write_exp_elt_opcode (&p->pstate, OP_REGISTER); str.ptr = regname; str.length = len; write_exp_string (&p->pstate, str); write_exp_elt_opcode (&p->pstate, OP_REGISTER); p->arg = s; } else { /* All the other tokens should be handled correctly by the generic parser. */ return 0; } return 1; }
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 = (char *) 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 (&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 (&p->pstate, UNOP_NEG); /* The register name. */ write_exp_elt_opcode (&p->pstate, OP_REGISTER); str.ptr = regname; str.length = len; write_exp_string (&p->pstate, str); write_exp_elt_opcode (&p->pstate, OP_REGISTER); write_exp_elt_opcode (&p->pstate, BINOP_ADD); /* Casting to the expected type. */ 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 (&p->pstate, UNOP_IND); p->arg = tmp; } else return 0; return 1; }
static int arm_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, offset; 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); offset = 0; if (isdigit (*start)) { /* If we are dealing with a register whose name begins with a digit, it means we should prefix the name with the letter `r', because GDB expects this name pattern. Otherwise (e.g., we are dealing with the register `fp'), we don't need to add such a prefix. */ regname[0] = 'r'; offset = 1; } strncpy (regname + offset, start, len); len += offset; 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); if (*tmp++ != '#') return 0; if (*tmp == '-') { ++tmp; got_minus = 1; } 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; }