monitor: capops: copy: add DEBUG_CAPOPS and clearer messages in forwarding path
authorSimon Gerber <simon.gerber@inf.ethz.ch>
Mon, 28 Aug 2017 14:05:51 +0000 (16:05 +0200)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Tue, 29 Aug 2017 06:43:39 +0000 (08:43 +0200)
Signed-off-by: Simon Gerber <simon.gerber@inf.ethz.ch>

usr/monitor/capops/copy.c
usr/monitor/capops/internal.h

index 7de3a0e..104d82f 100644 (file)
@@ -446,8 +446,12 @@ recv_copy_result__src(errval_t status, capaddr_t capaddr, uint8_t level,
             }
             // this should always succeed either because there are local
             // copies or because the cap is now foreign
+            DEBUG_CAPOPS("%s st=%p, cap = %#"PRIxCADDR"\n", __FUNCTION__,
+                    rpc_st, get_cap_addr(rpc_st->cap));
             err = cap_destroy(rpc_st->cap);
-            PANIC_IF_ERR(err, "cap_destroy after give_away failed");
+            PANIC_IF_ERR(err, "cap_destroy after give_away failed (st=%p)", rpc_st);
+        } else if (err_is_ok(status)) {
+            debug_printf("copy succeeded but we're leaving monitor's copy alone?\n");
         }
     }
     // call result handler
@@ -468,7 +472,8 @@ recv_copy_result__rx(struct intermon_binding *b, errval_t status,
                      genvaddr_t st)
 {
     assert(st);
-    DEBUG_CAPOPS("recv_copy_result__rx: %p, %s\n", b, err_getstring(status));
+    DEBUG_CAPOPS("recv_copy_result__rx: %p, st=%p, %s\n", b, (void*)st,
+            err_getstring(status));
     struct cap_copy_rpc_st *rpc_st = (struct cap_copy_rpc_st*)((lvaddr_t)st);
     rpc_st->recv_handler(status, capaddr, level, slot, rpc_st);
 }
@@ -599,6 +604,8 @@ request_copy__rx(struct intermon_binding *b, coreid_t dest,
     }
     else {
         // forward copy to destination core
+        DEBUG_CAPOPS("%s: owner_copy__enq(st=%p) capref = %#"PRIxCADDR"\n",
+            __FUNCTION__, (void *)st, get_cap_addr(capref));
         owner_copy__enq(capref, &cap, from, dest, true, NULL, st);
     }
 
@@ -641,6 +648,8 @@ capops_copy(struct capref capref, coreid_t dest, bool give_away,
     if (capref_is_null(capref)) {
         memset(&cap, sizeof(cap), 0);
         cap.type = ObjType_Null;
+        DEBUG_CAPOPS("%s: owner_copy__enq(st=%p) capref = %#"PRIxCADDR"\n",
+            __FUNCTION__, st, get_cap_addr(capref));
         owner_copy__enq(capref, &cap, my_core_id, dest, give_away,
                 result_handler, (lvaddr_t)st);
         return;
@@ -682,11 +691,15 @@ capops_copy(struct capref capref, coreid_t dest, bool give_away,
         DEBUG_CAPOPS("capops_copy: sending copy from non-owner, forward request to owner\n");
 
         // sending copy from non-owner, send copy request to owner
+        DEBUG_CAPOPS("%s: request_copy__enq(st=%p) capref = %#"PRIxCADDR"\n",
+            __FUNCTION__, st, get_cap_addr(capref));
         request_copy__enq(capref, dest, give_away, result_handler, st);
     } else {
         DEBUG_CAPOPS("capops_copy: sending copy from here/owner\n");
 
         // sending copy from here/owner
+        DEBUG_CAPOPS("%s: owner_copy__enq(st=%p) capref = %#"PRIxCADDR"\n",
+            __FUNCTION__, st, get_cap_addr(capref));
         owner_copy__enq(capref, &cap, my_core_id, dest, give_away,
                         result_handler, (lvaddr_t)st);
     }
index e8e8f60..7299fa3 100644 (file)
@@ -42,10 +42,10 @@ struct result_closure {
     } \
 } while (0)
 
-#define PANIC_IF_ERR(err, msg) do { \
+#define PANIC_IF_ERR(err, msg...) do { \
     errval_t tmp_err__ = (err); \
     if (err_is_fail(tmp_err__)) { \
-        USER_PANIC_ERR(tmp_err__, (msg)); \
+        USER_PANIC_ERR(tmp_err__, msg); \
     } \
 } while (0)