diff options
author | Neal H. Walfield <neal@gnu.org> | 2009-01-16 07:30:05 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2009-01-16 07:30:05 +0100 |
commit | 01162d90ca9c87c2afe78e56f723ed0ec0fd8edb (patch) | |
tree | 8b31e26adbedba643764cb945288f2853c9d4391 | |
parent | 8bebe06303f91c90b3fb5879da3f3b0a825c55d1 (diff) |
Add asserts to the activation test in mm-init.c.
2009-01-16 Neal H. Walfield <neal@gnu.org>
* mm-init.c (mm_init) [!NDEBUG && i386]: Clear STORAGE and assert
that it is not VG_ADDR_VOID before freeing the associated storage.
Assert that the fault callback was called.
-rw-r--r-- | libhurd-mm/ChangeLog | 6 | ||||
-rw-r--r-- | libhurd-mm/mm-init.c | 24 |
2 files changed, 23 insertions, 7 deletions
diff --git a/libhurd-mm/ChangeLog b/libhurd-mm/ChangeLog index 3207a4e..e72d016 100644 --- a/libhurd-mm/ChangeLog +++ b/libhurd-mm/ChangeLog @@ -1,5 +1,11 @@ 2009-01-16 Neal H. Walfield <neal@gnu.org> + * mm-init.c (mm_init) [!NDEBUG && i386]: Clear STORAGE and assert + that it is not VG_ADDR_VOID before freeing the associated storage. + Assert that the fault callback was called. + +2009-01-16 Neal H. Walfield <neal@gnu.org> + * bits.h (extract_bits): Make W a uintptr_t, not an unsigned int. (extract_bits_inv): Likewise. diff --git a/libhurd-mm/mm-init.c b/libhurd-mm/mm-init.c index 90b7112..01fc9b2 100644 --- a/libhurd-mm/mm-init.c +++ b/libhurd-mm/mm-init.c @@ -71,6 +71,8 @@ mm_init (vg_addr_t activity) mode activation handler, call the call back functions, and then return to the interrupted code. */ #ifdef i386 + int d = 5; + void test (int nesting) { vg_addr_t addr = as_alloc (PAGESIZE_LOG2, 1, true); @@ -78,7 +80,11 @@ mm_init (vg_addr_t activity) int recursed = false; + /* We allocate the storage in the fault handler. */ struct storage storage; + memset (&storage, 0, sizeof (storage)); + int faulted = false; + bool fault (struct pager *pager, uintptr_t offset, int count, bool ro, uintptr_t fault_addr, uintptr_t ip, @@ -89,7 +95,7 @@ mm_init (vg_addr_t activity) struct hurd_utcb *utcb = hurd_utcb (); struct activation_frame *activation_frame = utcb->activation_stack; - debug (4, "Fault at %p (ip: %p, sp: %p, eax: %p, " + debug (d, "Fault at %p (ip: %p, sp: %p, eax: %p, " "ebx: %p, ecx: %p, edx: %p, edi: %p, esi: %p, ebp: %p, " "eflags: %p)", fault, @@ -126,12 +132,14 @@ mm_init (vg_addr_t activity) int i; for (i = 0; i < 3; i ++) { - debug (5, "Depth: %d; iter: %d", nesting - 1, i); + debug (d, "Depth: %d; iter: %d", nesting - 1, i); test (nesting - 1); - debug (5, "Depth: %d; iter: %d done", nesting - 1, i); + debug (d, "Depth: %d; iter: %d done", nesting - 1, i); } } + faulted = true; + return true; } @@ -211,7 +219,7 @@ mm_init (vg_addr_t activity) : [addr] "m" (a) : "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi"); - debug (4, "Regsiter file: " + debug (d, "Regsiter file: " "eax: %p, ebx: %p, ecx: %p, edx: %p, " "edi: %p, esi: %p, ebp: %p -> %p, esp: %p -> %p, flags: %p -> %p", (void *) eax, (void *) ebx, (void *) ecx, (void *) edx, @@ -229,22 +237,24 @@ mm_init (vg_addr_t activity) assert (esp == pre_esp); assert (flags == pre_flags); assert (canary == 0xcab00d1e); + assert (faulted); maps_lock_lock (); map_disconnect (map); maps_lock_unlock (); map_destroy (map); - storage_free (storage.addr, false); + assert (! VG_ADDR_IS_VOID (storage.addr)); + storage_free (storage.addr, true); as_free (addr, 1); } int i; for (i = 0; i < 3; i ++) { - debug (5, "Depth: %d; iter: %d", 3, i + 1); + debug (d, "Depth: %d; iter: %d", 3, i + 1); test (3); - debug (5, "Depth: %d; iter: %d done", 3, i + 1); + debug (d, "Depth: %d; iter: %d done", 3, i + 1); } #endif #endif |