void initTracing (void) { #ifdef THREADED_RTS initMutex(&trace_utx); #endif DEBUG_FLAG(scheduler, DEBUG_sched); DEBUG_FLAG(interpreter, DEBUG_interp); DEBUG_FLAG(weak, DEBUG_weak); DEBUG_FLAG(gccafs, DEBUG_gccafs); DEBUG_FLAG(gc, DEBUG_gc); DEBUG_FLAG(block_alloc, DEBUG_block_alloc); DEBUG_FLAG(sanity, DEBUG_sanity); DEBUG_FLAG(stable, DEBUG_stable); DEBUG_FLAG(stm, DEBUG_stm); DEBUG_FLAG(prof, DEBUG_prof); DEBUG_FLAG(gran, DEBUG_gran); DEBUG_FLAG(par, DEBUG_par); DEBUG_FLAG(linker, DEBUG_linker); DEBUG_FLAG(squeeze, DEBUG_squeeze); DEBUG_FLAG(hpc, DEBUG_hpc); PAR_FLAG(verbose, PAR_DEBUG_verbose); PAR_FLAG(bq, PAR_DEBUG_bq); PAR_FLAG(schedule, PAR_DEBUG_schedule); PAR_FLAG(free, PAR_DEBUG_free); PAR_FLAG(resume, PAR_DEBUG_resume); PAR_FLAG(weight, PAR_DEBUG_weight); PAR_FLAG(fetch, PAR_DEBUG_fetch); PAR_FLAG(fish, PAR_DEBUG_fish); PAR_FLAG(tables, PAR_DEBUG_tables); PAR_FLAG(packet, PAR_DEBUG_packet); PAR_FLAG(pack, PAR_DEBUG_pack); PAR_FLAG(paranoia, PAR_DEBUG_paranoia); GRAN_FLAG(event_trace, GRAN_DEBUG_event_trace); GRAN_FLAG(event_stats, GRAN_DEBUG_event_stats); GRAN_FLAG(bq, GRAN_DEBUG_bq); GRAN_FLAG(pack, GRAN_DEBUG_pack); GRAN_FLAG(checkSparkQ, GRAN_DEBUG_checkSparkQ); GRAN_FLAG(thunkStealing, GRAN_DEBUG_thunkStealing); GRAN_FLAG(randomSteal, GRAN_DEBUG_randomSteal); GRAN_FLAG(findWork, GRAN_DEBUG_findWork); GRAN_FLAG(unused, GRAN_DEBUG_unused); GRAN_FLAG(pri, GRAN_DEBUG_pri); GRAN_FLAG(checkLight, GRAN_DEBUG_checkLight); GRAN_FLAG(sortedQ, GRAN_DEBUG_sortedQ); GRAN_FLAG(blockOnFetch, GRAN_DEBUG_blockOnFetch); GRAN_FLAG(packBuffer, GRAN_DEBUG_packBuffer); GRAN_FLAG(blockedOnFetch_sanity, GRAN_DEBUG_BOF_sanity); TRACE_FLAG(sched, TRACE_sched); }
void test_proc(void) { UINT32 x, y, flags; for (x = TRACE_LEVEL_ERROR; x <= TRACE_LEVEL_VERBOSE; x++) { xpcf_print("*** Set trace level to %u ***\n", x); SET_TRACE_LEVEL(x); for (y = TRACE_LEVEL_ERROR; y <= TRACE_LEVEL_VERBOSE; y++) { TRACE_MSG(y, TRACE_FLAG_DEFAULT, "Trace level = %u\n", y); } } for (x = 0; x < 32; x++) { flags = TRACE_FLAG(x); xpcf_print("*** Set trace level to %08X ***\n", flags); SET_TRACE_FLAGS(flags); for (y = 0; y < 32; y++) { flags = TRACE_FLAG(y); TRACE_MSG(TRACE_LEVEL_INFO, flags, "Trace flags = 0x%08X\n", flags); } } }
int main(int argc, char *argv[]) { int ctx, i, n, done; char command[256]; /* trace flags */ int DBG_GRAPH, DBG_VAR, DBG_RESOLVE, DBG_ACTION, DBG_VM; TRACE_DECLARE_MODULE(test, "test", TRACE_FLAG("graph" , "dependency graph" , &DBG_GRAPH), TRACE_FLAG("var" , "variable handling" , &DBG_VAR), TRACE_FLAG("resolve", "dependency resolving", &DBG_RESOLVE), TRACE_FLAG("action" , "action processing" , &DBG_ACTION), TRACE_FLAG("vm" , "VM execution" , &DBG_VM)); trace_init(); if ((ctx = trace_context_open("test")) < 0) fatal(1, "failed to create test trace context"); if (trace_module_add(ctx, &test) != 0) fatal(1, "failed to add trace module test (%d: %s)", errno, strerror(errno)); info("registered trace module test..."); info("got debug flags:"); info("graph: 0x%x, var: 0x%x, res: 0x%x, act: 0x%x, vm: 0x%x", DBG_GRAPH, DBG_VAR, DBG_RESOLVE, DBG_ACTION, DBG_VM); #define SHOW(n) do { \ printf("%s,%s,%s,%s,%s\n", \ i & 0x01 ? "GRAPH" : "-", \ i & 0x02 ? "VAR" : "-", \ i & 0x04 ? "RESOLVE" : "-", \ i & 0x08 ? "ACTION" : "-", \ i & 0x10 ? "VM" : "-"); \ } while (0) #define FLIP(id, b) \ ((i) & (0x1<<(b)) ? trace_flag_set : trace_flag_clr)(DBG_##id) trace_configure("*.*=+all"); trace_context_enable(ctx); done = FALSE; while (!done) { trace_write(DBG_GRAPH , "DBG_GRAPH"); trace_write(DBG_VAR , "DBG_VAR"); trace_write(DBG_RESOLVE, "DBG_RESOLVE"); trace_write(DBG_ACTION , "DBG_ACTION"); trace_write(DBG_VM , "DBG_VM"); while (!done) { char *nl; printf("trace> "); if (fgets(command, sizeof(command), stdin) == NULL) continue; if ((nl = strchr(command, '\n')) != NULL) *nl = '\0'; if (!strcmp(command, "quit") || !strcmp(command, "exit")) done = TRUE; else if (!strcmp(command, "show")) printf("I would if I could...\n"); else if (!strcmp(command, "test") || !strcmp(command, "run")) break; else if (!strcmp(command, "help")) { printf("Possible commands are:\n"); printf("quit: quit\n"); printf("show: show current trace settings\n"); printf("test: write one test trace message per flag\n"); printf("context.module=[+|-]f1,...: change trace flags\n"); printf("context > file: redirect trace context to file\n"); } else trace_configure(command); } } if (trace_module_del(ctx, "test") != 0) fatal(1, "failed to remove trace module %s (%d: %s)", "test", errno, strerror(errno)); info("test trace module %s removed...", "test"); return 0; }
#include <ohm/ohm-fact.h> #include <dres/dres.h> #include <dres/compiler.h> #include "dres-debug.h" #include "parser-types.h" #include "parser.h" /* trace flags */ int DBG_GRAPH, DBG_VAR, DBG_RESOLVE, DBG_ACTION, DBG_VM; TRACE_DECLARE_MODULE(trcdres, "dres", TRACE_FLAG("graph" , "dependency graph" , &DBG_GRAPH), TRACE_FLAG("var" , "variable handling" , &DBG_VAR), TRACE_FLAG("resolve", "dependency resolving", &DBG_RESOLVE), TRACE_FLAG("action" , "action processing" , &DBG_ACTION), TRACE_FLAG("vm" , "VM execution" , &DBG_VM)); extern int lexer_open(char *path); extern int lexer_line(void); extern char *lexer_file(void); extern int yyparse(dres_t *dres); int initialize_variables(dres_t *dres); int finalize_variables (dres_t *dres); static void free_initializers (dres_t *dres); static int finalize_actions (dres_t *dres);