From: Masato Asou <a...@soum.co.jp>
Date: Fri, 04 Aug 2023 07:57:42 +0900 (JST)

> From: Omar Polo <o...@omarpolo.com>
> Date: Thu, 03 Aug 2023 23:36:06 +0200
> 
>>> > other than this, while the changes are a bit over my head, I've
>>> > quickly tested it and it seems to be working.  So, fwiw, OK op@.
>>> > 
>>> > I still get some ???  entries, for example with grep:
>>> > 
>>> >   $ make clean obj
>>> >   [...]
>>> >   $ make DEBUG='-O0 -g3'
>>> >   [...]
>>> >   $ valgrind obj/grep foo Makefile
>>> >   [...]
>>> >   ==31128== Use of uninitialised value of size 8
>>> >   ==31128==    at 0x49D935D: ??? (in obj/grep)
>>> >   ==31128==    by 0x10F385: grep_reallocarray (util.c:615)
>>> >   ==31128==    by 0x10D626: add_pattern (grep.c:186)
>>> >   ==31128==    by 0x10D426: add_patterns (grep.c:224)
>>> >   ==31128==    by 0x10D03C: main (grep.c:473)
>>> >   [...]
>>> 
>>> I also tried DEBUG="-O0 -g3", but ??? was not displayed.  Is your
>>> libc.so stripped?
>> 
>> nope.  while i've rebuilt and installed it, it's not stripped.  I can
>> set a breakpoint in, for e.g., reallocarray in egdb and step into libc
>> just fine.
>> 
>> Not a blocker for your diff IMHO since it improves the situation.
>> Given the tricky port I guess it's better to have this in.
> 
> I will investigate into it again.

I reproduced the problem in my OpenBSD and found the cause.  I forget
to attach the diff of coregrind/m_options.c.

comment, ok?
--
ASOU Masato

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/valgrind/Makefile,v
retrieving revision 1.30
diff -u -p -r1.30 Makefile
--- Makefile    18 Jul 2023 06:17:15 -0000      1.30
+++ Makefile    3 Aug 2023 23:09:52 -0000
@@ -5,6 +5,7 @@ CATEGORIES =            devel
 
 V =                    3.21.0
 DISTNAME =             valgrind-${V}
+REVISION =             0
 EXTRACT_SUFX =         .tar.bz2
 
 MASTER_SITES =         https://sourceware.org/pub/valgrind/
Index: 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
--- patches/patch-coregrind_m_debuginfo_debuginfo_c     18 Jul 2023 06:17:15 
-0000      1.1
+++ patches/patch-coregrind_m_debuginfo_debuginfo_c     3 Aug 2023 23:09:52 
-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: 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
--- patches/patch-coregrind_m_debuginfo_readelf_c       18 Jul 2023 06:17:15 
-0000      1.3
+++ patches/patch-coregrind_m_debuginfo_readelf_c       3 Aug 2023 23:09:52 
-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: patches/patch-coregrind_m_options_c
===================================================================
RCS file: patches/patch-coregrind_m_options_c
diff -N patches/patch-coregrind_m_options_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-coregrind_m_options_c 3 Aug 2023 23:09:52 -0000
@@ -0,0 +1,14 @@
+--- coregrind/m_options.c.orig
++++ coregrind/m_options.c
+@@ -181,7 +181,11 @@
+ XArray *VG_(clo_req_tsyms);  // array of strings
+ Bool   VG_(clo_run_libc_freeres) = True;
+ Bool   VG_(clo_run_cxx_freeres) = True;
++#if !defined(VGO_openbsd)
+ UInt   VG_(clo_track_fds)      = 0;
++#else
++UInt   VG_(clo_track_fds)      = 1;
++#endif
+ Bool   VG_(clo_show_below_main)= False;
+ Bool   VG_(clo_keep_debuginfo) = False;
+ Bool   VG_(clo_show_emwarns)   = False;
Index: 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
--- patches/patch-include_vki_vki_openbsd_h     18 Jul 2023 06:17:15 -0000      
1.1
+++ patches/patch-include_vki_vki_openbsd_h     3 Aug 2023 23:09:52 -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