forked from Imagelibrary/binutils-gdb
gdb: make gdbarch_displaced_step_copy_insn return an std::unique_ptr
This callback dynamically allocates a specialized displaced_step_closure, and gives the ownership of the object to its caller. So I think it would make sense for the callback to return an std::unique_ptr, this is what this patch implements. gdb/ChangeLog: * gdbarch.sh (displaced_step_copy_insn): Change return type to an std::unique_ptr. * gdbarch.c: Re-generate. * gdbarch.h: Re-generate. * infrun.c (displaced_step_prepare_throw): Adjust to std::unique_ptr change. * aarch64-tdep.c (aarch64_displaced_step_copy_insn): Change return type to std::unique_ptr. * aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise. * amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise. * amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. * i386-tdep.h (i386_displaced_step_copy_insn): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. * s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
This commit is contained in:
@@ -1465,7 +1465,7 @@ fixup_displaced_copy (struct gdbarch *gdbarch,
|
||||
}
|
||||
}
|
||||
|
||||
struct displaced_step_closure *
|
||||
std::unique_ptr<displaced_step_closure>
|
||||
amd64_displaced_step_copy_insn (struct gdbarch *gdbarch,
|
||||
CORE_ADDR from, CORE_ADDR to,
|
||||
struct regcache *regs)
|
||||
@@ -1474,8 +1474,8 @@ amd64_displaced_step_copy_insn (struct gdbarch *gdbarch,
|
||||
/* Extra space for sentinels so fixup_{riprel,displaced_copy} don't have to
|
||||
continually watch for running off the end of the buffer. */
|
||||
int fixup_sentinel_space = len;
|
||||
amd64_displaced_step_closure *dsc
|
||||
= new amd64_displaced_step_closure (len + fixup_sentinel_space);
|
||||
std::unique_ptr<amd64_displaced_step_closure> dsc
|
||||
(new amd64_displaced_step_closure (len + fixup_sentinel_space));
|
||||
gdb_byte *buf = &dsc->insn_buf[0];
|
||||
struct amd64_insn *details = &dsc->insn_details;
|
||||
|
||||
@@ -1500,7 +1500,7 @@ amd64_displaced_step_copy_insn (struct gdbarch *gdbarch,
|
||||
|
||||
/* Modify the insn to cope with the address where it will be executed from.
|
||||
In particular, handle any rip-relative addressing. */
|
||||
fixup_displaced_copy (gdbarch, dsc, from, to, regs);
|
||||
fixup_displaced_copy (gdbarch, dsc.get (), from, to, regs);
|
||||
|
||||
write_memory (to, buf, len);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user