Commit e8fae19e authored by Josh Kunz's avatar Josh Kunz

Adds refcount debugging code

By setting the hold debugging flags to true or false you can
get logging information each time a lock is held or released.
parent da3bff12
......@@ -21,7 +21,7 @@
#define CNCPRIxMAC "%.2hhx:%.2hhx:%.2hhx:%.2hhx:%.2hhx:%.2hhx"
#define CNCPRIxMACARGS(mac) mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]
#define MUL_OWNER (0xdeadc0deUL)
#define MUL_OWNER ((void *) 0xdeadc0deUL)
/* An officially and unofficially unused ethernet protocol number for
* the capnet capability protocol. */
......@@ -1567,7 +1567,7 @@ void cnc_port_add(mul_switch_t *sw, mul_port_t *port) {
cncerr("couldn't alloc node");
goto finish;
}
cn_obj_lock(node);
cn_obj_lock(node);
rc = metadata_get_node_info(csw, cport, node);
if (rc != 0) {
cncerr("couldn't get metatdata for node");
......
......@@ -16,7 +16,7 @@
#include "capnet_log.h"
#define DISPATCH_OWNER 0xd15A74beefUL
#define DISPATCH_OWNER ((void *) 0xd15A74beefUL)
static const uint32_t CP_PROTO_MAGIC = 0x434e5000U;
static const uint32_t CP_PROTO_V1 = 0x1U;
......
......@@ -15,8 +15,6 @@
#include "capnet_ref.h"
#include "capnet_log.h"
static const void * OBJ_OWNER = (void *) 0xdeadbeefUL;
/* Used as the declassifier on annotations that were added nominally by
* the system itself. This is special cased in a bunch of cases in the code
* below. */
......
......@@ -54,9 +54,10 @@ REFCNT __OBJ_free(cn_obj_t *obj, int i);
#define cn_obj_ref(o) ((cn_obj_t *) (o))
#ifndef __DEBUG_OBJ_LOCKS
#define __DEBUG_OBJ_LOCKS
#ifndef __DEBUG_OBJ
#define __DEBUG_OBJ
static bool __debug_obj_locks = false;
static bool __debug_obj_holds = false;
#endif
static pid_t gettid(void) {
......@@ -89,11 +90,27 @@ static pid_t gettid(void) {
#define RHOLD_OBJ(o,acc) \
do { cn_obj_lock(cn_obj_ref((o))); \
RHOLD(cn_obj_ref((o)), (acc)); \
if (__debug_obj_holds) { \
printf("OBJHOLD,hold,%s,%p,%u,%p,%s,%d\n", \
cn_objtype_name(cn_obj_ref((o))->type), \
cn_obj_ref((o)), \
cn_obj_ref((o))->refcnt, \
acc, \
__FILE__,__LINE__); } \
cn_obj_unlock(cn_obj_ref((o))); } while (0)
/* Release a reference to the object 'o' */
/* Release a reference to the object 'o'
* The logging is as follows:
* OBJHOLD,put,typename,obj pointer, obj->refcnt - 1, acquirer, file, line*/
#define RPUT_OBJ(o,acc,rc) \
do { cn_obj_lock(cn_obj_ref((o))); \
if (__debug_obj_holds) { \
printf("OBJHOLD,put,%s,%p,%u,%p,%s,%d\n", \
cn_objtype_name(cn_obj_ref((o))->type), \
cn_obj_ref((o)), \
(cn_obj_ref((o))->refcnt) - 1, \
acc, \
__FILE__,__LINE__); } \
RPUT(cn_obj_ref((o)), __OBJ, (acc), (rc)); \
if (rc > 0) { cn_obj_unlock(cn_obj_ref((o))); } \
} while (0);
......
......@@ -3,6 +3,8 @@
#include <libcap.h>
static const void * OBJ_OWNER = (void *) 0xdeadbeefUL;
int cn_ensure_target_meta(struct cnode *ca, struct cnode *cb);
void cn_ensure_target_meta_cleanup(struct cnode *ca, struct cnode *cb);
......
......@@ -8,7 +8,7 @@ int cn_waiting_node_new(cn_node_t *node, cptr_t obj, uint64_t uuid,
return -1;
}
RHOLD_OBJ(node, MUL_OWNER);
RHOLD_OBJ(node, OBJ_OWNER);
wait->node = node;
wait->obj = obj;
wait->uuid = uuid;
......
......@@ -5,6 +5,7 @@
#include <libcap.h>
#include "obj_internal.h"
#include "obj_decl.h"
struct cn_waiting_node {
......
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