diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-03-31 21:43:25 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1993-03-31 21:43:25 +0000 |
commit | 5d0734a7d74cf01b73303aeb884b719b4b220035 (patch) | |
tree | f24aaaf513a030c64dd9b0dae5ddb405a1c214f3 /include/dis-asm.h | |
parent | 79337c85b8e706bd247a99d26a237f6dddf4ffe5 (diff) | |
download | gdb-5d0734a7d74cf01b73303aeb884b719b4b220035.zip gdb-5d0734a7d74cf01b73303aeb884b719b4b220035.tar.gz gdb-5d0734a7d74cf01b73303aeb884b719b4b220035.tar.bz2 |
provide a new interface (using read_memory_func) to call the disassemblers
which copes with errors in a plausible way
Diffstat (limited to 'include/dis-asm.h')
-rw-r--r-- | include/dis-asm.h | 82 |
1 files changed, 66 insertions, 16 deletions
diff --git a/include/dis-asm.h b/include/dis-asm.h index d229924..da13bf7 100644 --- a/include/dis-asm.h +++ b/include/dis-asm.h @@ -7,26 +7,76 @@ typedef int (*fprintf_ftype) PARAMS((FILE*, const char*, ...)); typedef struct disassemble_info { fprintf_ftype fprintf_func; FILE *stream; + + /* For use by the disassembler. */ int flags; + PTR private_data; + + /* Function used to get bytes to disassemble. MEMADDR is the + address of the stuff to be disassembled, MYADDR is the address to + put the bytes in, and LENGTH is the number of bytes to read. + INFO is a pointer to this struct. + Returns an errno value or 0 for success. */ + int (*read_memory_func) + PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int length, + struct disassemble_info *info)); + + /* Function which should be called if we get an error that we can't + recover from. STATUS is the errno value from read_memory_func and + MEMADDR is the address that we were trying to read. INFO is a + pointer to this struct. */ + void (*memory_error_func) + PARAMS ((int status, bfd_vma memaddr, struct disassemble_info *info)); + + /* These are for buffer_read_memory. */ + bfd_byte *buffer; + bfd_vma buffer_vma; + int buffer_length; } disassemble_info; -typedef int (*disassembler_ftype) - PARAMS((bfd_vma, bfd_byte *, disassemble_info *)); +/* Here is a function which callers may wish to use for read_memory_func. + It gets bytes from a buffer. */ +extern int buffer_read_memory + PARAMS ((bfd_vma, bfd_byte *, int, struct disassemble_info *)); + +/* This function goes with buffer_read_memory. + It prints a message using info->fprintf_func and info->stream. */ +extern void perror_memory PARAMS ((int, bfd_vma, struct disassemble_info *)); #define INIT_DISASSEMBLE_INFO(INFO, STREAM) \ - INFO.fprintf_func = (fprintf_ftype)fprintf, \ - INFO.stream = (STREAM) + (INFO).fprintf_func = (fprintf_ftype)fprintf, \ + (INFO).stream = (STREAM), \ + (INFO).buffer = NULL, \ + (INFO).buffer_vma = 0, \ + (INFO).buffer_length = 0, \ + (INFO).read_memory_func = buffer_read_memory, \ + (INFO).memory_error_func = perror_memory + +/* GDB--Like target_read_memory, but slightly different parameters. */ +extern int +dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int len)); + +/* GDB--Like memory_error with slightly different parameters. */ +extern void +dis_asm_memory_error + PARAMS ((int status, bfd_vma memaddr, disassembler_info *info)); #define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \ - INFO.fprintf_func = (fprintf_ftype)fprintf_filtered, \ - INFO.stream = (STREAM) - -/* Standard dis-assemblers. */ - -extern int print_insn_big_mips PARAMS ((bfd_vma, bfd_byte*,disassemble_info*)); -extern int print_insn_little_mips - PARAMS ((bfd_vma,bfd_byte*,disassemble_info*)); -extern int print_insn_i386 PARAMS ((bfd_vma,bfd_byte*,disassemble_info*)); -extern int print_insn_m68k PARAMS ((bfd_vma,bfd_byte*,disassemble_info*)); -extern int print_insn_z8001 PARAMS ((bfd_vma,bfd_byte*,disassemble_info*)); -extern int print_insn_z8002 PARAMS ((bfd_vma,bfd_byte*,disassemble_info*)); + (INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \ + (INFO).stream = (STREAM), \ + (INFO).read_memory_func = dis_asm_read_memory, \ + (INFO).memory_error_func = dis_asm_memory_error + + +/* Standard disassemblers. Disassemble one instruction at the given + target address. Return number of bytes processed. */ +typedef int (*disassembler_ftype) + PARAMS((bfd_vma, disassemble_info *)); + +extern int print_insn_big_mips PARAMS ((bfd_vma, disassemble_info*)); +extern int print_insn_little_mips PARAMS ((bfd_vma,disassemble_info*)); +extern int print_insn_i386 PARAMS ((bfd_vma,disassemble_info*)); +extern int print_insn_m68k PARAMS ((bfd_vma,disassemble_info*)); +extern int print_insn_z8001 PARAMS ((bfd_vma,disassemble_info*)); +extern int print_insn_z8002 PARAMS ((bfd_vma,disassemble_info*)); +extern int print_insn_h8500 PARAMS ((bfd_vma,disassemble_info*)); |