aboutsummaryrefslogtreecommitdiff
path: root/include/dis-asm.h
blob: 51808a84a00815d65524568e8df5168fb5814cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdio.h>
#include "ansidecl.h"
#include "bfd.h"

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;

/* 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).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,
			     disassemble_info *info));

/* GDB--Like memory_error with slightly different parameters.  */
extern void
dis_asm_memory_error
  PARAMS ((int status, bfd_vma memaddr, disassemble_info *info));

#define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \
  (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*));
extern int print_insn_sparc PARAMS ((bfd_vma,disassemble_info*));