From 6b78c3f83c8bcbfa714aab7627ece9673b2d602a Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 2 Jul 2019 12:06:06 +0100 Subject: gdb: Remove a non-const reference parameter Non-const reference parameter should be avoided according to the GDB coding standard: https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Avoid_non-const_reference_parameters.2C_use_pointers_instead This commit updates the gdbarch method gdbarch_stap_adjust_register, and the one implementation i386_stap_adjust_register to avoid using a non-const reference parameter. I've also removed the kfail from the testsuite for bug 24541, as this issue is now resolved. gdb/ChangeLog: PR breakpoints/24541 * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh: Adjust return type and parameter types for 'stap_adjust_register'. (i386_stap_adjust_register): Adjust signature and return new register name. * stap-probe.c (stap_parse_register_operand): Adjust use of 'gdbarch_stap_adjust_register'. gdb/testsuite/ChangeLog: PR breakpoints/24541 * gdb.mi/mi-catch-cpp-exceptions.exp: Remove kfail due to 24541. --- gdb/i386-tdep.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'gdb/i386-tdep.c') diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index aac9baa0..ccec6d1 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -4389,27 +4389,24 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch, /* Implementation of 'gdbarch_stap_adjust_register', as defined in gdbarch.h. */ -static void +static std::string i386_stap_adjust_register (struct gdbarch *gdbarch, struct stap_parse_info *p, - std::string ®name, int regnum) + const std::string ®name, int regnum) { static const std::unordered_set reg_assoc = { "ax", "bx", "cx", "dx", "si", "di", "bp", "sp" }; - if (register_size (gdbarch, regnum) >= TYPE_LENGTH (p->arg_type)) - { - /* If we're dealing with a register whose size is greater or - equal than the size specified by the "[-]N@" prefix, then we - don't need to do anything. */ - return; - } + /* If we are dealing with a register whose size is less than the size + specified by the "[-]N@" prefix, and it is one of the registers that + we know has an extended variant available, then use the extended + version of the register instead. */ + if (register_size (gdbarch, regnum) < TYPE_LENGTH (p->arg_type) + && reg_assoc.find (regname) != reg_assoc.end ()) + return "e" + regname; - if (reg_assoc.find (regname) != reg_assoc.end ()) - { - /* Use the extended version of the register. */ - regname = "e" + regname; - } + /* Otherwise, just use the requested register. */ + return regname; } -- cgit v1.1