From f1ead573e87f2f1571ae3d0724020fc0f6e06bb5 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 8 Nov 2005 00:45:47 +0000 Subject: [PATCH] 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 --- coregrind/m_debuginfo/symtab.c | 31 +++++++++++++-------------- coregrind/m_main.c | 6 ++++-- coregrind/m_syswrap/syswrap-generic.c | 2 +- coregrind/pub_core_debuginfo.h | 10 ++++++++- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/coregrind/m_debuginfo/symtab.c b/coregrind/m_debuginfo/symtab.c index 8b798429c4..7420424966 100644 --- a/coregrind/m_debuginfo/symtab.c +++ b/coregrind/m_debuginfo/symtab.c @@ -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); diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 65f3396eb3..e7d0c70dc7 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -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 ); } diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 75c2dce564..4c2bd7b14b 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -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 */ diff --git a/coregrind/pub_core_debuginfo.h b/coregrind/pub_core_debuginfo.h index 94a76ea7af..a0b90366f3 100644 --- a/coregrind/pub_core_debuginfo.h +++ b/coregrind/pub_core_debuginfo.h @@ -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, -- 2.47.3