Second try at getting rid of the is_self() hack used to decide when to

load debug info from the V executable.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5033
This commit is contained in:
Julian Seward 2005-11-08 00:45:47 +00:00
parent 41690bf0f4
commit f1ead573e8
4 changed files with 29 additions and 20 deletions

View File

@ -130,14 +130,6 @@ static void unload_symbols ( Addr start, SizeT length );
that third segment, which is wrong and causes crashes.
*/
/* Make a guess (doesn't have to be 100% correct) as to whether a path
is that of the valgrind exe we're using. */
static Bool is_self ( HChar* filename )
{
return VG_(strstr)( filename, "/lib/valgrind/" ) != NULL
|| VG_(strstr)( filename, ".in_place/" ) != NULL;
}
static void nuke_syms_in_range ( Addr start, SizeT length )
{
/* Repeatedly scan the segInfo list, looking for segInfos in this
@ -168,7 +160,14 @@ static void nuke_syms_in_range ( Addr start, SizeT length )
}
}
void VG_(di_notify_mmap)( Addr a )
/* Notify the debuginfo system about a new mapping. This is the way
new debug information gets loaded. If allow_SkFileV is True, it
will try load debug info if the mapping at 'a' belongs to Valgrind;
whereas normally (False) it will not do that. This allows us to
carefully control when the thing will read symbols from the
Valgrind executable itself. */
void VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV )
{
NSegment* seg;
HChar* filename;
@ -183,13 +182,13 @@ void VG_(di_notify_mmap)( Addr a )
filename = VG_(arena_strdup)( VG_AR_SYMTAB, filename );
ok = (seg->kind == SkFileC || (seg->kind == SkFileV && is_self(filename)))
&& seg->offset == 0
&& seg->fnIdx != -1
&& seg->hasR
&& seg->hasX
&& !seg->hasW
&& is_elf_object_file( (const void*)seg->start );
ok = (seg->kind == SkFileC || (seg->kind == SkFileV && allow_SkFileV))
&& seg->offset == 0
&& seg->fnIdx != -1
&& seg->hasR
&& seg->hasX
&& !seg->hasW
&& is_elf_object_file( (const void*)seg->start );
if (!ok) {
VG_(arena_free)(VG_AR_SYMTAB, filename);

View File

@ -2321,9 +2321,11 @@ Int main(Int argc, HChar **argv, HChar **envp)
seg_starts = get_seg_starts( &n_seg_starts );
vg_assert(seg_starts && n_seg_starts > 0);
/* show them all to the debug info reader */
/* show them all to the debug info reader. allow_SkFileV has to
be True here so that we read info from the valgrind executable
itself. */
for (i = 0; i < n_seg_starts; i++)
VG_(di_notify_mmap)( seg_starts[i] );
VG_(di_notify_mmap)( seg_starts[i], True/*allow_SkFileV*/ );
VG_(free)( seg_starts );
}

View File

@ -1854,7 +1854,7 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid,
arg5, arg6
);
/* Load symbols? */
VG_(di_notify_mmap)( (Addr)sres.val );
VG_(di_notify_mmap)( (Addr)sres.val, False/*allow_SkFileV*/ );
}
/* Stay sane */

View File

@ -41,8 +41,16 @@
#include "pub_tool_debuginfo.h"
extern void VG_(di_notify_mmap)( Addr a );
/* Notify the debuginfo system about a new mapping. This is the way
new debug information gets loaded. If allow_SkFileV is True, it
will try load debug info if the mapping at 'a' belongs to Valgrind;
whereas normally (False) it will not do that. This allows us to
carefully control when the thing will read symbols from the
Valgrind executable itself. */
extern void VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV );
extern void VG_(di_notify_munmap)( Addr a, SizeT len );
extern void VG_(di_notify_mprotect)( Addr a, SizeT len, UInt prot );
extern SegInfo *VG_(read_seg_symbols) ( Addr addr, SizeT len,