Changed the order of the function definitions.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9162
This commit is contained in:
Bart Van Assche 2009-02-15 10:36:32 +00:00
parent 6dacd9c6ff
commit ce938fd90d

View File

@ -47,48 +47,15 @@ Bool DRD_(handle_client_request)(ThreadId vg_tid, UWord* arg, UWord* ret);
static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid);
/* Function definitions. */
/**
* Walk the stack up to the highest stack frame, and return the stack pointer
* of the highest stack frame. It is assumed that there are no more than
* ten stack frames above the current frame. This should be no problem
* since this function is either called indirectly from the _init() function
* in vgpreload_exp-drd-*.so or from the thread wrapper for a newly created
* thread. See also drd_pthread_intercepts.c.
* Tell the Valgrind core the address of the DRD function that processes
* client requests. Must be called before any client code is run.
*/
static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid)
void DRD_(clientreq_init)(void)
{
UInt nframes;
const UInt n_ips = 10;
UInt i;
Addr ips[n_ips], sps[n_ips];
Addr husa;
nframes = VG_(get_StackTrace)(vg_tid, ips, n_ips, sps, 0, 0);
tl_assert(1 <= nframes && nframes <= n_ips);
/* A hack to work around VG_(get_StackTrace)()'s behavior that sometimes */
/* the topmost stackframes it returns are bogus (this occurs sometimes */
/* at least on amd64, ppc32 and ppc64). */
husa = sps[0];
tl_assert(VG_(thread_get_stack_max)(vg_tid)
- VG_(thread_get_stack_size)(vg_tid) <= husa
&& husa < VG_(thread_get_stack_max)(vg_tid));
for (i = 1; i < nframes; i++)
{
if (sps[i] == 0)
break;
if (husa < sps[i] && sps[i] < VG_(thread_get_stack_max)(vg_tid))
husa = sps[i];
}
tl_assert(VG_(thread_get_stack_max)(vg_tid)
- VG_(thread_get_stack_size)(vg_tid) <= husa
&& husa < VG_(thread_get_stack_max)(vg_tid));
return husa;
VG_(needs_client_requests)(DRD_(handle_client_request));
}
/**
@ -411,10 +378,45 @@ Bool DRD_(handle_client_request)(ThreadId vg_tid, UWord* arg, UWord* ret)
}
/**
* Tell the Valgrind core the address of the DRD function that processes
* client requests. Must be called before any client code is run.
* Walk the stack up to the highest stack frame, and return the stack pointer
* of the highest stack frame. It is assumed that there are no more than
* ten stack frames above the current frame. This should be no problem
* since this function is either called indirectly from the _init() function
* in vgpreload_exp-drd-*.so or from the thread wrapper for a newly created
* thread. See also drd_pthread_intercepts.c.
*/
void DRD_(clientreq_init)(void)
static Addr DRD_(highest_used_stack_address)(const ThreadId vg_tid)
{
VG_(needs_client_requests)(DRD_(handle_client_request));
UInt nframes;
const UInt n_ips = 10;
UInt i;
Addr ips[n_ips], sps[n_ips];
Addr husa;
nframes = VG_(get_StackTrace)(vg_tid, ips, n_ips, sps, 0, 0);
tl_assert(1 <= nframes && nframes <= n_ips);
/* A hack to work around VG_(get_StackTrace)()'s behavior that sometimes */
/* the topmost stackframes it returns are bogus (this occurs sometimes */
/* at least on amd64, ppc32 and ppc64). */
husa = sps[0];
tl_assert(VG_(thread_get_stack_max)(vg_tid)
- VG_(thread_get_stack_size)(vg_tid) <= husa
&& husa < VG_(thread_get_stack_max)(vg_tid));
for (i = 1; i < nframes; i++)
{
if (sps[i] == 0)
break;
if (husa < sps[i] && sps[i] < VG_(thread_get_stack_max)(vg_tid))
husa = sps[i];
}
tl_assert(VG_(thread_get_stack_max)(vg_tid)
- VG_(thread_get_stack_size)(vg_tid) <= husa
&& husa < VG_(thread_get_stack_max)(vg_tid));
return husa;
}