https://bugs.kde.org/show_bug.cgi?id=433510

Mark Wielaard <m...@klomp.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m...@klomp.org

--- Comment #3 from Mark Wielaard <m...@klomp.org> ---
We really should rename coregrind/m_aspacemgr/aspacemgr-linux.c one day...

This code formatting is really ugly/unreadable:

@@ -2165,13 +2248,21 @@ VG_(am_notify_client_mmap)( Addr a, SizeT len, UInt
prot, UInt flags,
    needDiscard = any_Ts_in_range( a, len );

    init_nsegment( &seg );
-   seg.kind   = (flags & VKI_MAP_ANONYMOUS) ? SkAnonC : SkFileC;
+   seg.kind   = (flags & (VKI_MAP_ANONYMOUS
+#if defined(VGO_freebsd)
+ | VKI_MAP_STACK
+#endif
+)) ? SkAnonC : SkFileC;
    seg.start  = a;
    seg.end    = a + len - 1;
    seg.hasR   = toBool(prot & VKI_PROT_READ);
    seg.hasW   = toBool(prot & VKI_PROT_WRITE);
    seg.hasX   = toBool(prot & VKI_PROT_EXEC);
-   if (!(flags & VKI_MAP_ANONYMOUS)) {
+   if (!(flags & (VKI_MAP_ANONYMOUS
+#if defined(VGO_freebsd)
+ | VKI_MAP_STACK
+#endif
+))) {
       // Nb: We ignore offset requests in anonymous mmaps (see bug #126722)
       seg.offset = offset;
       if (ML_(am_get_fd_d_i_m)(fd, &dev, &ino, &mode)) {

Can't you define something like MAP_STACK_ ANONYMOUS to either
VKI_MAP_ANONYMOUS or VKI_MAP_ANONYMOUS | VKI_MAP_STACK and use that?

In coregrind/m_debuginfo/readelf.c there are various changes like:

@@ -1939,13 +2014,13 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
       const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rx)
-         TRACE_SYMTAB("rx_map:  avma %#lx   size %lu  foff %ld\n",
+         TRACE_SYMTAB("rx_map:  avma %#lx   size %lu  foff %lld\n",
                       map->avma, map->size, map->foff);
    }
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
       const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rw)
-         TRACE_SYMTAB("rw_map:  avma %#lx   size %lu  foff %ld\n",
+         TRACE_SYMTAB("rw_map:  avma %#lx   size %lu  foff %lld\n",
                       map->avma, map->size, map->foff);
    }

@@ -2166,7 +2246,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
       const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rx)
-         TRACE_SYMTAB("rx: at %#lx are mapped foffsets %ld .. %lu\n",
+         TRACE_SYMTAB("rx: at %#lx are mapped foffsets %lld .. %llu\n",
                       map->avma, map->foff, map->foff + map->size - 1 );
    }
    TRACE_SYMTAB("rx: contains these svma regions:\n");
@@ -2179,7 +2259,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
       const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rw)
-         TRACE_SYMTAB("rw: at %#lx are mapped foffsets %ld .. %lu\n",
+         TRACE_SYMTAB("rw: at %#lx are mapped foffsets %lld .. %llu\n",
                       map->avma, map->foff, map->foff + map->size - 1 );
    }
    TRACE_SYMTAB("rw: contains these svma regions:\n");
@@ -2222,7 +2302,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
          }
       }

-      TRACE_SYMTAB(" [sec %2ld]  %s %s  al%4u  foff %6ld .. %6lu  "
+      TRACE_SYMTAB(" [sec %2ld]  %s %s  al%4u  foff %6lld .. %6llu  "
                    "  svma %p  name \"%s\"\n", 
                    i, inrx ? "rx" : "  ", inrw ? "rw" : "  ", alyn,
                    foff, (size == 0) ? foff : foff+size-1, (void *) svma,
name);

Which causes warnings like:

m_debuginfo/readelf.c:2017:23: warning: format ‘%lld’ expects argument of type
‘long long int’, but argument 4 has type ‘OffT’ {aka ‘long int’} [-Wformat=]
 2017 |          TRACE_SYMTAB("rx_map:  avma %#lx   size %lu  foff %lld\n",
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2018 |                       map->avma, map->size, map->foff);
      |                                             ~~~~~~~~~
      |                                                |
      |                                                OffT {aka long int}
m_debuginfo/priv_storage.h:1199:44: note: in definition of macro ‘TRACE_SYMTAB’
 1199 |    if (TRACE_SYMTAB_ENABLED) { VG_(printf)(format, ## args); }
      |                                            ^~~~~~
m_debuginfo/readelf.c:2017:63: note: format string is defined here
 2017 |          TRACE_SYMTAB("rx_map:  avma %#lx   size %lu  foff %lld\n",
      |                                                            ~~~^
      |                                                               |
      |                                                               long long
int
      |                                                            %ld
In file included from m_debuginfo/readelf.c:53:
m_debuginfo/readelf.c:2023:23: warning: format ‘%lld’ expects argument of type
‘long long int’, but argument 4 has type ‘OffT’ {aka ‘long int’} [-Wformat=]
 2023 |          TRACE_SYMTAB("rw_map:  avma %#lx   size %lu  foff %lld\n",
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2024 |                       map->avma, map->size, map->foff);
      |                                             ~~~~~~~~~
      |                                                |
      |                                                OffT {aka long int}
m_debuginfo/priv_storage.h:1199:44: note: in definition of macro ‘TRACE_SYMTAB’
 1199 |    if (TRACE_SYMTAB_ENABLED) { VG_(printf)(format, ## args); }
      |                                            ^~~~~~
m_debuginfo/readelf.c:2023:63: note: format string is defined here
 2023 |          TRACE_SYMTAB("rw_map:  avma %#lx   size %lu  foff %lld\n",
      |                                                            ~~~^
      |                                                               |
      |                                                               long long
int
      |                                                            %ld


In coregrind/m_debuginfo/storage.c we have:

+#if defined(VGO_freebsd)
+   if (sym->size == 0)
+      sym->size = 1;
+#endif
+
    /* Ignore zero-sized syms. */
    if (sym->size == 0) return;

Why? Do we not want to ignore zero-sized syms? Are those really size 1?

coregrind/pub_core_gdbserver.h What is the padding in padding? I see it is
actually set in coregrind/m_gdbserver/remote-utils.c remote_open. But why?

The logic and the defines feel swapped in VG_(is32on64)(void). But I might
misunderstand why the check for that file is done.

 /* Number of file descriptors that Valgrind tries to reserve for
    its own use - just a small constant. */
+#if defined(VGO_freebsd)
+#define N_RESERVED_FDS (20)
+#else
 #define N_RESERVED_FDS (12)
+#endif

Why does FreeBSD need 8 more?

I don't understand what SIGSYS is/does. This patch adds/clears it
unconditionally, not just for freebsd. Is that correct?

Why this in coregrind/m_main.c

+void *memcpy(void *dest, const void *src, size_t n);
+void *memcpy(void *dest, const void *src, size_t n) {
+   return VG_(memcpy)(dest, src, n);
+}
+void* memmove(void *dest, const void *src, SizeT n);
+void* memmove(void *dest, const void *src, SizeT n) {
+   return VG_(memmove)(dest,src,n);
+}
+void* memset(void *s, int c, SizeT n);
+void* memset(void *s, int c, SizeT n) {
+  return VG_(memset)(s,c,n);
+}

aha, this is where the realloc support is added. Dont forget to close bug
#407589.

Was this deliberate?

diff --git a/coregrind/m_scheduler/sema.c b/coregrind/m_scheduler/sema.c
index 61e10dcf0..5954cdf8f 100644
--- a/coregrind/m_scheduler/sema.c
+++ b/coregrind/m_scheduler/sema.c
@@ -108,8 +108,8 @@ void ML_(sema_down)( vg_sema_t *sema, Bool as_LL )
    INNER_REQUEST(ANNOTATE_RWLOCK_ACQUIRED(sema, /*is_w*/1));

    if (ret != 1) 
-      VG_(debugLog)(0, "scheduler", 
-                       "VG_(sema_down): read returned %d\n", ret);
+      VG_(debugLog)(1, "scheduler",
+                       "ML_(sema_down): read returned %d\n", ret);

    if (ret == -VKI_EINTR)
       goto again;

This change:

@@ -2459,9 +2528,9 @@ void async_signalhandler ( Int sigNo,
    info->si_code = sanitize_si_code(info->si_code);

    if (VG_(clo_trace_signals))
-      VG_(dmsg)("async signal handler: signal=%d, tid=%u, si_code=%d, "
+      VG_(dmsg)("async signal handler: signal=%d, vgtid=%u, tid=%u,
si_code=%d, "
                 "exitreason %s\n",
-                sigNo, tid, info->si_code,
+                sigNo, VG_(gettid)(), tid, info->si_code,
                 VG_(name_of_VgSchedReturnCode)(tst->exitreason));

    /* See similar logic in VG_(poll_signals). */

Causes this warning:

m_signals.c: In function ‘async_signalhandler’:
m_signals.c:2531:58: warning: format ‘%u’ expects argument of type ‘unsigned
int’, but argument 3 has type ‘Int’ {aka ‘int’} [-Wformat=]
 2531 |       VG_(dmsg)("async signal handler: signal=%d, vgtid=%u, tid=%u,
si_code=%d, "
      |                                                         ~^
      |                                                          |
      |                                                          unsigned int
      |                                                         %u

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to