#include "defs.h"
#include "stap-probe.h"
#include "probe.h"
-#include "common/vec.h"
+#include "gdbsupport/vec.h"
#include "ui-out.h"
#include "objfiles.h"
#include "arch-utils.h"
regname += gdb_reg_suffix;
}
+ int regnum = user_reg_map_name_to_regnum (gdbarch, regname.c_str (),
+ regname.size ());
+
/* Is this a valid register name? */
- if (user_reg_map_name_to_regnum (gdbarch,
- regname.c_str (),
- regname.size ()) == -1)
+ if (regnum == -1)
error (_("Invalid register name `%s' on expression `%s'."),
regname.c_str (), p->saved_arg);
+ /* Check if there's any special treatment that the arch-specific
+ code would like to perform on the register name. */
+ if (gdbarch_stap_adjust_register_p (gdbarch))
+ {
+ std::string newregname
+ = gdbarch_stap_adjust_register (gdbarch, p, regname, regnum);
+
+ if (regname != newregname)
+ {
+ /* This is just a check we perform to make sure that the
+ arch-dependent code has provided us with a valid
+ register name. */
+ regnum = user_reg_map_name_to_regnum (gdbarch, newregname.c_str (),
+ newregname.size ());
+
+ if (regnum == -1)
+ internal_error (__FILE__, __LINE__,
+ _("Invalid register name '%s' after replacing it"
+ " (previous name was '%s')"),
+ newregname.c_str (), regname.c_str ());
+
+ regname = newregname;
+ }
+ }
+
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
str.ptr = regname.c_str ();
str.length = regname.size ();