|
From: Nicholas N. <nj...@ca...> - 2004-09-07 10:17:19
|
CVS commit by nethercote:
Arch-abstraction:
- Moved VG_MAX_REALREGS into x86/ part.
- Tweaked basic types so they're suitable for both 32-bit and 64-bit platforms.
Main change was to change 'Addr' to "unsigned long" which is the same size as
a pointer. Had to make a couple of minor changes to accommodate this.
Also, introduced 'UWord' and 'Word' types which will be necessary for making
code 64-bit clean.
M +1 -1 coregrind/core.h 1.14
M +7 -5 coregrind/vg_main.c 1.205 [POSSIBLY UNSAFE: printf]
M +3 -3 coregrind/vg_procselfmaps.c 1.13
M +3 -3 helgrind/hg_main.c 1.84
M +18 -27 include/tool.h.base 1.7
M +17 -0 include/x86/tool_arch.h 1.4
--- valgrind/coregrind/core.h #1.13:1.14
@@ -1473,5 +1473,5 @@ extern void VG_(missing_tool_func) ( con
/* ---------------------------------------------------------------------
- The state of the simulated CPU.
+ The baseBlock -- arch-neutral bits
------------------------------------------------------------------ */
--- valgrind/coregrind/vg_main.c #1.204:1.205
@@ -1027,7 +1027,8 @@ static Addr setup_client_stack(char **or
if (0)
printf("stringsize=%d auxsize=%d stacksize=%d\n"
- "clstk_base %x\n"
- "clstk_end %x\n",
- stringsize, auxsize, stacksize, VG_(clstk_base), VG_(clstk_end));
+ "clstk_base %p\n"
+ "clstk_end %p\n",
+ stringsize, auxsize, stacksize,
+ (void*)VG_(clstk_base), (void*)VG_(clstk_end));
@@ -2646,6 +2647,7 @@ int main(int argc, char **argv)
if (0)
- printf("entry=%x client esp=%x vg_argc=%d brkbase=%x\n",
- client_eip, esp_at_startup, vg_argc, VG_(brk_base));
+ printf("entry=%p client esp=%p vg_argc=%d brkbase=%p\n",
+ (void*)client_eip, (void*)esp_at_startup, vg_argc,
+ (void*)VG_(brk_base));
//==============================================================
--- valgrind/coregrind/vg_procselfmaps.c #1.12:1.13
@@ -64,5 +64,5 @@ static Int readchar ( Char* buf, Char* c
}
-static Int readhex ( Char* buf, UInt* val )
+static Int readhex ( Char* buf, UWord* val )
{
Int n = 0;
@@ -149,7 +149,7 @@ void VG_(parse_procselfmaps) (
Addr start, endPlusOne;
UChar* filename;
- UInt foffset;
UChar rr, ww, xx, pp, ch, tmp;
- UInt maj, min, ino;
+ UInt ino;
+ UWord foffset, maj, min;
sk_assert( '\0' != procmap_buf[0] && 0 != buf_n_tot);
--- valgrind/helgrind/hg_main.c #1.83:1.84
@@ -1712,5 +1712,5 @@ static void bus_unlock(void);
static
void eraser_pre_mem_read(CorePart part, ThreadId tid,
- Char* s, UInt base, UInt size )
+ Char* s, Addr base, UInt size )
{
if (tid > 50) { VG_(printf)("pid = %d, s = `%s`, part = %d\n", tid, s, part); VG_(skin_panic)("a");}
@@ -1720,5 +1720,5 @@ void eraser_pre_mem_read(CorePart part,
static
void eraser_pre_mem_read_asciiz(CorePart part, ThreadId tid,
- Char* s, UInt base )
+ Char* s, Addr base )
{
eraser_mem_read(base, VG_(strlen)((Char*)base), tid);
@@ -1727,5 +1727,5 @@ void eraser_pre_mem_read_asciiz(CorePart
static
void eraser_pre_mem_write(CorePart part, ThreadId tid,
- Char* s, UInt base, UInt size )
+ Char* s, Addr base, UInt size )
{
eraser_mem_write(base, size, tid);
--- valgrind/include/tool.h.base #1.6:1.7
@@ -41,17 +41,24 @@
/*====================================================================*/
-typedef unsigned char UChar;
-typedef unsigned short UShort;
-typedef unsigned int UInt;
-typedef unsigned long long int ULong;
-
-typedef signed char Char;
-typedef signed short Short;
-typedef signed int Int;
-typedef signed long long int Long;
+// By choosing the right types, we can get these right for 32-bit and 64-bit
+// platforms without having to do any conditional compilation or anything.
+//
+// Size in bits on: 32-bit archs 64-bit archs
+// ------------ ------------
+typedef unsigned char UChar; // 8 8
+typedef unsigned short UShort; // 16 16
+typedef unsigned int UInt; // 32 32
+typedef unsigned long UWord; // 32 64
+typedef unsigned long long ULong; // 64 64
+
+typedef signed char Char; // 8 8
+typedef signed short Short; // 16 16
+typedef signed int Int; // 32 32
+typedef signed long Word; // 32 64
+typedef signed long long Long; // 64 64
-typedef unsigned int Addr;
+typedef UWord Addr; // 32 64
-typedef unsigned char Bool;
+typedef UChar Bool; // 8 8
#define False ((Bool)0)
#define True ((Bool)1)
@@ -90,20 +97,4 @@
#define VG_N_THREAD_KEYS 50
-/* Total number of integer registers available for allocation -- all of
- them except %esp, %ebp. %ebp permanently points at VG_(baseBlock).
-
- If you increase this you'll have to also change at least these:
- - VG_(rank_to_realreg)()
- - VG_(realreg_to_rank)()
- - ppRegsLiveness()
- - the RegsLive type (maybe -- RegsLive type must have more than
- VG_MAX_REALREGS bits)
-
- You can decrease it, and performance will drop because more spills will
- occur. If you decrease it too much, everything will fall over.
-
- Do not change this unless you really know what you are doing! */
-#define VG_MAX_REALREGS 6
-
/*====================================================================*/
--- valgrind/include/x86/tool_arch.h #1.3:1.4
@@ -49,4 +49,21 @@
#define MAX_INSTR_SIZE 16
+/* Total number of integer registers available for allocation -- all of
+ them except %esp (points to Valgrind's stack) and %ebp (permanently
+ points at the baseBlock).
+
+ If you increase this you'll have to also change at least these:
+ - VG_(rank_to_realreg)()
+ - VG_(realreg_to_rank)()
+ - ppRegsLiveness()
+ - the RegsLive type (maybe -- RegsLive type must have more than
+ VG_MAX_REALREGS bits)
+
+ You can decrease it, and performance will drop because more spills will
+ occur. If you decrease it too much, everything will fall over.
+
+ Do not change this unless you really know what you are doing! */
+#define VG_MAX_REALREGS 6
+
/*====================================================================*/
|