]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
AIX5 counterpart to r7302: Improve handling of programs which require
authorJulian Seward <jseward@acm.org>
Sat, 22 Dec 2007 14:12:42 +0000 (14:12 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 22 Dec 2007 14:12:42 +0000 (14:12 +0000)
very large main thread stacks.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7306

auxprogs/aix5_VKI_info.c
coregrind/m_aspacemgr/aspacemgr-aix5.c
coregrind/m_main.c
include/vki/vki-ppc32-aix5.h
include/vki/vki-ppc64-aix5.h

index e597b6fe7f02b46b5cf7366e52aa34748e0b5c4e..b2095c810df364326c8d254e669c4da462226f13 100644 (file)
@@ -268,6 +268,7 @@ int main ( void )
    printf("#define VKI_SEGV_MAPERR %d\n", SEGV_MAPERR);
    printf("\n");
    printf("#define VKI_TRAP_TRACE %d\n", TRAP_TRACE);
+   printf("#define VKI_TRAP_BRKPT %d\n", TRAP_BRKPT);
    printf("#define VKI_BUS_OBJERR %d\n", BUS_OBJERR);
    printf("#define VKI_BUS_ADRERR %d\n", BUS_ADRERR);
    printf("#define VKI_BUS_ADRALN %d\n", BUS_ADRALN);
index 18f438a2aa60697a7745506ba8d18356d2a20221..89a862736de251690740a85f26fba26a0eae388e 100644 (file)
@@ -201,7 +201,9 @@ static AixSegments asegs_told;
 /* The assumed size of the main thread's stack, so that we can add a
    segment for it at startup. */
 
-#define N_FAKE_STACK_PAGES 4096 /* 16M fake stack */
+#define N_FAKE_STACK_PAGES_MIN 4096  /* 16M fake stack */ /* default size */
+#define N_FAKE_STACK_PAGES_MAX 32768 /* 128M fake stack */ /* max size? */
+
 
 /* Hacks which are probably for AIX 'millicode'.  Note: ensure
    these stay page aligned. */
@@ -1162,6 +1164,8 @@ void VG_(am_aix5_set_initial_client_sp)( Addr sp )
 {
    static Bool done = False;
    AixSegment  seg;
+   Word n_fake_stack_pages;
+   Word m1 = 1048576;
 
    aspacem_assert(!done);
    done = True;
@@ -1180,7 +1184,6 @@ void VG_(am_aix5_set_initial_client_sp)( Addr sp )
       0xFFF'FFFF'FFFF'E920, and the accessible area extends to
       0xFFF'FFFF'FFFF'FFFF.  So in both cases, (64k roundup of sp) - 1
       gives the end of the accessible area. */
-
    VG_(debugLog)(1,"aspacem", "aix5_set_initial_client_sp( %p )\n",
                    (void*)sp);
 
@@ -1197,7 +1200,29 @@ void VG_(am_aix5_set_initial_client_sp)( Addr sp )
       seg.end = AM_64K_ROUNDUP(sp) - 1;
    }
 
-   seg.start = seg.end+1 - N_FAKE_STACK_PAGES * VKI_PAGE_SIZE;
+   n_fake_stack_pages = N_FAKE_STACK_PAGES_MIN;
+   if (VG_(clo_main_stacksize) > 0 
+       && ((m1+VG_(clo_main_stacksize)) / VKI_PAGE_SIZE) > n_fake_stack_pages) {
+      n_fake_stack_pages = (m1+VG_(clo_main_stacksize)) / VKI_PAGE_SIZE;
+   }
+   if (n_fake_stack_pages > N_FAKE_STACK_PAGES_MAX) {
+      /* Allocation of the stack failed.  We have to stop. */
+      VG_(debugLog)(
+         0, "aspacem",
+            "valgrind: "
+            "I failed to allocate space for the application's stack.\n");
+      VG_(debugLog)(
+         0, "aspacem",
+            "valgrind: "
+            "This may be the result of a very large --max-stackframe=\n");
+      VG_(debugLog)(
+         0, "aspacem",
+            "valgrind: "
+            "setting.  Cannot continue.  Sorry.\n\n");
+      ML_(am_exit)(0);
+   }
+
+   seg.start = seg.end+1 - n_fake_stack_pages * VKI_PAGE_SIZE;
 
    VG_(debugLog)(1,"aspacem", "aix5_set_initial_client_sp: stack seg:\n");
    show_AixSegment(1,0, &seg);
index 50992f48a267401ef6ce5f31cf89867b95abdd95..85f3495975c21539894bcef9ba4b2035c501568a 100644 (file)
@@ -1470,12 +1470,14 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
 #       error "Uknown platform"
 #     endif
 
+      /* NOTE: this call reads VG_(clo_max_stackframe). */
       the_iifii = VG_(ii_create_image)( the_iicii );
 
 #     if defined(VGO_aix5)
       /* Tell aspacem where the initial client stack is, so that it
          can later produce a faked-up NSegment in response to
          VG_(am_find_nsegment) for that address range, if asked. */
+      /* NOTE: this call reads VG_(clo_max_stackframe). */
       VG_(am_aix5_set_initial_client_sp)( the_iifii.initial_client_SP );
       /* Now have a look at said fake segment, so we can find out
          the size of it. */
@@ -1484,7 +1486,7 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
            = VG_(am_find_nsegment)( the_iifii.initial_client_SP );
         vg_assert(seg);
         sz = seg->end - seg->start + 1;
-        vg_assert(sz >= 0 && sz <= 64*1024*1024); /* stay sane */
+        vg_assert(sz >= 0 && sz <= (256+1)*1024*1024); /* stay sane */
         the_iifii.clstack_max_size = sz;
       }
 #     endif
index 8cb3c82a656bb0a5f516c9f5a0bb551525d0fea6..76ad19d451ece738244f0ae667582e53faa6df44 100644 (file)
@@ -290,6 +290,7 @@ struct vki_sigaction {
 #define VKI_SEGV_MAPERR 50
 
 #define VKI_TRAP_TRACE 61
+#define VKI_TRAP_BRKPT 60
 #define VKI_BUS_OBJERR 3
 #define VKI_BUS_ADRERR 2
 #define VKI_BUS_ADRALN 1
index aec2347ae671880934f4e25ed828c5175734f4bf..fecbc8ca7312c3bd9d2ca350a03c51d249bfd957 100644 (file)
@@ -292,6 +292,7 @@ struct vki_sigaction {
 #define VKI_SEGV_MAPERR 50
 
 #define VKI_TRAP_TRACE 61
+#define VKI_TRAP_BRKPT 60
 #define VKI_BUS_OBJERR 3
 #define VKI_BUS_ADRERR 2
 #define VKI_BUS_ADRALN 1