From: Bart Van Assche Date: Sat, 20 Feb 2021 04:24:57 +0000 (-0800) Subject: drd: Process stack registration client requests X-Git-Tag: VALGRIND_3_17_0~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd5a12afcb126d3be18f78a6f17d49847e202742;p=thirdparty%2Fvalgrind.git drd: Process stack registration client requests Reset stack information if the client registers a new stack --- diff --git a/NEWS b/NEWS index c910af0f4e..cdd103b01e 100644 --- a/NEWS +++ b/NEWS @@ -120,6 +120,7 @@ where XXXXXX is the bug number as listed below. 431556 Complete arm64 FADDP v8.2 instruction support 432102 Add support for DWARF5 as produced by GCC11 432161 Addition of arm64 v8.2 FADDP, FNEG and FSQRT +432381 drd: Process STACK_REGISTER client requests 432672 vg_regtest: test-specific environment variables not reset between tests 432809 VEX should support REX.W + POPF 432861 PPC modsw and modsd give incorrect results for 1 mod 12 diff --git a/drd/drd_main.c b/drd/drd_main.c index 7873c1f977..2f2279e52d 100644 --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -629,6 +629,13 @@ static void drd_stop_using_mem_stack_signal(Addr a, SizeT len) True); } +static void drd_register_stack(Addr start, Addr end) +{ + DrdThreadId drd_tid = DRD_(thread_get_running_tid)(); + + DRD_(thread_register_stack)(drd_tid, start, end); +} + static void drd_pre_thread_create(const ThreadId creator, const ThreadId created) { @@ -852,6 +859,7 @@ void drd_pre_clo_init(void) VG_(track_die_mem_munmap) (drd_stop_using_nonstack_mem); VG_(track_die_mem_stack) (drd_stop_using_mem_stack); VG_(track_die_mem_stack_signal) (drd_stop_using_mem_stack_signal); + VG_(track_register_stack) (drd_register_stack); VG_(track_pre_deliver_signal) (drd_pre_deliver_signal); VG_(track_post_deliver_signal) (drd_post_deliver_signal); VG_(track_start_client_code) (drd_start_client_code); diff --git a/drd/drd_thread.c b/drd/drd_thread.c index 548c74843b..32064c3b15 100644 --- a/drd/drd_thread.c +++ b/drd/drd_thread.c @@ -431,6 +431,17 @@ void DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee) DRD_(thread_delayed_delete)(drd_joinee); } +void DRD_(thread_register_stack)(DrdThreadId tid, Addr addr1, Addr addr2) +{ + tl_assert(0 <= (int)tid && tid < DRD_N_THREADS + && tid != DRD_INVALID_THREADID); + tl_assert(addr1 < addr2); + DRD_(g_threadinfo)[tid].stack_min = addr2; + DRD_(g_threadinfo)[tid].stack_min_min = addr2; + DRD_(g_threadinfo)[tid].stack_startup = addr2; + DRD_(g_threadinfo)[tid].stack_max = addr2; +} + /** * NPTL hack: NPTL allocates the 'struct pthread' on top of the stack, * and accesses this data structure from multiple threads without locking. diff --git a/drd/drd_thread.h b/drd/drd_thread.h index 063ae35fc9..0f7d783733 100644 --- a/drd/drd_thread.h +++ b/drd/drd_thread.h @@ -153,6 +153,7 @@ void DRD_(thread_delete)(const DrdThreadId tid, Bool detached); void DRD_(thread_finished)(const DrdThreadId tid); void DRD_(drd_thread_atfork_child)(const DrdThreadId tid); void DRD_(thread_pre_cancel)(const DrdThreadId tid); +void DRD_(thread_register_stack)(DrdThreadId tid, Addr addr1, Addr addr2); void DRD_(thread_set_stack_startup)(const DrdThreadId tid, const Addr stack_startup); Addr DRD_(thread_get_stack_min)(const DrdThreadId tid);