|
From: <sv...@va...> - 2007-12-22 14:12:56
|
Author: sewardj
Date: 2007-12-22 14:12:42 +0000 (Sat, 22 Dec 2007)
New Revision: 7306
Log:
AIX5 counterpart to r7302: Improve handling of programs which require
very large main thread stacks.
Modified:
trunk/auxprogs/aix5_VKI_info.c
trunk/coregrind/m_aspacemgr/aspacemgr-aix5.c
trunk/coregrind/m_main.c
trunk/include/vki/vki-ppc32-aix5.h
trunk/include/vki/vki-ppc64-aix5.h
Modified: trunk/auxprogs/aix5_VKI_info.c
===================================================================
--- trunk/auxprogs/aix5_VKI_info.c 2007-12-21 10:24:24 UTC (rev 7305)
+++ trunk/auxprogs/aix5_VKI_info.c 2007-12-22 14:12:42 UTC (rev 7306)
@@ -268,6 +268,7 @@
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);
Modified: trunk/coregrind/m_aspacemgr/aspacemgr-aix5.c
===================================================================
--- trunk/coregrind/m_aspacemgr/aspacemgr-aix5.c 2007-12-21 10:24:24 UTC (rev 7305)
+++ trunk/coregrind/m_aspacemgr/aspacemgr-aix5.c 2007-12-22 14:12:42 UTC (rev 7306)
@@ -201,8 +201,10 @@
/* 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 @@
{
static Bool done = False;
AixSegment seg;
+ Word n_fake_stack_pages;
+ Word m1 = 1048576;
aspacem_assert(!done);
done = True;
@@ -1180,7 +1184,6 @@
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,8 +1200,30 @@
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);
add_asegment( &asegs_pri, &seg );
Modified: trunk/coregrind/m_main.c
===================================================================
--- trunk/coregrind/m_main.c 2007-12-21 10:24:24 UTC (rev 7305)
+++ trunk/coregrind/m_main.c 2007-12-22 14:12:42 UTC (rev 7306)
@@ -1470,12 +1470,14 @@
# 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 @@
= 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
Modified: trunk/include/vki/vki-ppc32-aix5.h
===================================================================
--- trunk/include/vki/vki-ppc32-aix5.h 2007-12-21 10:24:24 UTC (rev 7305)
+++ trunk/include/vki/vki-ppc32-aix5.h 2007-12-22 14:12:42 UTC (rev 7306)
@@ -290,6 +290,7 @@
#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
Modified: trunk/include/vki/vki-ppc64-aix5.h
===================================================================
--- trunk/include/vki/vki-ppc64-aix5.h 2007-12-21 10:24:24 UTC (rev 7305)
+++ trunk/include/vki/vki-ppc64-aix5.h 2007-12-22 14:12:42 UTC (rev 7306)
@@ -292,6 +292,7 @@
#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
|