| 1 | #include <stdio.h> |
| 2 | #include "ansidecl.h" |
| 3 | #include "bfd.h" |
| 4 | |
| 5 | typedef int (*fprintf_ftype) PARAMS((FILE*, const char*, ...)); |
| 6 | |
| 7 | typedef struct disassemble_info { |
| 8 | fprintf_ftype fprintf_func; |
| 9 | FILE *stream; |
| 10 | |
| 11 | /* For use by the disassembler. */ |
| 12 | int flags; |
| 13 | PTR private_data; |
| 14 | |
| 15 | /* Function used to get bytes to disassemble. MEMADDR is the |
| 16 | address of the stuff to be disassembled, MYADDR is the address to |
| 17 | put the bytes in, and LENGTH is the number of bytes to read. |
| 18 | INFO is a pointer to this struct. |
| 19 | Returns an errno value or 0 for success. */ |
| 20 | int (*read_memory_func) |
| 21 | PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int length, |
| 22 | struct disassemble_info *info)); |
| 23 | |
| 24 | /* Function which should be called if we get an error that we can't |
| 25 | recover from. STATUS is the errno value from read_memory_func and |
| 26 | MEMADDR is the address that we were trying to read. INFO is a |
| 27 | pointer to this struct. */ |
| 28 | void (*memory_error_func) |
| 29 | PARAMS ((int status, bfd_vma memaddr, struct disassemble_info *info)); |
| 30 | |
| 31 | /* These are for buffer_read_memory. */ |
| 32 | bfd_byte *buffer; |
| 33 | bfd_vma buffer_vma; |
| 34 | int buffer_length; |
| 35 | } disassemble_info; |
| 36 | |
| 37 | /* Here is a function which callers may wish to use for read_memory_func. |
| 38 | It gets bytes from a buffer. */ |
| 39 | extern int buffer_read_memory |
| 40 | PARAMS ((bfd_vma, bfd_byte *, int, struct disassemble_info *)); |
| 41 | |
| 42 | /* This function goes with buffer_read_memory. |
| 43 | It prints a message using info->fprintf_func and info->stream. */ |
| 44 | extern void perror_memory PARAMS ((int, bfd_vma, struct disassemble_info *)); |
| 45 | |
| 46 | #define INIT_DISASSEMBLE_INFO(INFO, STREAM) \ |
| 47 | (INFO).fprintf_func = (fprintf_ftype)fprintf, \ |
| 48 | (INFO).stream = (STREAM), \ |
| 49 | (INFO).buffer = NULL, \ |
| 50 | (INFO).buffer_vma = 0, \ |
| 51 | (INFO).buffer_length = 0, \ |
| 52 | (INFO).read_memory_func = buffer_read_memory, \ |
| 53 | (INFO).memory_error_func = perror_memory |
| 54 | |
| 55 | /* GDB--Like target_read_memory, but slightly different parameters. */ |
| 56 | extern int |
| 57 | dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int len, |
| 58 | disassemble_info *info)); |
| 59 | |
| 60 | /* GDB--Like memory_error with slightly different parameters. */ |
| 61 | extern void |
| 62 | dis_asm_memory_error |
| 63 | PARAMS ((int status, bfd_vma memaddr, disassemble_info *info)); |
| 64 | |
| 65 | #define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \ |
| 66 | (INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \ |
| 67 | (INFO).stream = (STREAM), \ |
| 68 | (INFO).read_memory_func = dis_asm_read_memory, \ |
| 69 | (INFO).memory_error_func = dis_asm_memory_error |
| 70 | |
| 71 | |
| 72 | /* Standard disassemblers. Disassemble one instruction at the given |
| 73 | target address. Return number of bytes processed. */ |
| 74 | typedef int (*disassembler_ftype) |
| 75 | PARAMS((bfd_vma, disassemble_info *)); |
| 76 | |
| 77 | extern int print_insn_big_mips PARAMS ((bfd_vma, disassemble_info*)); |
| 78 | extern int print_insn_little_mips PARAMS ((bfd_vma,disassemble_info*)); |
| 79 | extern int print_insn_i386 PARAMS ((bfd_vma,disassemble_info*)); |
| 80 | extern int print_insn_m68k PARAMS ((bfd_vma,disassemble_info*)); |
| 81 | extern int print_insn_z8001 PARAMS ((bfd_vma,disassemble_info*)); |
| 82 | extern int print_insn_z8002 PARAMS ((bfd_vma,disassemble_info*)); |
| 83 | extern int print_insn_h8500 PARAMS ((bfd_vma,disassemble_info*)); |
| 84 | extern int print_insn_sparc PARAMS ((bfd_vma,disassemble_info*)); |