diff options
author | Stefan Siegl <stesie@brokenpipe.de> | 2005-03-20 14:02:07 +0000 |
---|---|---|
committer | Stefan Siegl <stesie@brokenpipe.de> | 2005-03-20 14:02:07 +0000 |
commit | d0ecce4b23e59bf49efbd3e26c2b8aa9701c720a (patch) | |
tree | 6a87f13479088dcb2127e136716c67684fbf0b83 | |
parent | 5eb1c783eabf69e5f2fbf14cdd728bcd069f9df1 (diff) |
added debug macros from cvsfs.
-rw-r--r-- | fuse_i.h | 67 | ||||
-rw-r--r-- | main.c | 6 |
2 files changed, 73 insertions, 0 deletions
@@ -64,4 +64,71 @@ struct netnode *fuse_make_netnode(struct netnode *parent, const char *path); /* make a new node for a specific netnode */ struct node *fuse_make_node(struct netnode *nn); + + +/***************************************************************************** + *** debug cruft *** + *****************************************************************************/ + +/* the port where to write out debug messages to, NULL to omit these */ +extern FILE *debug_port; + +#define DEBUG(cat,msg...) \ + if(debug_port) \ + fprintf(debug_port, PACKAGE ": " cat ": " msg); + +#define FUNC_PROLOGUE_(func_name, fmt...) \ + do \ + { \ + const char *debug_func_name = func_name; \ + DEBUG("tracing", "entering %s (" __FILE__ ":%d) ", \ + debug_func_name, __LINE__); \ + if(debug_port) \ + { \ + fmt; \ + fprintf(debug_port, "\n"); \ + } + +#define FUNC_PROLOGUE(func_name) \ + FUNC_PROLOGUE_(func_name, (void)0) + +#define FUNC_PROLOGUE_FMT(func_name, fmt...) \ + FUNC_PROLOGUE_(func_name, fprintf(debug_port, fmt)) + +#define FUNC_PROLOGUE_NODE(func_name, node) \ + FUNC_PROLOGUE_FMT(func_name, "node=%s", (node)->nn->path) + +#define FUNC_EPILOGUE_NORET() \ + DEBUG("tracing", "leaving %s\n", debug_func_name); \ + } while(0); + +#define FUNC_RETURN_(ret, fmt) \ + { \ + int retval = (ret); \ + DEBUG("tracing", "leaving %s (" __FILE__ ":%d) ret=%d ", \ + debug_func_name, __LINE__, retval); \ + if(debug_port) \ + { \ + fmt; \ + fprintf(debug_port, "\n"); \ + } \ + return retval; \ + } + +#define FUNC_EPILOGUE_(ret, fmt) \ + FUNC_RETURN_(ret, fmt) \ + } while(0); + +#define FUNC_RETURN_FMT(ret, fmt...) \ + FUNC_RETURN_(ret, fprintf(debug_port, fmt)) + +#define FUNC_EPILOGUE_FMT(ret, fmt...) \ + FUNC_EPILOGUE_(ret, fprintf(debug_port, fmt)) + +#define FUNC_RETURN(ret) \ + FUNC_RETURN_(ret, (void)0) + +#define FUNC_EPILOGUE(ret) \ + FUNC_EPILOGUE_(ret, (void)0) + #endif /* FUSE_INTERNAL_H */ @@ -30,11 +30,17 @@ int netfs_maxsymlinks = 12; /* pointer to the fuse_operations structure of this translator process */ const struct fuse_operations *fuse_ops = NULL; +/* the port where to write out debug messages to, NULL to omit these */ +FILE *debug_port = NULL; + void fuse_main(int argc, char *argv[], const struct fuse_operations *op) { mach_port_t bootstrap, ul_node; + /* print debug messages out to standard error */ + debug_port = stderr; + task_get_bootstrap_port(mach_task_self(), &bootstrap); if(bootstrap == MACH_PORT_NULL) { |