summaryrefslogtreecommitdiff
path: root/gdb/amd64-tdep.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2010-05-06 00:21:53 +0000
committerPedro Alves <pedro@codesourcery.com>2010-05-06 00:21:53 +0000
commit4927abba2122a98402fef9f6b7b830704eca787b (patch)
treec0982d16f8b18f3415f9d2111c8a463c13d60e45 /gdb/amd64-tdep.c
parent165b53e016058e4e6ed08e8f6e3f1d62d45a9f85 (diff)
downloadgdb-4927abba2122a98402fef9f6b7b830704eca787b.tar.gz
* amd64-tdep.c: Include disasm.h.
(amd64_insn_length_fprintf, amd64_insn_length_init_dis) (amd64_insn_length): Moved to disasm.c and renamed. (fixup_riprel): Adjust. * disasm.c (do_ui_file_delete): New. (gdb_insn_length): New. (gdb_buffered_insn_length_fprintf) (gdb_buffered_insn_length_init_dis) (gdb_buffered_insn_length): New, moved from amd64-tdep.c, and renamed. * disasm.h (gdb_insn_length): Declare. (gdb_buffered_insn_length): Declare.
Diffstat (limited to 'gdb/amd64-tdep.c')
-rw-r--r--gdb/amd64-tdep.c56
1 files changed, 3 insertions, 53 deletions
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 21d66c5ac55..6336b7a5365 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -36,7 +36,7 @@
#include "regcache.h"
#include "regset.h"
#include "symfile.h"
-
+#include "disasm.h"
#include "gdb_assert.h"
#include "amd64-tdep.h"
@@ -1022,57 +1022,6 @@ amd64_skip_prefixes (gdb_byte *insn)
return insn;
}
-/* fprintf-function for amd64_insn_length.
- This function is a nop, we don't want to print anything, we just want to
- compute the length of the insn. */
-
-static int ATTRIBUTE_PRINTF (2, 3)
-amd64_insn_length_fprintf (void *stream, const char *format, ...)
-{
- return 0;
-}
-
-/* Initialize a struct disassemble_info for amd64_insn_length. */
-
-static void
-amd64_insn_length_init_dis (struct gdbarch *gdbarch,
- struct disassemble_info *di,
- const gdb_byte *insn, int max_len,
- CORE_ADDR addr)
-{
- init_disassemble_info (di, NULL, amd64_insn_length_fprintf);
-
- /* init_disassemble_info installs buffer_read_memory, etc.
- so we don't need to do that here.
- The cast is necessary until disassemble_info is const-ified. */
- di->buffer = (gdb_byte *) insn;
- di->buffer_length = max_len;
- di->buffer_vma = addr;
-
- di->arch = gdbarch_bfd_arch_info (gdbarch)->arch;
- di->mach = gdbarch_bfd_arch_info (gdbarch)->mach;
- di->endian = gdbarch_byte_order (gdbarch);
- di->endian_code = gdbarch_byte_order_for_code (gdbarch);
-
- disassemble_init_for_target (di);
-}
-
-/* Return the length in bytes of INSN.
- MAX_LEN is the size of the buffer containing INSN.
- libopcodes currently doesn't export a utility to compute the
- instruction length, so use the disassembler until then. */
-
-static int
-amd64_insn_length (struct gdbarch *gdbarch,
- const gdb_byte *insn, int max_len, CORE_ADDR addr)
-{
- struct disassemble_info di;
-
- amd64_insn_length_init_dis (gdbarch, &di, insn, max_len, addr);
-
- return gdbarch_print_insn (gdbarch, addr, &di);
-}
-
/* Return an integer register (other than RSP) that is unused as an input
operand in INSN.
In order to not require adding a rex prefix if the insn doesn't already
@@ -1238,7 +1187,8 @@ fixup_riprel (struct gdbarch *gdbarch, struct displaced_step_closure *dsc,
/* Compute the rip-relative address. */
disp = extract_signed_integer (insn, sizeof (int32_t), byte_order);
- insn_length = amd64_insn_length (gdbarch, dsc->insn_buf, dsc->max_len, from);
+ insn_length = gdb_buffered_insn_length (gdbarch, dsc->insn_buf,
+ dsc->max_len, from);
rip_base = from + insn_length;
/* We need a register to hold the address.