]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Second try at getting rid of the is_self() hack used to decide when to
authorJulian Seward <jseward@acm.org>
Tue, 8 Nov 2005 00:45:47 +0000 (00:45 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 8 Nov 2005 00:45:47 +0000 (00:45 +0000)
load debug info from the V executable.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5033

coregrind/m_debuginfo/symtab.c
coregrind/m_main.c
coregrind/m_syswrap/syswrap-generic.c
coregrind/pub_core_debuginfo.h

index 8b798429c4146d5635fa5625340f786c951b8cc6..7420424966e9feb909143e5d62d44cf7a720ffed 100644 (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);
index 65f3396eb3e7f4b55a0b1c507f786dab3f784c68..e7d0c70dc7c8bee31d1769ad482dba4193e65516 100644 (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 );
    }
index 75c2dce564f05f477786d4c7e2dfffce75f9899d..4c2bd7b14bf46fbd35d5b4003f6d7d303817ab6c 100644 (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 */
index 94a76ea7af2e20d4c400804dd4abaf714a441839..a0b90366f37c518192f3393a5e015f5c1b7dd992 100644 (file)
 
 #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,