From 7b0247aace78de9de1e493839145c5a74e885ee7 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Fri, 19 Apr 2002 15:43:37 +0000 Subject: [PATCH] VG_(record_free_error) / VG_(record_freemismatch_error) are called by the scheduler, not by generated code. So pass in the relevant ThreadState*; don't get it from VG_(get_current_tid)(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@101 --- coregrind/vg_clientmalloc.c | 8 ++++---- coregrind/vg_errcontext.c | 26 ++++++++++++-------------- coregrind/vg_include.h | 4 ++-- vg_clientmalloc.c | 8 ++++---- vg_errcontext.c | 26 ++++++++++++-------------- vg_include.h | 4 ++-- 6 files changed, 36 insertions(+), 40 deletions(-) diff --git a/coregrind/vg_clientmalloc.c b/coregrind/vg_clientmalloc.c index b1848405aa..607c633b98 100644 --- a/coregrind/vg_clientmalloc.c +++ b/coregrind/vg_clientmalloc.c @@ -334,14 +334,14 @@ void VG_(client_free) ( ThreadState* tst, void* ptrV, VgAllocKind kind ) } if (sc == NULL) { - VG_(record_free_error) ( (Addr)ptrV ); + VG_(record_free_error) ( tst, (Addr)ptrV ); VGP_POPCC; return; } /* check if its a matching free() / delete / delete [] */ if (kind != sc->allockind) - VG_(record_freemismatch_error) ( (Addr) ptrV ); + VG_(record_freemismatch_error) ( tst, (Addr) ptrV ); /* Remove the shadow chunk from the mallocd list. */ remove_from_malloclist ( ml_no, sc ); @@ -440,7 +440,7 @@ void* VG_(client_realloc) ( ThreadState* tst, void* ptrV, UInt size_new ) } if (sc == NULL) { - VG_(record_free_error) ( (Addr)ptrV ); + VG_(record_free_error) ( tst, (Addr)ptrV ); /* Perhaps we should keep going regardless. */ VGP_POPCC; return NULL; @@ -448,7 +448,7 @@ void* VG_(client_realloc) ( ThreadState* tst, void* ptrV, UInt size_new ) if (sc->allockind != Vg_AllocMalloc) { /* can not realloc a range that was allocated with new or new [] */ - VG_(record_freemismatch_error) ( (Addr)ptrV ); + VG_(record_freemismatch_error) ( tst, (Addr)ptrV ); /* but keep going anyway */ } diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c index aa883d5bc2..3f44821456 100644 --- a/coregrind/vg_errcontext.c +++ b/coregrind/vg_errcontext.c @@ -546,7 +546,7 @@ static void VG_(maybe_add_context) ( ErrContext* ec ) /*--- Exported fns ---*/ /*------------------------------------------------------------*/ -/* These are all called from generated code, so that the %EIP/%EBP +/* These two are called from generated code, so that the %EIP/%EBP values that we need in order to create proper error messages are picked up out of VG_(baseBlock) rather than from the thread table (vg_threads in vg_scheduler.c). */ @@ -589,41 +589,39 @@ void VG_(record_address_error) ( Addr a, Int size, Bool isWrite ) VG_(maybe_add_context) ( &ec ); } -void VG_(record_free_error) ( Addr a ) + +/* These five are called not from generated code but in response to + requests passed back to the scheduler. So we pick up %EIP/%EBP + values from the stored thread state, not from VG_(baseBlock). */ + +void VG_(record_free_error) ( ThreadState* tst, Addr a ) { ErrContext ec; clear_ErrContext( &ec ); ec.count = 1; ec.next = NULL; - ec.where = VG_(get_ExeContext)( True, VG_(baseBlock)[VGOFF_(m_eip)], - VG_(baseBlock)[VGOFF_(m_ebp)] ); + ec.where = VG_(get_ExeContext)( True, tst->m_eip, tst->m_ebp ); ec.ekind = FreeErr; ec.addr = a; - ec.tid = VG_(get_current_tid)(); + ec.tid = tst->tid; VG_(describe_addr) ( a, &ec.addrinfo ); VG_(maybe_add_context) ( &ec ); } -void VG_(record_freemismatch_error) ( Addr a ) +void VG_(record_freemismatch_error) ( ThreadState* tst, Addr a ) { ErrContext ec; clear_ErrContext( &ec ); ec.count = 1; ec.next = NULL; - ec.where = VG_(get_ExeContext)( True, VG_(baseBlock)[VGOFF_(m_eip)], - VG_(baseBlock)[VGOFF_(m_ebp)] ); + ec.where = VG_(get_ExeContext)( True, tst->m_eip, tst->m_ebp ); ec.ekind = FreeMismatchErr; ec.addr = a; - ec.tid = VG_(get_current_tid)(); + ec.tid = tst->tid; VG_(describe_addr) ( a, &ec.addrinfo ); VG_(maybe_add_context) ( &ec ); } - -/* These three are called not from generated code but in response to - requests passed back to the scheduler. So we pick up %EIP/%EBP - values from the stored thread state, not from VG_(baseBlock). */ - void VG_(record_jump_error) ( ThreadState* tst, Addr a ) { ErrContext ec; diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index 3f9a10ce12..1c72ac0d05 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -1061,8 +1061,8 @@ extern Bool VG_(eq_ExeContext_all) ( ExeContext* e1, ExeContext* e2 ); extern void VG_(load_suppressions) ( void ); extern void VG_(show_all_errors) ( void ); extern void VG_(record_value_error) ( Int size ); -extern void VG_(record_free_error) ( Addr a ); -extern void VG_(record_freemismatch_error) ( Addr a ); +extern void VG_(record_free_error) ( ThreadState* tst, Addr a ); +extern void VG_(record_freemismatch_error) ( ThreadState* tst, Addr a ); extern void VG_(record_address_error) ( Addr a, Int size, Bool isWrite ); diff --git a/vg_clientmalloc.c b/vg_clientmalloc.c index b1848405aa..607c633b98 100644 --- a/vg_clientmalloc.c +++ b/vg_clientmalloc.c @@ -334,14 +334,14 @@ void VG_(client_free) ( ThreadState* tst, void* ptrV, VgAllocKind kind ) } if (sc == NULL) { - VG_(record_free_error) ( (Addr)ptrV ); + VG_(record_free_error) ( tst, (Addr)ptrV ); VGP_POPCC; return; } /* check if its a matching free() / delete / delete [] */ if (kind != sc->allockind) - VG_(record_freemismatch_error) ( (Addr) ptrV ); + VG_(record_freemismatch_error) ( tst, (Addr) ptrV ); /* Remove the shadow chunk from the mallocd list. */ remove_from_malloclist ( ml_no, sc ); @@ -440,7 +440,7 @@ void* VG_(client_realloc) ( ThreadState* tst, void* ptrV, UInt size_new ) } if (sc == NULL) { - VG_(record_free_error) ( (Addr)ptrV ); + VG_(record_free_error) ( tst, (Addr)ptrV ); /* Perhaps we should keep going regardless. */ VGP_POPCC; return NULL; @@ -448,7 +448,7 @@ void* VG_(client_realloc) ( ThreadState* tst, void* ptrV, UInt size_new ) if (sc->allockind != Vg_AllocMalloc) { /* can not realloc a range that was allocated with new or new [] */ - VG_(record_freemismatch_error) ( (Addr)ptrV ); + VG_(record_freemismatch_error) ( tst, (Addr)ptrV ); /* but keep going anyway */ } diff --git a/vg_errcontext.c b/vg_errcontext.c index aa883d5bc2..3f44821456 100644 --- a/vg_errcontext.c +++ b/vg_errcontext.c @@ -546,7 +546,7 @@ static void VG_(maybe_add_context) ( ErrContext* ec ) /*--- Exported fns ---*/ /*------------------------------------------------------------*/ -/* These are all called from generated code, so that the %EIP/%EBP +/* These two are called from generated code, so that the %EIP/%EBP values that we need in order to create proper error messages are picked up out of VG_(baseBlock) rather than from the thread table (vg_threads in vg_scheduler.c). */ @@ -589,41 +589,39 @@ void VG_(record_address_error) ( Addr a, Int size, Bool isWrite ) VG_(maybe_add_context) ( &ec ); } -void VG_(record_free_error) ( Addr a ) + +/* These five are called not from generated code but in response to + requests passed back to the scheduler. So we pick up %EIP/%EBP + values from the stored thread state, not from VG_(baseBlock). */ + +void VG_(record_free_error) ( ThreadState* tst, Addr a ) { ErrContext ec; clear_ErrContext( &ec ); ec.count = 1; ec.next = NULL; - ec.where = VG_(get_ExeContext)( True, VG_(baseBlock)[VGOFF_(m_eip)], - VG_(baseBlock)[VGOFF_(m_ebp)] ); + ec.where = VG_(get_ExeContext)( True, tst->m_eip, tst->m_ebp ); ec.ekind = FreeErr; ec.addr = a; - ec.tid = VG_(get_current_tid)(); + ec.tid = tst->tid; VG_(describe_addr) ( a, &ec.addrinfo ); VG_(maybe_add_context) ( &ec ); } -void VG_(record_freemismatch_error) ( Addr a ) +void VG_(record_freemismatch_error) ( ThreadState* tst, Addr a ) { ErrContext ec; clear_ErrContext( &ec ); ec.count = 1; ec.next = NULL; - ec.where = VG_(get_ExeContext)( True, VG_(baseBlock)[VGOFF_(m_eip)], - VG_(baseBlock)[VGOFF_(m_ebp)] ); + ec.where = VG_(get_ExeContext)( True, tst->m_eip, tst->m_ebp ); ec.ekind = FreeMismatchErr; ec.addr = a; - ec.tid = VG_(get_current_tid)(); + ec.tid = tst->tid; VG_(describe_addr) ( a, &ec.addrinfo ); VG_(maybe_add_context) ( &ec ); } - -/* These three are called not from generated code but in response to - requests passed back to the scheduler. So we pick up %EIP/%EBP - values from the stored thread state, not from VG_(baseBlock). */ - void VG_(record_jump_error) ( ThreadState* tst, Addr a ) { ErrContext ec; diff --git a/vg_include.h b/vg_include.h index 3f9a10ce12..1c72ac0d05 100644 --- a/vg_include.h +++ b/vg_include.h @@ -1061,8 +1061,8 @@ extern Bool VG_(eq_ExeContext_all) ( ExeContext* e1, ExeContext* e2 ); extern void VG_(load_suppressions) ( void ); extern void VG_(show_all_errors) ( void ); extern void VG_(record_value_error) ( Int size ); -extern void VG_(record_free_error) ( Addr a ); -extern void VG_(record_freemismatch_error) ( Addr a ); +extern void VG_(record_free_error) ( ThreadState* tst, Addr a ); +extern void VG_(record_freemismatch_error) ( ThreadState* tst, Addr a ); extern void VG_(record_address_error) ( Addr a, Int size, Bool isWrite ); -- 2.47.2