]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 507721 - Wire up illumos and Solaris mallinfo
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 19 Aug 2025 14:37:50 +0000 (16:37 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 19 Aug 2025 14:49:56 +0000 (16:49 +0200)
NEWS
configure.ac
coregrind/m_mallocfree.c
coregrind/m_replacemalloc/vg_replace_malloc.c
coregrind/m_scheduler/scheduler.c
coregrind/pub_core_mallocfree.h
coregrind/pub_core_replacemalloc.h
memcheck/tests/Makefile.am

diff --git a/NEWS b/NEWS
index d5aaee976753c3ce14dcb765af372d8d481245c7..e2c49a0ffb70e7b2648d753d0c14f70a55705188 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 506967  Implement and override mallinfo2
 506970  mmap needs an EBADF fd_allowed check
 507173  s390x: Crash when constant folding is disabled
+507721  Wire up illumos and Solaris mallinfo
 507853  faccessat and faccessat2 should handle AT_FDCWD and absolute paths
 507868  futimesat doesn't handle AT_FDCWD
 507873  Make fchmodat and fchmodat2 syscall wrappers accept AT_FDCWD
index 0d5633fc062a7b82737b5c0ef2c844596052a836..ee623b050fdc0e7b80b8d8dba5821f5e7f79a40f 100755 (executable)
@@ -4943,6 +4943,12 @@ AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_LIB([rt], [clock_gettime])
 AC_CHECK_LIB([rt], [timer_delete])
 
+if test "$VGCONF_OS" = "solaris" ; then
+# for mallinfo
+saved_LDFLAGS="$LDFLAGS"
+LDFLAGS="$saved_LDFLAGS -lmalloc"
+fi
+
 AC_CHECK_FUNCS([     \
         aligned_alloc \
         clock_gettime\
@@ -5013,6 +5019,10 @@ AC_CHECK_FUNCS([     \
         exterrctl
         ])
 
+if test "$VGCONF_OS" = "solaris" ; then
+LDFLAGS="$saved_LDFLAGS"
+fi
+
 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
 # libraries with any shared object and/or executable. This is NOT what we
 # want for e.g. vgpreload_core-x86-linux.so
index e7c80af71048ef3328ce81ee66f2524f58548286..a84bbeb3ad164431f85b9dd4ce0e77c287db4924 100644 (file)
@@ -2433,6 +2433,7 @@ void VG_(mallinfo) ( ThreadId tid, struct vg_mallinfo* mi )
    mi->keepcost = 0; // may want some value in here
 }
 
+#if defined(VGO_linux)
 // The aforementioned older function, mallinfo(), is deprecated since the type
 // used for the fields is too small.
 void VG_(mallinfo2) ( ThreadId tid, struct vg_mallinfo2* mi )
@@ -2467,6 +2468,7 @@ void VG_(mallinfo2) ( ThreadId tid, struct vg_mallinfo2* mi )
    mi->fordblks = free_blocks_size + VG_(free_queue_volume);
    mi->keepcost = 0; // may want some value in here
 }
+#endif
 
 SizeT VG_(arena_redzone_size) ( ArenaId aid )
 {
index 808096152b532afc0a11f9c86ef68bfd21a626d9..02134d672a0745a48b105c04792c53239506cacd 100644 (file)
@@ -2518,8 +2518,9 @@ static void panic(const char *str)
  MALLINFO(VG_Z_LIBC_SONAME, mallinfo);
  MALLINFO(SO_SYN_MALLOC,    mallinfo);
 
-#elif defined(VGO_darwin)
- //MALLINFO(VG_Z_LIBC_SONAME, mallinfo);
+#elif defined(VGO_solaris)
+ MALLINFO(VG_Z_LIBC_SONAME, mallinfo);
+ MALLINFO(SO_SYN_MALLOC,    mallinfo);
 
 #endif
 
@@ -2545,9 +2546,6 @@ static void panic(const char *str)
  MALLINFO2(VG_Z_LIBC_SONAME, mallinfo2);
  MALLINFO2(SO_SYN_MALLOC,    mallinfo2);
 
-#elif defined(VGO_darwin)
- //MALLINFO2(VG_Z_LIBC_SONAME, mallinfo2);
-
 #endif
 
 
index 1e77944cdde7baff3405ca9b78e7358068ab14a9..4862f2506aa9b819ef5c7a6206a996b1fafb1074 100644 (file)
@@ -2145,9 +2145,12 @@ void do_client_request ( ThreadId tid )
         info->tl___builtin_vec_delete = VG_(tdict).tool___builtin_vec_delete;
         info->tl___builtin_vec_delete_aligned = VG_(tdict).tool___builtin_vec_delete_aligned;
         info->tl_malloc_usable_size   = VG_(tdict).tool_malloc_usable_size;
-
+#if defined(VGO_linux) || defined(VGO_solaris)
         info->mallinfo                = VG_(mallinfo);
+#endif
+#if defined(VGO_linux)
         info->mallinfo2               = VG_(mallinfo2);
+#endif
         info->clo_trace_malloc        = VG_(clo_trace_malloc);
          info->clo_realloc_zero_bytes_frees    = VG_(clo_realloc_zero_bytes_frees);
 
index 3ae9eb486a976d8bd668b2e099654a303f6e08aa..1ab3a9f0822b9364ced8252f538325a00856c241 100644 (file)
@@ -91,6 +91,7 @@ typedef Int ArenaId;
 #  error Unknown platform
 #endif
 
+#if defined(VGO_linux)
 /* This struct definition MUST match the system one. */
 /* SVID2/XPG mallinfo structure */
 struct vg_mallinfo {
@@ -120,6 +121,22 @@ struct vg_mallinfo2 {
    SizeT fordblks; /* total non-inuse space */
    SizeT keepcost; /* top-most, releasable (via malloc_trim) space */
 };
+#elif defined(VGO_solaris)
+
+struct vg_mallinfo  {
+        unsigned long arena;    /* total space in arena */
+        unsigned long ordblks;  /* number of ordinary blocks */
+        unsigned long smblks;   /* number of small blocks */
+        unsigned long hblks;    /* number of holding blocks */
+        unsigned long hblkhd;   /* space in holding block headers */
+        unsigned long usmblks;  /* space in small blocks in use */
+        unsigned long fsmblks;  /* space in free small blocks */
+        unsigned long uordblks; /* space in ordinary blocks in use */
+        unsigned long fordblks; /* space in free ordinary blocks */
+        unsigned long keepcost; /* cost of enabling keep option */
+};
+
+#endif
 
 extern void* VG_(arena_malloc)  ( ArenaId arena, const HChar* cc, SizeT nbytes );
 extern void  VG_(arena_free)    ( ArenaId arena, void* ptr );
@@ -146,8 +163,12 @@ extern SizeT VG_(arena_malloc_usable_size) ( ArenaId aid, void* payload );
 
 extern SizeT VG_(arena_redzone_size) ( ArenaId aid );
 
+#if defined(VGO_linux) || defined(VGO_solaris)
 extern void  VG_(mallinfo) ( ThreadId tid, struct vg_mallinfo* mi );
+#endif
+#if defined(VGO_linux)
 extern void  VG_(mallinfo2) ( ThreadId tid, struct vg_mallinfo2* mi );
+#endif
 
 // VG_(arena_perm_malloc) is for permanent allocation of small blocks.
 // See VG_(perm_malloc) in pub_tool_mallocfree.h for more details.
index 4f9c5bb1a3275eb7020a407e075e6d8c3e1367f4..0c81e7c5509b360c9eacf04332877c5cdda8fd43 100644 (file)
@@ -53,8 +53,12 @@ struct vg_mallocfunc_info {
    void  (*tl___builtin_vec_delete_aligned)(ThreadId tid, void* p, SizeT n);
    void* (*tl_realloc)             (ThreadId tid, void* p, SizeT size);
    SizeT (*tl_malloc_usable_size)  (ThreadId tid, void* payload);
+#if defined(VGO_linux) || defined(VGO_solaris)
    void  (*mallinfo)               (ThreadId tid, struct vg_mallinfo* mi);
+#endif
+#if defined(VGO_linux)
    void  (*mallinfo2)              (ThreadId tid, struct vg_mallinfo2* mi);
+#endif
    Bool        clo_trace_malloc;
    Bool  clo_realloc_zero_bytes_frees;
 };
index 91d58b48b8ad32fdc32b366c081f74a9e8f1d1d3..349cdaf15d937a14207bb2c011cdb1abb614135d 100644 (file)
@@ -684,9 +684,16 @@ bug472219_CFLAGS   = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
 calloc_overflow_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_ALLOC_SIZE_LARGER_THAN@
 malloc_usable_CFLAGS   = ${AM_CFLAGS} @FLAG_W_NO_MAYBE_UNINITIALIZED@ @FLAG_W_NO_UNINITIALIZED@
 mallinfo_CFLAGS                = $(AM_CFLAGS) -Wno-deprecated-declarations
+if VGCONF_OS_IS_SOLARIS
+mallinfo_LDADD = -lmalloc
+endif
 mallinfo2_CFLAGS       = $(AM_CFLAGS) -Wno-deprecated-declarations
 malloc3_CFLAGS         = $(AM_CFLAGS) @FLAG_W_NO_ALLOC_SIZE_LARGER_THAN@
 sbfragment_CFLAGS      = $(AM_CFLAGS) -Wno-deprecated-declarations
+if VGCONF_OS_IS_SOLARIS
+sbfragment_LDADD = -lmalloc
+endif
+
 strchr_CFLAGS          = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
 
 big_debuginfo_symbol_SOURCES = big_debuginfo_symbol.cpp