2 /*--------------------------------------------------------------------*/
3 /*--- begin guest_generic_bb_to_IR.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2004-2017 OpenWorks LLP
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
28 Neither the names of the U.S. Department of Energy nor the
29 University of California nor the names of its contributors may be
30 used to endorse or promote products derived from this software
31 without prior written permission.
34 #ifndef __VEX_GUEST_GENERIC_BB_TO_IR_H
35 #define __VEX_GUEST_GENERIC_BB_TO_IR_H
37 #include "libvex_basictypes.h"
38 #include "libvex_ir.h" // IRJumpKind
39 #include "libvex.h" // VexArch
41 /* This defines stuff needed by the guest insn disassemblers.
42 It's a bit circular; is imported by
43 - the guest-specific toIR.c files (guest-{x86,amd64,ppc,arm}/toIR.c)
44 - the generic disassembly driver (bb_to_IR.c)
49 /* ---------------------------------------------------------------
50 Result of disassembling an instruction
51 --------------------------------------------------------------- */
53 /* The results of disassembling an instruction. There are three possible
54 outcomes. For Dis_StopHere, the disassembler _must_ terminate the BB. For
55 Dis_Continue, we may at our option either disassemble the next insn, or
56 terminate the BB; but in the latter case we must set the bb's ->next field
57 to point to the next instruction. */
63 /* The disassembled insn has this length. Must always be
68 Dis_StopHere: this insn terminates the BB; we must stop.
69 Dis_Continue: we can optionally continue into the next insn
71 enum { Dis_StopHere
=0x10, Dis_Continue
} whatNext
;
73 /* Any other hints that we should feed back to the disassembler?
75 Dis_HintVerbose: this insn potentially generates a lot of code
77 enum { Dis_HintNone
=0x20, Dis_HintVerbose
} hint
;
79 /* For whatNext==Dis_StopHere, we need to end the block and create a
80 transfer to whatever the NIA is. That will have presumably
81 been set by the IR generated for this insn. So we need to
82 know the jump kind to use. Should Ijk_INVALID in other Dis_
84 IRJumpKind jk_StopHere
;
91 /* ---------------------------------------------------------------
92 The type of a function which disassembles one instruction.
93 --------------------------------------------------------------- */
95 /* A function of this type (DisOneInstrFn) disassembles an instruction
96 located at host address &guest_code[delta], whose guest IP is
97 guest_IP (this may be entirely unrelated to where the insn is
98 actually located in the host's address space.). The returned
99 DisResult.len field carries its size.
101 The resulting IR is added to the end of irsb.
106 DisResult (*DisOneInstrFn
) (
108 /* This is the IRSB to which the resulting IR is to be appended. */
111 /* Where is the guest code? */
112 /*IN*/ const UChar
* guest_code
,
114 /* Where is the actual insn? Note: it's at &guest_code[delta] */
117 /* What is the guest IP of the insn? */
118 /*IN*/ Addr guest_IP
,
120 /* Info about the guest architecture */
121 /*IN*/ VexArch guest_arch
,
122 /*IN*/ const VexArchInfo
* archinfo
,
124 /* ABI info for both guest and host */
125 /*IN*/ const VexAbiInfo
* abiinfo
,
127 /* The endianness of the host */
128 /*IN*/ VexEndness host_endness
,
130 /* Should diagnostics be printed for illegal instructions? */
131 /*IN*/ Bool sigill_diag
136 /* ---------------------------------------------------------------
137 Top-level BB to IR conversion fn.
138 --------------------------------------------------------------- */
140 /* See detailed comment in guest_generic_bb_to_IR.c. */
143 /*OUT*/VexGuestExtents
* vge
,
144 /*OUT*/UInt
* n_sc_extents
,
145 /*OUT*/UInt
* n_guest_instrs
, /* stats only */
146 /*OUT*/UShort
* n_uncond_in_trace
, /* stats only */
147 /*OUT*/UShort
* n_cond_in_trace
, /* stats only */
148 /*MOD*/VexRegisterUpdates
* pxControl
,
149 /*IN*/ void* callback_opaque
,
150 /*IN*/ DisOneInstrFn dis_instr_fn
,
151 /*IN*/ const UChar
* guest_code
,
152 /*IN*/ Addr guest_IP_bbstart
,
153 /*IN*/ Bool (*chase_into_ok
)(void*,Addr
),
154 /*IN*/ VexEndness host_endness
,
155 /*IN*/ Bool sigill_diag
,
156 /*IN*/ VexArch arch_guest
,
157 /*IN*/ const VexArchInfo
* archinfo_guest
,
158 /*IN*/ const VexAbiInfo
* abiinfo_both
,
159 /*IN*/ IRType guest_word_type
,
160 /*IN*/ UInt (*needs_self_check
)
161 (void*, /*MB_MOD*/VexRegisterUpdates
*,
162 const VexGuestExtents
*),
163 /*IN*/ Bool (*preamble_function
)(void*,IRSB
*),
164 /*IN*/ Int offB_GUEST_CMSTART
,
165 /*IN*/ Int offB_GUEST_CMLEN
,
166 /*IN*/ Int offB_GUEST_IP
,
167 /*IN*/ Int szB_GUEST_IP
171 #endif /* ndef __VEX_GUEST_GENERIC_BB_TO_IR_H */
173 /*--------------------------------------------------------------------*/
174 /*--- end guest_generic_bb_to_IR.h ---*/
175 /*--------------------------------------------------------------------*/