blob: 61e7e8c98ece0351aea650f848046c8778a7711e [file] [log] [blame]
Jeff Browned07e002011-02-03 17:46:23 -08001
2/*--------------------------------------------------------------------*/
3/*--- The translation table and cache. ---*/
4/*--- pub_core_transtab.h ---*/
5/*--------------------------------------------------------------------*/
6
7/*
8 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
10
Ben Cheng663860b2013-01-31 15:38:14 -080011 Copyright (C) 2000-2012 Julian Seward
Jeff Browned07e002011-02-03 17:46:23 -080012 jseward@acm.org
13
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
28
29 The GNU General Public License is contained in the file COPYING.
30*/
31
32#ifndef __PUB_CORE_TRANSTAB_H
33#define __PUB_CORE_TRANSTAB_H
34
35//--------------------------------------------------------------------
36// PURPOSE: This module is responsible for caching translations, and
37// enabling fast look-ups of them.
38//--------------------------------------------------------------------
39
40#include "pub_core_transtab_asm.h"
41
Ben Cheng663860b2013-01-31 15:38:14 -080042/* The fast-cache for tt-lookup. Unused entries are denoted by .guest
43 == 1, which is assumed to be a bogus address for all guest code. */
Jeff Browned07e002011-02-03 17:46:23 -080044typedef
45 struct {
46 Addr guest;
47 Addr host;
48 }
49 FastCacheEntry;
50
51extern __attribute__((aligned(16)))
52 FastCacheEntry VG_(tt_fast) [VG_TT_FAST_SIZE];
53
54#define TRANSTAB_BOGUS_GUEST_ADDR ((Addr)1)
55
Jeff Browned07e002011-02-03 17:46:23 -080056extern void VG_(init_tt_tc) ( void );
57
58extern
59void VG_(add_to_transtab)( VexGuestExtents* vge,
60 Addr64 entry,
61 AddrH code,
62 UInt code_len,
Ben Cheng663860b2013-01-31 15:38:14 -080063 Bool is_self_checking,
64 Int offs_profInc,
65 UInt n_guest_instrs,
66 VexArch arch_host );
Jeff Browned07e002011-02-03 17:46:23 -080067
Ben Cheng663860b2013-01-31 15:38:14 -080068extern
69void VG_(tt_tc_do_chaining) ( void* from__patch_addr,
70 UInt to_sNo,
71 UInt to_tteNo,
72 Bool to_fastEP );
73
74extern Bool VG_(search_transtab) ( /*OUT*/AddrH* res_hcode,
75 /*OUT*/UInt* res_sNo,
76 /*OUT*/UInt* res_tteNo,
Jeff Browned07e002011-02-03 17:46:23 -080077 Addr64 guest_addr,
78 Bool upd_cache );
79
80extern void VG_(discard_translations) ( Addr64 start, ULong range,
81 HChar* who );
82
83extern void VG_(print_tt_tc_stats) ( void );
84
85extern UInt VG_(get_bbs_translated) ( void );
86
87/* Add to / search the auxiliary, small, unredirected translation
88 table. */
89
90extern
91void VG_(add_to_unredir_transtab)( VexGuestExtents* vge,
92 Addr64 entry,
93 AddrH code,
94 UInt code_len );
95extern
96Bool VG_(search_unredir_transtab) ( /*OUT*/AddrH* result,
97 Addr64 guest_addr );
98
99// BB profiling stuff
100
101typedef struct _BBProfEntry {
102 Addr64 addr;
103 ULong score;
104} BBProfEntry;
105
106extern ULong VG_(get_BB_profile) ( BBProfEntry tops[], UInt n_tops );
107
108#endif // __PUB_CORE_TRANSTAB_H
109
110/*--------------------------------------------------------------------*/
111/*--- end ---*/
112/*--------------------------------------------------------------------*/