add_segment( &seg );
}
+Bool
+VG_(am_is_valid_for_aspacem_minAddr)( Addr addr, const HChar **errmsg )
+{
+ const Addr min = 0x1000; // 1 page FIXME: VKI_PAGE_SIZE ?
+#if VG_WORDSIZE == 4
+ const Addr max = 0x40000000; // 1Gb
+#else
+ const Addr max = 0x200000000; // 8Gb
+#endif
+ Bool ok = VG_IS_PAGE_ALIGNED(addr) && addr >= min && addr <= max;
+
+ if (errmsg) {
+ *errmsg = "";
+ if (! ok) {
+ const HChar fmt[] = "Must be a page aligned address between "
+ "0x%lx and 0x%lx";
+ static HChar buf[sizeof fmt + 2 * 16]; // large enough
+ ML_(am_sprintf)(buf, fmt, min, max);
+ *errmsg = buf;
+ }
+ }
+ return ok;
+}
+
/* See description in pub_core_aspacemgr.h */
Addr VG_(am_startup) ( Addr sp_at_startup )
{
if VG_BINT_CLO(argv[i], "--redzone-size", VG_(clo_redzone_size),
0, MAX_CLO_REDZONE_SZB) {}
if VG_STR_CLO(argv[i], "--aspace-minaddr", tmp_str) {
-# if VG_WORDSIZE == 4
- const Addr max = (Addr) 0x40000000; // 1Gb
-# else
- const Addr max = (Addr) 0x200000000; // 8Gb
-# endif
Bool ok = VG_(parse_Addr) (&tmp_str, &VG_(clo_aspacem_minAddr));
if (!ok)
VG_(fmsg_bad_option)(argv[i], "Invalid address\n");
-
- if (!VG_IS_PAGE_ALIGNED(VG_(clo_aspacem_minAddr))
- || VG_(clo_aspacem_minAddr) < (Addr) 0x1000
- || VG_(clo_aspacem_minAddr) > max) // 1Gb
- VG_(fmsg_bad_option)(argv[i],
- "Must be a page aligned address between "
- "0x1000 and 0x%lx\n", max);
+ const HChar *errmsg;
+ if (!VG_(am_is_valid_for_aspacem_minAddr)(VG_(clo_aspacem_minAddr),
+ &errmsg))
+ VG_(fmsg_bad_option)(argv[i], "%s\n", errmsg);
}
}
suggested end address (highest addressable byte) for the client's stack. */
extern Addr VG_(am_startup) ( Addr sp_at_startup );
+/* Check whether ADDR is OK to be used as aspacem_minAddr. If not, *ERRMSG
+ will be set to identify what's wrong. ERRMSG may be NULL. */
+extern Bool VG_(am_is_valid_for_aspacem_minAddr)( Addr addr,
+ const HChar **errmsg );
//--------------------------------------------------------------
// Querying current status