|
From: <sv...@va...> - 2007-09-09 21:22:49
|
Author: sewardj
Date: 2007-09-09 22:22:48 +0100 (Sun, 09 Sep 2007)
New Revision: 6802
Log:
For VG_(record_ExeContext) et al, add a new parameter (first_ip_delta)
which is added to the initial IP value before the stack is unwound. A
safe value to pass is zero, which causes the existing behaviour to be
unchanged. This is a kludge needed to work around the incomplete
amd64 stack unwind info in glibc-2.5's clone() routine.
Modified:
branches/THRCHECK/coregrind/m_errormgr.c
branches/THRCHECK/coregrind/m_execontext.c
branches/THRCHECK/coregrind/m_stacktrace.c
branches/THRCHECK/helgrind/hg_main.c
branches/THRCHECK/include/pub_tool_execontext.h
branches/THRCHECK/include/pub_tool_stacktrace.h
branches/THRCHECK/memcheck/mc_main.c
branches/THRCHECK/memcheck/mc_malloc_wrappers.c
Modified: branches/THRCHECK/coregrind/m_errormgr.c
===================================================================
--- branches/THRCHECK/coregrind/m_errormgr.c 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/coregrind/m_errormgr.c 2007-09-09 21:22:48 UTC (rev 6802)
@@ -380,7 +380,7 @@
err->count = 1;
err->tid = tid;
if (NULL == where)
- err->where = VG_(record_ExeContext)( tid );
+ err->where = VG_(record_ExeContext)( tid, 0 );
else
err->where = where;
Modified: branches/THRCHECK/coregrind/m_execontext.c
===================================================================
--- branches/THRCHECK/coregrind/m_execontext.c 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/coregrind/m_execontext.c 2007-09-09 21:22:48 UTC (rev 6802)
@@ -277,7 +277,7 @@
ec_htab_size_idx++;
}
-ExeContext* VG_(record_ExeContext) ( ThreadId tid )
+ExeContext* VG_(record_ExeContext) ( ThreadId tid, Word first_ip_delta )
{
Int i;
Addr ips[VG_DEEPEST_BACKTRACE];
@@ -297,7 +297,8 @@
vg_assert(VG_(clo_backtrace_size) >= 1 &&
VG_(clo_backtrace_size) <= VG_DEEPEST_BACKTRACE);
- n_ips = VG_(get_StackTrace)( tid, ips, VG_(clo_backtrace_size) );
+ n_ips = VG_(get_StackTrace)( tid, ips, VG_(clo_backtrace_size),
+ first_ip_delta );
tl_assert(n_ips >= 1 && n_ips <= VG_(clo_backtrace_size));
/* Now figure out if we've seen this one before. First hash it so
Modified: branches/THRCHECK/coregrind/m_stacktrace.c
===================================================================
--- branches/THRCHECK/coregrind/m_stacktrace.c 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/coregrind/m_stacktrace.c 2007-09-09 21:22:48 UTC (rev 6802)
@@ -369,7 +369,8 @@
return n_found;
}
-UInt VG_(get_StackTrace) ( ThreadId tid, StackTrace ips, UInt n_ips )
+UInt VG_(get_StackTrace) ( ThreadId tid, StackTrace ips, UInt n_ips,
+ Word first_ip_delta )
{
/* thread in thread table */
Addr ip = VG_(get_IP)(tid);
@@ -405,6 +406,10 @@
}
# endif
+ /* Take into account the first_ip_delta. */
+ vg_assert( sizeof(Addr) == sizeof(Word) );
+ ip += first_ip_delta;
+
if (0)
VG_(printf)("tid %d: stack_highest=%p ip=%p sp=%p fp=%p\n",
tid, stack_highest_word, ip, sp, fp);
@@ -446,7 +451,8 @@
void VG_(get_and_pp_StackTrace) ( ThreadId tid, UInt n_ips )
{
Addr ips[n_ips];
- UInt n_ips_obtained = VG_(get_StackTrace)(tid, ips, n_ips);
+ UInt n_ips_obtained = VG_(get_StackTrace)(tid, ips, n_ips,
+ 0/*first_ip_delta*/);
VG_(pp_StackTrace)(ips, n_ips_obtained);
}
Modified: branches/THRCHECK/helgrind/hg_main.c
===================================================================
--- branches/THRCHECK/helgrind/hg_main.c 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/helgrind/hg_main.c 2007-09-09 21:22:48 UTC (rev 6802)
@@ -1600,7 +1600,7 @@
break;
}
- mutex->location = VG_(record_ExeContext)(tid);
+ mutex->location = VG_(record_ExeContext)(tid, 0);
mutex->state = state;
}
@@ -1845,7 +1845,7 @@
hc = VG_(malloc)(sizeof(HG_Chunk));
hc->data = p;
hc->size = size;
- hc->where = VG_(record_ExeContext)(tid);
+ hc->where = VG_(record_ExeContext)(tid, 0);
hc->tid = tid;
VG_(HT_add_node)( hg_malloc_list, (VgHashNode*)hc );
@@ -1921,7 +1921,7 @@
*prev_chunks_next_ptr = hc->next;
/* Record where freed */
- hc->where = VG_(record_ExeContext) ( tid );
+ hc->where = VG_(record_ExeContext) ( tid, 0 );
/* maintain a small window so that the error reporting machinery
knows about this memory */
@@ -1989,13 +1989,13 @@
if (hc->size == new_size) {
/* size unchanged */
- hc->where = VG_(record_ExeContext)(tid);
+ hc->where = VG_(record_ExeContext)(tid, 0);
return p;
} else if (hc->size > new_size) {
/* new size is smaller */
hc->size = new_size;
- hc->where = VG_(record_ExeContext)(tid);
+ hc->where = VG_(record_ExeContext)(tid, 0);
return p;
} else {
@@ -3076,7 +3076,7 @@
if (clo_execontext == EC_Some)
ecip = IP(VG_(get_IP)(tid), prevstate, tls);
else
- ecip = EC(VG_(record_ExeContext)(tid), prevstate, tls);
+ ecip = EC(VG_(record_ExeContext)(tid, 0), prevstate, tls);
setExeContext(a, ecip);
}
}
@@ -3181,7 +3181,7 @@
if (clo_execontext == EC_Some)
ecip = IP(VG_(get_IP)(tid), prevstate, tls);
else
- ecip = EC(VG_(record_ExeContext)(tid), prevstate, tls);
+ ecip = EC(VG_(record_ExeContext)(tid, 0), prevstate, tls);
setExeContext(a, ecip);
}
}
Modified: branches/THRCHECK/include/pub_tool_execontext.h
===================================================================
--- branches/THRCHECK/include/pub_tool_execontext.h 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/include/pub_tool_execontext.h 2007-09-09 21:22:48 UTC (rev 6802)
@@ -51,8 +51,11 @@
//
// If called from generated code, use VG_(get_running_tid)() to get the
// current ThreadId. If called from non-generated code, the current
-// ThreadId should be passed in by the core.
-extern ExeContext* VG_(record_ExeContext) ( ThreadId tid );
+// ThreadId should be passed in by the core. The initial IP value to
+// use is adjusted by first_ip_delta before the stack is unwound.
+// A safe value to pass is zero.
+extern
+ExeContext* VG_(record_ExeContext) ( ThreadId tid, Word first_ip_delta );
// Apply a function to every element in the ExeContext. The parameter 'n'
// gives the index of the passed ip. Doesn't go below main() unless
Modified: branches/THRCHECK/include/pub_tool_stacktrace.h
===================================================================
--- branches/THRCHECK/include/pub_tool_stacktrace.h 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/include/pub_tool_stacktrace.h 2007-09-09 21:22:48 UTC (rev 6802)
@@ -37,8 +37,11 @@
// Walks the stack to get instruction pointers from the top stack frames for
// thread 'tid'. Maximum of 'n_ips' addresses put into 'ips'; 0 is the top
// of the stack, 1 is its caller, etc. Everything from ips[n_ips] onwards
-// is undefined and should not be read.
-extern UInt VG_(get_StackTrace) ( ThreadId tid, StackTrace ips, UInt n_ips );
+// is undefined and should not be read. The initial IP value to
+// use is adjusted by first_ip_delta before the stack is unwound.
+// A safe value to pass is zero.
+extern UInt VG_(get_StackTrace) ( ThreadId tid, StackTrace ips, UInt n_ips,
+ Word first_ip_delta );
// Apply a function to every element in the StackTrace. The parameter 'n'
// gives the index of the passed ip. Doesn't go below main() unless
Modified: branches/THRCHECK/memcheck/mc_main.c
===================================================================
--- branches/THRCHECK/memcheck/mc_main.c 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/memcheck/mc_main.c 2007-09-09 21:22:48 UTC (rev 6802)
@@ -4659,7 +4659,7 @@
cgbs[i].start = arg[1];
cgbs[i].size = arg[2];
cgbs[i].desc = VG_(strdup)((Char *)arg[3]);
- cgbs[i].where = VG_(record_ExeContext) ( tid );
+ cgbs[i].where = VG_(record_ExeContext) ( tid, 0/*first_ip_delta*/ );
*ret = i;
} else
Modified: branches/THRCHECK/memcheck/mc_malloc_wrappers.c
===================================================================
--- branches/THRCHECK/memcheck/mc_malloc_wrappers.c 2007-09-09 20:57:49 UTC (rev 6801)
+++ branches/THRCHECK/memcheck/mc_malloc_wrappers.c 2007-09-09 21:22:48 UTC (rev 6802)
@@ -131,7 +131,7 @@
mc->data = p;
mc->szB = szB;
mc->allockind = kind;
- mc->where = VG_(record_ExeContext)(tid);
+ mc->where = VG_(record_ExeContext)(tid, 0/*first_ip_delta*/);
/* Paranoia ... ensure the MC_Chunk is off-limits to the client, so
the mc->data field isn't visible to the leak checker. If memory
@@ -268,7 +268,7 @@
/* Put it out of harm's way for a while, if not from a client request */
if (MC_AllocCustom != mc->allockind) {
/* Record where freed */
- mc->where = VG_(record_ExeContext) ( tid );
+ mc->where = VG_(record_ExeContext) ( tid, 0/*first_ip_delta*/ );
add_to_freed_queue ( mc );
} else {
VG_(free) ( mc );
@@ -346,14 +346,14 @@
if (old_szB == new_szB) {
/* size unchanged */
- mc->where = VG_(record_ExeContext)(tid);
+ mc->where = VG_(record_ExeContext)(tid, 0/*first_ip_delta*/);
p_new = p_old;
} else if (old_szB > new_szB) {
/* new size is smaller */
MC_(make_mem_noaccess)( mc->data+new_szB, mc->szB-new_szB );
mc->szB = new_szB;
- mc->where = VG_(record_ExeContext)(tid);
+ mc->where = VG_(record_ExeContext)(tid, 0/*first_ip_delta*/);
p_new = p_old;
} else {
|