]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Hide the --max-guard-pages cmdline switch on non-linux
authorMartin Cermak <mcermak@redhat.com>
Wed, 1 Apr 2026 12:46:11 +0000 (14:46 +0200)
committerMartin Cermak <mcermak@redhat.com>
Wed, 1 Apr 2026 12:46:11 +0000 (14:46 +0200)
Hide the --max-guard-pages command line switch on non-linux,
update none/tests/cmdline{1,2} accordingly.  Related to bug

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

coregrind/m_addrinfo.c
coregrind/m_main.c
coregrind/m_options.c
coregrind/pub_core_options.h
none/tests/cmdline1.stdout.exp-non-linux
none/tests/cmdline2.stdout.exp-non-linux

index 1bce6aa8e046f6debb772f618256206d3d458d73..6615bbca605b5a387ff7c57e298ad7412d26532b 100644 (file)
@@ -228,8 +228,8 @@ void VG_(describe_addr) ( DiEpoch ep, Addr a, /*OUT*/AddrInfo* ai )
       if (tid != VG_INVALID_THREADID) {
          /* Should be below stack pointer, as if it is >= SP, it
             will have been described as StackPos_stacked above. */
-         const NSegment *seg = VG_(am_find_nsegment) (a);
 #if defined(VGO_linux)
+         const NSegment *seg = VG_(am_find_nsegment) (a);
          /* On linux we might be hitting madvise guard pages, bug 514297 */
          if (seg->hasGuardPages && VG_(is_guarded)(a) ) {
             stackPos = StackPos_guard_page;
index b707fd9876d6789f0606252bdb738386ebc1044d..d364c6fc34d1364a5d157a2fc4e7c6cbf6891054 100644 (file)
@@ -254,8 +254,10 @@ static void usage_NORETURN ( int need_help )
 "              attempt to avoid expensive address-space-resync operations\n"
 "    --max-threads=<number>     maximum number of threads that valgrind can\n"
 "                               handle [%d]\n"
+#if defined(VGO_linux)
 "    --max-guard-pages=<number> maximum number of madvise guard pages that\n"
 "                               valgrind can handle [%d]\n"
+#endif
 "\n";
 
    const HChar usage2[] =
@@ -381,8 +383,10 @@ static void usage_NORETURN ( int need_help )
                   VG_(clo_vgdb_poll)         /* int */,
                   VG_(vgdb_prefix_default)() /* char* */,
                   N_SECTORS_DEFAULT          /* int */,
-                  MAX_THREADS_DEFAULT        /* int */,
-                  MAX_GUARDS_DEFAULT         /* int */
+                  MAX_THREADS_DEFAULT        /* int */
+#if defined(VGO_linux)
+                , MAX_GUARDS_DEFAULT         /* int */
+#endif
                );
    if (need_help > 1 && VG_(details).name) {
       VG_(printf)("  user options for %s:\n", VG_(details).name);
@@ -516,14 +520,18 @@ static void process_option (Clo_Mode mode,
 
    // Set up VG_(clo_max_threads); needed for VG_(tl_pre_clo_init)
    else if VG_INT_CLOM(cloE, arg, "--max-threads", VG_(clo_max_threads)) {
+#if defined(VGO_linux)
       // VG_(clo_max_guard_pages) defaults to VG_(clo_max_threads)
       // unless explititly set otherwise - below.  With glibc upstream
       // commit a6fbe36b7f31 and others, a guard page is installed for
       // each new thread.
       VG_(clo_max_guard_pages) = VG_(clo_max_threads);
+#endif
    }
+#if defined(VGO_linux)
    // Set up VG_(clo_max_guard_pages); needed for aspacemgr init
    else if VG_INT_CLOM(cloE, arg, "--max-guard-pages", VG_(clo_max_guard_pages)) {}
+#endif
 
    // Set up VG_(clo_sim_hints). This is needed a.o. for an inner
    // running in an outer, to have "no-inner-prefix" enabled
@@ -1367,13 +1375,17 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
             VG_(fmsg_bad_option)(argv[i], "%s\n", errmsg);
       }
       if VG_INT_CLOM(cloE, argv[i], "--max-threads", VG_(clo_max_threads)) {
+#if defined(VGO_linux)
          // VG_(clo_max_guard_pages) defaults to VG_(clo_max_threads)
          // unless explititly set otherwise - below.  With glibc upstream
          // commit a6fbe36b7f31 and others, a guard page is installed for
          // each new thread.
          VG_(clo_max_guard_pages) = VG_(clo_max_threads);
+#endif
       }
+#if defined(VGO_linux)
       if VG_INT_CLOM(cloE, argv[i], "--max-guard-pages", VG_(clo_max_guard_pages)) {}
+#endif
    }
 
    /* ... and start the debug logger.  Now we can safely emit logging
index faf095b2183967241203b1308a98aeaa97b00d76..5373cbff277b7a98cc3d92f49fc95a513c0f4c13 100644 (file)
@@ -188,7 +188,9 @@ Bool   VG_(clo_keep_debuginfo) = False;
 Bool   VG_(clo_show_emwarns)   = False;
 Word   VG_(clo_max_stackframe) = 2000000;
 UInt   VG_(clo_max_threads)    = MAX_THREADS_DEFAULT;
+#if defined(VGO_linux)
 UInt   VG_(clo_max_guard_pages) = MAX_GUARDS_DEFAULT;
+#endif
 Word   VG_(clo_main_stacksize) = 0; /* use client's rlimit.stack */
 Word   VG_(clo_valgrind_stacksize) = VG_DEFAULT_STACK_ACTIVE_SZB;
 Bool   VG_(clo_wait_for_gdb)   = False;
index f6b84ea8c4cfb2332f93ea76d1958e915afd5860..5ee0201e46f3b5bfcc1bf93f2a60ddc90b032a5d 100644 (file)
@@ -327,8 +327,10 @@ extern Word VG_(clo_main_stacksize);
 extern UInt VG_(clo_max_threads);
 
 /* The maximum number of madvise guard pages we support. */
+#if defined(VGO_linux)
 #define MAX_GUARDS_DEFAULT 500
 extern UInt VG_(clo_max_guard_pages);
+#endif
 
 /* If the same IP is found twice in a backtrace in a sequence of max
    VG_(clo_merge_recursive_frames) frames, then the recursive call
index 9b044e78a17cc654f74181178074b0ab96073334..340e8496ea8bff5fb0fb2ee0e61daf673804a623 100644 (file)
@@ -161,8 +161,8 @@ usage: valgrind [options] prog-and-args
                   recovered by stack scanning [5]
     --resync-filter=no|yes|verbose [yes on MacOS, no on other OSes]
               attempt to avoid expensive address-space-resync operations
-    --max-threads=<number>    maximum number of threads that valgrind can
-                              handle [500]
+    --max-threads=<number>     maximum number of threads that valgrind can
+                               handle [500]
 
   user options for Nulgrind:
     (none)
index 19c282b7f6159d7409b4aecf2adebb51b0a51c6b..6a96927c131fc4ffda99d5a4d99a0f882718d0f4 100644 (file)
@@ -161,8 +161,8 @@ usage: valgrind [options] prog-and-args
                   recovered by stack scanning [5]
     --resync-filter=no|yes|verbose [yes on MacOS, no on other OSes]
               attempt to avoid expensive address-space-resync operations
-    --max-threads=<number>    maximum number of threads that valgrind can
-                              handle [500]
+    --max-threads=<number>     maximum number of threads that valgrind can
+                               handle [500]
 
   user options for Nulgrind:
     (none)