Commit a96a29fe authored by Josh Kunz's avatar Josh Kunz

Add/cleanup the logging

parent 6e59f166
......@@ -855,13 +855,14 @@ static int __cn_dispatch_create_flow(cn_principal_t *as,
}
if (cn_cnode_type(*cnode) != CN_NODE_GRANT) {
res = cn_dispatch_result_fail(result, "Node grant capability is not actually a node grant");
res = cn_dispatch_result_fail(result, "Node grant capability is not actually a node grant, it's a %s",
cn_objtype_name(cn_cnode_type(*cnode)));
goto finish;
}
node = ((cn_node_grant_t *) cn_cnode_object(*cnode))->node;
} else {
node = (cn_node_t *) as->owner;
assert(node && "Triede ot create flow in principal with NULL owner");
assert(node && "Tried to create flow in principal with NULL owner");
assert(((cn_obj_t *) node)->type == CN_NODE
&& "Tried to create flow with nodeless owner");
*cnode = NULL;
......@@ -1004,10 +1005,11 @@ int cn_dispatch_create(cn_principal_t *as, cn_dispatch_result_t *result,
} else {
assert(obj_base == NULL && "valid cnode but no args");
cn_obj_lock(as->owner);
assert(as == ((cn_node_t *) as->owner)->principal
&& "node principal should always be invoker");
node_grant = ((cn_node_t *) as->owner)->grant;
cn_obj_unlock(as->owner);
}
c_log_debug("doing derive!");
if (cn_derive(as, node_grant, as, obj_cptr, NULL) != 0) {
cn_delete(as, obj_cptr, NULL);
res = cn_dispatch_result_fail(result, "Cannot perform derive operation on flow");
......
......@@ -1370,6 +1370,18 @@ bool cn_method_mask_permission_is_set(method_mask_t * mask, cn_method_t m) {
/* sec: Normal Capability Operations */
char * cn_cnode_string(struct cnode * c) {
cn_obj_t * obj = cn_cnode_object(c);
return g_strdup_printf("(cnode (cptr %p %#lx) (type %s) (obj %p %s))",
cn_cnode_principal(c), cptr2ul(cap_cnode_cptr(c)),
cn_objtype_name(cn_cnode_type(c)),
obj, (obj ? cn_objtype_name(obj->type) : NULL));
}
char * cn_cptr_string(cn_principal_t *p, cptr_t c) {
return g_strdup_printf("(cptr %p %#lx)", p, cptr2ul(c));
}
int cn_grant_cnode_extended(struct cnode * ca,
cn_principal_t *dest, void * payload,
cptr_t *out, cn_objtype_t *o_type) {
......@@ -1538,7 +1550,9 @@ int cn_node_reset(struct cnode * node, cptr_t *o_grant) {
RHOLD_OBJ(rp0, OBJ_OWNER);
cncinfo("Revoking grant chain (cap: %#0lx)\n", cptr2ul(n->grant));
cn_revoke(n->secret, n->grant, NULL);
cncinfo("Deleting grant\n");
cn_delete(n->secret, n->grant, NULL);
if ((res = cn_principal_clear(n->principal)) != 0) {
......
......@@ -24,6 +24,10 @@ static int cn_dispatch_caller_binop(struct cnode * ca, struct cnode *cb,
/* Generic delete callback that just decrefs the object the cnode contains */
int cn_default_delete_cb(struct cnode *cnode, void * payload) {
cncinfo("[delete] (cap (principal %p) (cptr %#0lx) (obj-type %s))\n",
cn_cnode_principal(cnode),
cptr2ul(cap_cnode_cptr(cnode)),
cn_objtype_name(cn_cnode_type(cnode)));
cn_obj_t *obj = (cn_obj_t *) cap_cnode_object(cnode);
cn_obj_lock(obj);
assert(cn_cnode_type(cnode) == obj->type
......@@ -223,7 +227,7 @@ end1:
cn_obj_unlock(flow);
cn_obj_unlock(owner);
end:
c_log_debug("default cb...");
cncinfo("flow doing default delete cb\n");
ret = cn_default_delete_cb(flow_cnode, payload);
cn_obj_unlock(principal);
return ret;
......
......@@ -44,5 +44,9 @@ enum cn_rp_recv_result_flag {
// 0x3 (the low two bits reserved)
};
/* Utilities */
char * cn_cnode_string(struct cnode * c);
char * cn_cptr_string(cn_principal_t *p, cptr_t c);
#endif
......@@ -36,6 +36,9 @@ extern struct argp log_argp;
__FUNCTION__, __LINE__, ## __VA_ARGS__)
#define cncwarnc(format,...) fprintf(stdout,format, ## __VA_ARGS__)
#define cncinfo(format,...) fprintf(stdout,"CINFO: %s:%d: "format, \
__FUNCTION__, __LINE__, ## __VA_ARGS__)
#define cncwarnopt(level,area,flags,format,...) _cnc_warn(level,area,flags, \
"CWARNING: %s:%d: "format, \
__FUNCTION__, __LINE__, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment