|
From: Nicholas N. <nj...@ca...> - 2004-10-20 10:58:15
|
CVS commit by nethercote:
Arch-abstraction:
- Make Helgrind totally arch-agnostic.
M +0 -3 coregrind/x86/core_arch.h 1.13
M +44 -43 helgrind/hg_main.c 1.85
M +4 -0 include/x86/tool_arch.h 1.5
--- valgrind/coregrind/x86/core_arch.h #1.12:1.13
@@ -49,7 +49,4 @@
// Accessors for the baseBlock
-#define R_STACK_PTR R_ESP
-#define R_FRAME_PTR R_EBP
-
#define R_CLREQ_RET R_EDX
#define R_PTHREQ_RET R_EDX
--- valgrind/helgrind/hg_main.c #1.84:1.85
@@ -225,17 +225,17 @@ static const shadow_word error_sword = S
changed state (if required) */
-typedef struct EC_EIP {
- union u_ec_eip {
- Addr eip;
+typedef struct EC_IP {
+ union u_ec_ip {
+ Addr ip;
ExeContext *ec;
- } uu_ec_eip;
+ } uu_ec_ip;
UInt state:STATE_BITS;
UInt tls:OTHER_BITS; /* packed TLS */
-} EC_EIP;
+} EC_IP;
-#define NULL_EC_EIP ((EC_EIP){ { 0 }, 0, 0})
+#define NULL_EC_IP ((EC_IP){ { 0 }, 0, 0})
-#define EIP(eip, prev, tls) ((EC_EIP) { (union u_ec_eip)(eip), (prev).state, packTLS(tls) })
-#define EC(ec, prev, tls) ((EC_EIP) { (union u_ec_eip)(ec), (prev).state, packTLS(tls) })
+#define IP(ip, prev, tls) ((EC_IP) { (union u_ec_ip)(ip), (prev).state, packTLS(tls) })
+#define EC(ec, prev, tls) ((EC_IP) { (union u_ec_ip)(ec), (prev).state, packTLS(tls) })
static inline UInt packEC(ExeContext *ec)
@@ -250,11 +250,11 @@ static inline ExeContext *unpackEC(UInt
}
-/* Lose 2 LSB of eip */
-static inline UInt packEIP(Addr eip)
+/* Lose 2 LSB of IP */
+static inline UInt packIP(Addr ip)
{
- return ((UInt)eip) >> STATE_BITS;
+ return ((UInt)ip) >> STATE_BITS;
}
-static inline Addr unpackEIP(UInt i)
+static inline Addr unpackIP(UInt i)
{
return (Addr)(i << STATE_BITS);
@@ -262,10 +262,10 @@ static inline Addr unpackEIP(UInt i)
typedef struct {
- EC_EIP execontext[ESEC_MAP_WORDS];
+ EC_IP execontext[ESEC_MAP_WORDS];
} ExeContextMap;
static ExeContextMap** execontext_map;
-static inline void setExeContext(Addr a, EC_EIP ec)
+static inline void setExeContext(Addr a, EC_IP ec)
{
UInt idx = (a >> 16) & 0xffff;
@@ -280,9 +280,9 @@ static inline void setExeContext(Addr a,
}
-static inline EC_EIP getExeContext(Addr a)
+static inline EC_IP getExeContext(Addr a)
{
UInt idx = (a >> 16) & 0xffff;
UInt off = (a >> 2) & 0x3fff;
- EC_EIP ec = NULL_EC_EIP;
+ EC_IP ec = NULL_EC_IP;
if (execontext_map[idx] != NULL)
@@ -563,5 +563,5 @@ void init_virgin_sword(Addr a)
{
if (clo_execontext != EC_None)
- setExeContext(a, NULL_EC_EIP);
+ setExeContext(a, NULL_EC_IP);
set_sword(a, virgin_sword);
}
@@ -2045,6 +2045,6 @@ UCodeBlock* SK_(instrument) ( UCodeBlock
/* stackref[] is used for super-simple value tracking to keep note
of which tempregs currently hold a value which is derived from
- ESP or EBP, and is therefore likely stack-relative if used as
- the address for LOAD or STORE. */
+ the stack pointer or frame pointer, and is therefore likely
+ stack-relative if used as the address for LOAD or STORE. */
ntemps = VG_(get_num_temps)(cb);
stackref = VG_(malloc)(sizeof(*stackref) * ntemps);
@@ -2080,5 +2080,6 @@ UCodeBlock* SK_(instrument) ( UCodeBlock
stackref[u_in->val2] = (u_in->size == 4 &&
- (u_in->val1 == R_ESP || u_in->val1 == R_EBP));
+ (u_in->val1 == R_STACK_PTR ||
+ u_in->val1 == R_FRAME_PTR));
VG_(copy_UInstr)(cb, u_in);
break;
@@ -2316,5 +2317,5 @@ typedef
const Char* filename;
const Char* section;
- /* True if is just-below %esp -- could be a gcc bug. */
+ /* True if is just-below the stack pointer -- could be a gcc bug. */
Bool maybe_gcc;
/* symbolic address description */
@@ -2338,5 +2339,5 @@ typedef
/* MutexErr, LockGraphErr */
Mutex *mutex;
- EC_EIP lasttouched;
+ EC_IP lasttouched;
ThreadId lasttid;
/* LockGraphErr */
@@ -2367,5 +2368,5 @@ void clear_HelgrindError ( HelgrindError
err_extra->size = 0;
err_extra->mutex = NULL;
- err_extra->lasttouched= NULL_EC_EIP;
+ err_extra->lasttouched= NULL_EC_IP;
err_extra->lasttid = VG_INVALID_THREADID;
err_extra->prev_lockset = 0;
@@ -2577,5 +2578,5 @@ static void pp_AddrInfo ( Addr a, AddrIn
if (ai->maybe_gcc) {
VG_(message)(Vg_UserMsg,
- " Address %p is just below %%esp. Possibly a bug in GCC/G++",
+ " Address %p is just below the stack pointer. Possibly a bug in GCC/G++",
a);
VG_(message)(Vg_UserMsg,
@@ -2698,8 +2699,8 @@ void SK_(pp_SkinError) ( Error* err )
if (clo_execontext == EC_Some
- && extra->lasttouched.uu_ec_eip.eip != 0) {
+ && extra->lasttouched.uu_ec_ip.ip != 0) {
Char file[100];
UInt line;
- Addr eip = extra->lasttouched.uu_ec_eip.eip;
+ Addr ip = extra->lasttouched.uu_ec_ip.ip;
VG_(message)(Vg_UserMsg, " Word at %p last changed state from %s by thread %u",
@@ -2708,20 +2709,20 @@ void SK_(pp_SkinError) ( Error* err )
unpackTLS(extra->lasttouched.tls)->tid);
- if (VG_(get_filename_linenum)(eip, file, sizeof(file), &line)) {
+ if (VG_(get_filename_linenum)(ip, file, sizeof(file), &line)) {
VG_(message)(Vg_UserMsg, " at %p: %y (%s:%u)",
- eip, eip, file, line);
- } else if (VG_(get_objname)(eip, file, sizeof(file))) {
+ ip, ip, file, line);
+ } else if (VG_(get_objname)(ip, file, sizeof(file))) {
VG_(message)(Vg_UserMsg, " at %p: %y (in %s)",
- eip, eip, file);
+ ip, ip, file);
} else {
- VG_(message)(Vg_UserMsg, " at %p: %y", eip, eip);
+ VG_(message)(Vg_UserMsg, " at %p: %y", ip, ip);
}
} else if (clo_execontext == EC_All
- && extra->lasttouched.uu_ec_eip.ec != NULL) {
+ && extra->lasttouched.uu_ec_ip.ec != NULL) {
VG_(message)(Vg_UserMsg, " Word at %p last changed state from %s in tid %u",
err_addr,
pp_state(extra->lasttouched.state),
unpackTLS(extra->lasttouched.tls)->tid);
- VG_(pp_ExeContext)(extra->lasttouched.uu_ec_eip.ec);
+ VG_(pp_ExeContext)(extra->lasttouched.uu_ec_ip.ec);
}
break;
@@ -2734,7 +2735,7 @@ void SK_(pp_SkinError) ( Error* err )
VG_(get_error_string)(err));
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
- if (extra->lasttouched.uu_ec_eip.ec != NULL) {
+ if (extra->lasttouched.uu_ec_ip.ec != NULL) {
VG_(message)(Vg_UserMsg, " last touched by thread %d", extra->lasttid);
- VG_(pp_ExeContext)(extra->lasttouched.uu_ec_eip.ec);
+ VG_(pp_ExeContext)(extra->lasttouched.uu_ec_ip.ec);
}
pp_AddrInfo(VG_(get_error_address)(err), &extra->addrinfo);
@@ -3024,11 +3025,11 @@ static void eraser_mem_read_word(Addr a,
done:
if (clo_execontext != EC_None && statechange) {
- EC_EIP eceip;
+ EC_IP ecip;
if (clo_execontext == EC_Some)
- eceip = EIP(VG_(get_EIP)(tid), prevstate, tls);
+ ecip = IP(VG_(get_EIP)(tid), prevstate, tls);
else
- eceip = EC(VG_(get_ExeContext)(tid), prevstate, tls);
- setExeContext(a, eceip);
+ ecip = EC(VG_(get_ExeContext)(tid), prevstate, tls);
+ setExeContext(a, ecip);
}
}
@@ -3129,11 +3130,11 @@ static void eraser_mem_write_word(Addr a
done:
if (clo_execontext != EC_None && statechange) {
- EC_EIP eceip;
+ EC_IP ecip;
if (clo_execontext == EC_Some)
- eceip = EIP(VG_(get_EIP)(tid), prevstate, tls);
+ ecip = IP(VG_(get_EIP)(tid), prevstate, tls);
else
- eceip = EC(VG_(get_ExeContext)(tid), prevstate, tls);
- setExeContext(a, eceip);
+ ecip = EC(VG_(get_ExeContext)(tid), prevstate, tls);
+ setExeContext(a, ecip);
}
}
--- valgrind/include/x86/tool_arch.h #1.4:1.5
@@ -41,4 +41,8 @@
#define REGPARM(n) __attribute__((regparm(n)))
+// Accessors for the baseBlock
+#define R_STACK_PTR R_ESP
+#define R_FRAME_PTR R_EBP
+
#define FIRST_ARCH_REG R_EAX
#define LAST_ARCH_REG R_EDI
|