Re: [patch v7 03/24] gdbarch: add instruction predicate methods

Pedro Alves
2013-12-11T12:16:08Z

On 11/29/2013 02:37 PM, Markus Metzger wrote:
> Add new methods to gdbarch for analyzing the instruction at a given address.
> Implement those methods for i386 and amd64 architectures.

"This is needed because <fill me in>."

>
> 2013-11-29 Markus Metzger <markus.t.metzger@intel.com>
>
> * amd64-tdep.c (amd64_classify_insn_at, amd64_insn_is_call,
> amd64_insn_is_ret, amd64_insn_is_jump, amd64_jmp_p): New.
> (amd64_init_abi): Add insn_is_call, insn_is_ret, and insn_is_jump
> to gdbarch.
> * i386-tdep.c (i386_insn_is_call, i386_insn_is_ret,
> i386_insn_is_jump, i386_jmp_p): New.
> (i386_gdbarch_init): Add insn_is_call, insn_is_ret, and
> insn_is_jump to gdbarch.
> * gdbarch.sh (insn_is_call, insn_is_ret, insn_is_jump): New.
> * gdbarch.h: Regenerated.
> * gdbarch.c: Regenerated.
> * arch-utils.h (default_insn_is_call, default_insn_is_ret,
> default_insn_is_jump): New.
> * arch-utils.c (default_insn_is_call, default_insn_is_ret,
> default_insn_is_jump): New.
>

> +/* Classify the instruction at ADDR using PRED.
> + Throw an error if the memory can't be read. */
> +
> +static int
> +amd64_classify_insn_at (struct gdbarch *gdbarch, CORE_ADDR addr,
> + int (*pred) (const struct amd64_insn *))
> +{
> + struct amd64_insn details;
> + gdb_byte *buf;
> + int len, classification;
> +
> + len = gdbarch_max_insn_length (gdbarch);
> + buf = alloca (len);
> +
> + read_memory (addr, buf, len);

This can be read_code now.

--
Pedro Alves