summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneal <neal>2007-12-11 00:33:10 +0000
committerneal <neal>2007-12-11 00:33:10 +0000
commit7ec9017f2321e8256ca25c8124346333fb2bf18a (patch)
treeb56bc91bf0881f7ecda63178d248c32a6bc933e0
parent482384a64f6e856dd43750f7cdc1f1feb5743afa (diff)
2007-12-11 Neal H. Walfield <neal@gnu.org>
* as.c (AS_LOCK): New macro. (AS_UNLOCK): Likewise. (AS_DUMP): Likewise. (as_build_internal): Use the above macros. Unlock before dumping the address space. (as_slot_ensure_full): Use the above macros. (as_dump_from): Update comment. (do_walk): Don't display dead capabilities.
-rw-r--r--viengoos/ChangeLog12
-rw-r--r--viengoos/as.c43
2 files changed, 36 insertions, 19 deletions
diff --git a/viengoos/ChangeLog b/viengoos/ChangeLog
index 97d0eaa..2399fae 100644
--- a/viengoos/ChangeLog
+++ b/viengoos/ChangeLog
@@ -1,5 +1,17 @@
2007-12-11 Neal H. Walfield <neal@gnu.org>
+ * as.c (AS_LOCK): New macro.
+ (AS_UNLOCK): Likewise.
+ (AS_DUMP): Likewise.
+ (as_build_internal): Use the above macros. Unlock before dumping
+ the address space.
+ (as_slot_ensure_full): Use the above macros.
+ (as_dump_from): Update comment.
+
+ (do_walk): Don't display dead capabilities.
+
+2007-12-11 Neal H. Walfield <neal@gnu.org>
+
* t-link.c (output_debug): New declaration.
2007-12-11 Neal H. Walfield <neal@gnu.org>
diff --git a/viengoos/as.c b/viengoos/as.c
index 7cadd6e..53917c0 100644
--- a/viengoos/as.c
+++ b/viengoos/as.c
@@ -35,6 +35,16 @@
#ifndef RM_INTERN
pthread_rwlock_t as_lock = __PTHREAD_RWLOCK_INITIALIZER;
+# define AS_LOCK pthread_rwlock_wrlock (&as_lock)
+# define AS_UNLOCK pthread_rwlock_unlock (&as_lock)
+# define AS_DUMP rm_as_dump (ADDR_VOID, ADDR_VOID)
+
+#else
+
+# define AS_LOCK do { } while (0)
+# define AS_UNLOCK do { } while (0)
+# define AS_DUMP as_dump_from (activity, start, __func__);
+
#endif
/* Build the address space such that A designates a capability slot.
@@ -87,7 +97,7 @@ as_build_internal (activity_t activity,
object at ADDR. This is a problem: we want to insert a
capability at ADDR. */
{
- as_dump_from (activity, start, __func__);
+ AS_DUMP;
panic ("There is already a %s object at %llx/%d!",
cap_type_string (root->type),
addr_prefix (a), addr_depth (a));
@@ -106,7 +116,7 @@ as_build_internal (activity_t activity,
{
/* The type should now have been set to cap_void. */
assert (root->type == cap_void);
- as_dump_from (activity, root, __func__);
+ AS_DUMP;
panic ("Lost object at %llx/%d",
addr_prefix (a), addr_depth (a) - remaining);
}
@@ -163,7 +173,7 @@ as_build_internal (activity_t activity,
}
default:
- as_dump_from (activity, start, __func__);
+ AS_DUMP;
panic ("Can't insert object at %llx/%d: "
"%s at 0x%llx/%d does not translate address bits",
addr_prefix (a), addr_depth (a),
@@ -379,9 +389,10 @@ as_build_internal (activity_t activity,
/* That should not be more than we have left to translate. */
if (width > remaining)
{
- as_dump_from (activity, start, __func__);
- panic ("Can't index %d-bit cappage: not enough bits (%d)",
- width, remaining);
+ AS_DUMP;
+ panic ("Translating " ADDR_FMT ": can't index %d-bit cappage; "
+ "not enough bits (%d)",
+ ADDR_PRINTF (a), width, remaining);
}
int idx = extract_bits64_inv (addr, remaining - 1, width);
root = &cappage->caps[CAP_SUBPAGE_OFFSET (root) + idx];
@@ -418,16 +429,12 @@ as_slot_ensure_full (activity_t activity,
struct as_insert_rt
(*allocate_object) (enum cap_type type, addr_t addr))
{
-#ifndef RM_INTERN
- pthread_rwlock_wrlock (&as_lock);
-#endif
+ AS_LOCK;
struct cap *cap = as_build_internal (activity, root, a,
allocate_object, true);
-#ifndef RM_INTERN
- pthread_rwlock_unlock (&as_lock);
-#endif
+ AS_UNLOCK;
return cap;
}
@@ -492,6 +499,10 @@ do_walk (activity_t activity, int index, struct cap *root, addr_t addr,
if (cap.type == cap_void)
return;
+ if (! cap_to_object (activity, &cap))
+ /* Cap is there but the object has been deallocated. */
+ return;
+
if (output_prefix)
printf ("%s: ", output_prefix);
for (i = 0; i < indent; i ++)
@@ -524,12 +535,6 @@ do_walk (activity_t activity, int index, struct cap *root, addr_t addr,
#endif
printf ("%s", cap_type_string (cap.type));
- if (! cap_to_object (activity, &cap))
- {
- printf (" <- LOST (likely deallocated)\n");
- return;
- }
-
printf ("\n");
if (addr_depth (addr) + CAP_GUARD_BITS (&cap) > ADDR_BITS)
@@ -567,7 +572,7 @@ do_walk (activity_t activity, int index, struct cap *root, addr_t addr,
}
}
-/* Caller must ensure that AS_LOCK is held. */
+/* AS_LOCK must not be held. */
void
as_dump_from (activity_t activity, struct cap *root, const char *prefix)
{