Hi,

I have solved the problem of Valgrind not displaying function names
and file names when it detects a problem.


Could not display symbols with current Valgrind as below:
$ cd /usr/src/usr.bin/grep
$ make COPTS="-g
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/binary.c
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/file.c
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/grep.c
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/mmfile.c
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/queue.c
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/util.c
cc   -o grep binary.o file.o grep.o mmfile.o queue.o util.o -lz
$ valgrind obj/grep PATH /etc/skel/.profile
==67899== Memcheck, a memory error detector
==67899== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==67899== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==67899== Command: obj/grep PATH /etc/skel/.profile
==67899==
==67899== Use of uninitialised value of size 8
==67899==    at 0x49AD34D: ??? (in obj/grep)
==67899==    by 0x10EF2A: ??? (in obj/grep)
==67899==    by 0x10CDFF: ??? (in obj/grep)
==67899==    by 0x10CB02: ??? (in obj/grep)
==67899==    by 0x10B821: ??? (in obj/grep)

</snip>


And applied following patch as below:
$ cd /usr/src/usr.bin/grep                                                      
$ make COPTS="-g"                                                               
 
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/binary.c
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/file.c                 
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/grep.c 
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/mmfile.c               
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/queue.c                
cc -O2 -pipe  -Wall -g -MD -MP  -c /usr/src/usr.bin/grep/util.c
cc   -o grep binary.o file.o grep.o mmfile.o queue.o util.o -lz
$ valgrind obj/grep PATH /etc/skel/.profile                                     
==78943== Memcheck, a memory error detector                                     
==78943== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.       
==78943== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info    
==78943== Command: obj/grep PATH /etc/skel/.profile                             
==78943==                                                                       
==78943== Use of uninitialised value of size 8          
==78943==    at 0x49D9B0D: realloc (stdlib/malloc.c:1897)                       
==78943==    by 0x10EF2A: grep_reallocarray (util.c:615)                        
==78943==    by 0x10CDFF: add_pattern (grep.c:186)
==78943==    by 0x10CB02: add_patterns (grep.c:224)                             
==78943==    by 0x10CB02: main (grep.c:473)    

</snip>


comments, ok?
--
ASOU Masato

? devel/valgrind/old-patches
? devel/valgrind/patches/patch-coregrind_m_options_c
Index: devel/valgrind/patches/patch-coregrind_m_debuginfo_debuginfo_c
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-coregrind_m_debuginfo_debuginfo_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-coregrind_m_debuginfo_debuginfo_c
--- devel/valgrind/patches/patch-coregrind_m_debuginfo_debuginfo_c      18 Jul 
2023 06:17:15 -0000      1.1
+++ devel/valgrind/patches/patch-coregrind_m_debuginfo_debuginfo_c      3 Aug 
2023 06:52:29 -0000
@@ -27,7 +27,17 @@
     ok = ML_(read_elf_debug_info)( di );
  #  elif defined(VGO_darwin)
     ok = ML_(read_macho_debug_info)( di );
-@@ -1347,7 +1347,7 @@
+@@ -1265,6 +1265,9 @@
+       || defined(VGA_mips64) || defined(VGA_nanomips)
+    is_rx_map = seg->hasR && seg->hasX;
+    is_rw_map = seg->hasR && seg->hasW;
++#  elif defined(VGO_openbsd)
++   is_rx_map = seg->hasX;
++   is_rw_map = seg->hasR && seg->hasW;
+ #  elif defined(VGA_amd64) || defined(VGA_ppc64be) || defined(VGA_ppc64le)  \
+         || defined(VGA_arm) || defined(VGA_arm64)
+    is_rx_map = seg->hasR && seg->hasX && !seg->hasW;
+@@ -1347,7 +1350,7 @@
  #endif
  
     /* We're only interested in mappings of object files. */
@@ -36,7 +46,7 @@
  
     rw_load_count = 0;
  
-@@ -2408,7 +2408,7 @@
+@@ -2408,7 +2411,7 @@
         VG_STREQ("generic_start_main", name) ||  // Yellow Dog doggedness
         VG_STREQN(19, "generic_start_main.", name) || // gcc optimization
         VG_STREQ("_start", name) ||
Index: devel/valgrind/patches/patch-coregrind_m_debuginfo_readelf_c
===================================================================
RCS file: 
/cvs/ports/devel/valgrind/patches/patch-coregrind_m_debuginfo_readelf_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-coregrind_m_debuginfo_readelf_c
--- devel/valgrind/patches/patch-coregrind_m_debuginfo_readelf_c        18 Jul 
2023 06:17:15 -0000      1.3
+++ devel/valgrind/patches/patch-coregrind_m_debuginfo_readelf_c        3 Aug 
2023 06:52:29 -0000
@@ -30,7 +30,26 @@
        res = VG_(do_syscall3)(__NR_readlink, (UWord)path, (UWord)buf, bufsiz);
  #elif defined(VGO_solaris)
        res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, (UWord)path,
-@@ -2654,7 +2658,8 @@
+@@ -2141,6 +2145,18 @@
+                            i, (UWord)item.bias);
+                         loaded = True;
+                      }
++#if defined(VGO_openbsd)
++                     if (map->rx
++                         && (a_phdr.p_flags & (PF_X))
++                            == (PF_X)) {
++                        item.exec = True;
++                        VG_(addToXA)(svma_ranges, &item);
++                        TRACE_SYMTAB(
++                           "PT_LOAD[%ld]:   acquired as rx, bias 0x%lx\n",
++                           i, (UWord)item.bias);
++                        loaded = True;
++                     }
++#endif
+                      if (map->ro
+                          && (a_phdr.p_flags & (PF_R | PF_W | PF_X))
+                             == PF_R) {
+@@ -2654,7 +2670,8 @@
           || defined(VGP_mips32_linux) || defined(VGP_mips64_linux) \
           || defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) \
           || defined(VGP_x86_solaris) || defined(VGP_amd64_solaris) \
Index: devel/valgrind/patches/patch-include_vki_vki_openbsd_h
===================================================================
RCS file: /cvs/ports/devel/valgrind/patches/patch-include_vki_vki_openbsd_h,v
retrieving revision 1.1
diff -u -p -r1.1 patch-include_vki_vki_openbsd_h
--- devel/valgrind/patches/patch-include_vki_vki_openbsd_h      18 Jul 2023 
06:17:15 -0000      1.1
+++ devel/valgrind/patches/patch-include_vki_vki_openbsd_h      3 Aug 2023 
06:52:29 -0000
@@ -126,7 +126,7 @@
 +typedef  __vki_ct_rune_t   __vki_rune_t;
 +typedef  __vki_ct_rune_t   __vki_wchar_t;
 +typedef  __vki_ct_rune_t   __vki_wint_t;
-+typedef  vki_uint64_t   __vki_dev_t;
++typedef  vki_uint32_t   __vki_dev_t;
 +typedef  vki_uint32_t   __vki_fixpt_t;
 +
 +

Reply via email to