From: Bart Van Assche Date: Sun, 15 Feb 2009 10:36:32 +0000 (+0000) Subject: Changed the order of the function definitions. X-Git-Tag: svn/VALGRIND_3_5_0~984 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ce938fd90d1c21996401de4e5226825250508e83;p=thirdparty%2Fvalgrind.git Changed the order of the function definitions. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9162 --- diff --git a/drd/drd_clientreq.c b/drd/drd_clientreq.c index fef90c1a69..4384c04ffc 100644 --- a/drd/drd_clientreq.c +++ b/drd/drd_clientreq.c @@ -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; }