Modularised vg_transtab.c as m_transtab.
Renamed add_to_trans_tab() as add_to_transtab() for consistency
with the other names.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3703 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 914c571..8c51c7e 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -53,6 +53,7 @@
pub_core_syscalls.h \
pub_core_tooliface.h \
pub_core_translate.h \
+ pub_core_transtab.h \
ume.h \
vg_symtab2.h \
vg_symtypes.h
@@ -80,6 +81,7 @@
m_stacktrace.c \
m_tooliface.c \
m_translate.c \
+ m_transtab.c \
ume.c \
\
vg_scheduler.c \
@@ -95,8 +97,7 @@
vg_redir.c \
vg_dwarf.c \
vg_stabs.c \
- vg_symtypes.c \
- vg_transtab.c
+ vg_symtypes.c
## libplatform.a must be before libarch.a and libos.a, it seems.
stage2_extra= \
diff --git a/coregrind/core.h b/coregrind/core.h
index 6ac1166..48aa006 100644
--- a/coregrind/core.h
+++ b/coregrind/core.h
@@ -759,38 +759,6 @@
/* ---------------------------------------------------------------------
- Exports of vg_transtab.c
- ------------------------------------------------------------------ */
-
-/* The fast-cache for tt-lookup, and for finding counters. */
-extern ULong* VG_(tt_fast) [VG_TT_FAST_SIZE];
-extern UInt* VG_(tt_fastN)[VG_TT_FAST_SIZE];
-
-
-extern void VG_(init_tt_tc) ( void );
-
-extern
-void VG_(add_to_trans_tab)( VexGuestExtents* vge,
- Addr64 entry,
- AddrH code,
- UInt code_len );
-
-extern Bool VG_(search_transtab) ( /*OUT*/AddrH* result,
- Addr64 guest_addr,
- Bool upd_cache );
-
-extern void VG_(discard_translations) ( Addr64 start, UInt range );
-
-extern void VG_(sanity_check_tt_tc) ( Char* caller );
-
-extern void VG_(print_tt_tc_stats) ( void );
-
-extern UInt VG_(get_bbs_translated) ( void );
-
-extern void VG_(show_BB_profile) ( void );
-
-
-/* ---------------------------------------------------------------------
Exports of vg_syscall.S
------------------------------------------------------------------ */
diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c
index d01f76a..57bc6ae 100644
--- a/coregrind/m_aspacemgr/aspacemgr.c
+++ b/coregrind/m_aspacemgr/aspacemgr.c
@@ -34,6 +34,7 @@
#include "pub_core_aspacemgr.h"
#include "pub_core_syscalls.h"
#include "pub_core_tooliface.h"
+#include "pub_core_transtab.h"
#include "vki_unistd.h"
diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c
index fa717da..4ec0043 100644
--- a/coregrind/m_translate.c
+++ b/coregrind/m_translate.c
@@ -32,6 +32,8 @@
#include "core.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_tooliface.h"
+#include "pub_core_translate.h"
+#include "pub_core_transtab.h"
/*------------------------------------------------------------*/
@@ -496,10 +498,10 @@
if (!debugging_translation) {
// Note that we use orig_addr0, not orig_addr, which might have been
// changed by the redirection
- VG_(add_to_trans_tab)( &vge,
- orig_addr0,
- (Addr)(&tmpbuf[0]),
- tmpbuf_used );
+ VG_(add_to_transtab)( &vge,
+ orig_addr0,
+ (Addr)(&tmpbuf[0]),
+ tmpbuf_used );
}
VGP_POPCC(VgpTranslate);
diff --git a/coregrind/vg_transtab.c b/coregrind/m_transtab.c
similarity index 98%
rename from coregrind/vg_transtab.c
rename to coregrind/m_transtab.c
index 68ccb6c..9c44d4c 100644
--- a/coregrind/vg_transtab.c
+++ b/coregrind/m_transtab.c
@@ -1,7 +1,7 @@
/*--------------------------------------------------------------------*/
/*--- Management of the translation table and cache. ---*/
-/*--- vg_transtab.c ---*/
+/*--- m_transtab.c ---*/
/*--------------------------------------------------------------------*/
/*
@@ -31,7 +31,9 @@
#include "core.h"
#include "pub_core_tooliface.h"
+// XXX: this module should not depend on m_translate!
#include "pub_core_translate.h"
+#include "pub_core_transtab.h"
/* #define DEBUG_TRANSTAB */
@@ -326,10 +328,10 @@
pre: youngest_sector points to a valid (although possibly full)
sector.
*/
-void VG_(add_to_trans_tab)( VexGuestExtents* vge,
- Addr64 entry,
- AddrH code,
- UInt code_len )
+void VG_(add_to_transtab)( VexGuestExtents* vge,
+ Addr64 entry,
+ AddrH code,
+ UInt code_len )
{
Int tcAvailQ, reqdQ, y, i;
ULong *tce, *tce2;
@@ -341,7 +343,7 @@
vg_assert(code_len > 0 && code_len < 20000);
if (0)
- VG_(printf)("add_to_trans_tab(entry = 0x%llx, len = %d)\n",
+ VG_(printf)("add_to_transtab(entry = 0x%llx, len = %d)\n",
entry, code_len);
n_in_count++;
@@ -804,5 +806,5 @@
/*--------------------------------------------------------------------*/
-/*--- end vg_transtab.c ---*/
+/*--- end ---*/
/*--------------------------------------------------------------------*/
diff --git a/coregrind/pub_core_transtab.h b/coregrind/pub_core_transtab.h
new file mode 100644
index 0000000..6d1e46b
--- /dev/null
+++ b/coregrind/pub_core_transtab.h
@@ -0,0 +1,71 @@
+
+/*--------------------------------------------------------------------*/
+/*--- The translation table and cache. ---*/
+/*--- pub_core_transtab.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_CORE_TRANSTAB_H
+#define __PUB_CORE_TRANSTAB_H
+
+//--------------------------------------------------------------------
+// PURPOSE: This module is responsible for caching translations, and
+// enabling fast look-ups of them.
+//--------------------------------------------------------------------
+
+/* The fast-cache for tt-lookup, and for finding counters. */
+extern ULong* VG_(tt_fast) [VG_TT_FAST_SIZE];
+extern UInt* VG_(tt_fastN)[VG_TT_FAST_SIZE];
+
+extern void VG_(init_tt_tc) ( void );
+
+extern
+void VG_(add_to_transtab)( VexGuestExtents* vge,
+ Addr64 entry,
+ AddrH code,
+ UInt code_len );
+
+extern Bool VG_(search_transtab) ( /*OUT*/AddrH* result,
+ Addr64 guest_addr,
+ Bool upd_cache );
+
+extern void VG_(discard_translations) ( Addr64 start, UInt range );
+
+extern void VG_(sanity_check_tt_tc) ( Char* caller );
+
+extern void VG_(print_tt_tc_stats) ( void );
+
+extern UInt VG_(get_bbs_translated) ( void );
+
+extern void VG_(show_BB_profile) ( void );
+
+
+#endif // __PUB_CORE_TRANSTAB_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c
index 41f5fbb..72e7a79 100644
--- a/coregrind/vg_main.c
+++ b/coregrind/vg_main.c
@@ -38,6 +38,7 @@
#include "pub_core_execontext.h"
#include "pub_core_syscalls.h"
#include "pub_core_tooliface.h"
+#include "pub_core_transtab.h"
#include <dirent.h>
#include <dlfcn.h>
diff --git a/coregrind/vg_redir.c b/coregrind/vg_redir.c
index 0d8996f..f0840b7 100644
--- a/coregrind/vg_redir.c
+++ b/coregrind/vg_redir.c
@@ -34,6 +34,7 @@
#include "pub_core_aspacemgr.h"
#include "pub_core_skiplist.h"
+#include "pub_core_transtab.h"
/*------------------------------------------------------------*/
/*--- General purpose redirection. ---*/
diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c
index 97e1064..c610869 100644
--- a/coregrind/vg_scheduler.c
+++ b/coregrind/vg_scheduler.c
@@ -67,6 +67,7 @@
#include "pub_core_syscalls.h"
#include "pub_core_tooliface.h"
#include "pub_core_translate.h"
+#include "pub_core_transtab.h"
#include "vki_unistd.h"
/* ---------------------------------------------------------------------