From: Gabriel Corona Date: Thu, 6 Nov 2014 11:49:45 +0000 (+0100) Subject: [mc] Add MC_dump_stacks X-Git-Tag: v3_12~732^2~224 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0cebe25fe80e2064230e8611a2aa34adb43b8cae?hp=59231194702784610f8603557c59ef263f6a3736 [mc] Add MC_dump_stacks --- diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index 8c3c47d71e..55162555c5 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -23,6 +23,7 @@ #include "../simix/smx_private.h" +#define UNW_LOCAL_ONLY #include #include diff --git a/src/mc/mc_global.c b/src/mc/mc_global.c index dbdbc7cc6d..5d163b1ccc 100644 --- a/src/mc/mc_global.c +++ b/src/mc/mc_global.c @@ -11,6 +11,9 @@ #include #include +#define UNW_LOCAL_ONLY +#include + #include "simgrid/sg_config.h" #include "../surf/surf_private.h" #include "../simix/smx_private.h" @@ -824,3 +827,33 @@ void MC_automaton_new_propositional_symbol(const char *id, void *fct) MC_SET_MC_HEAP; } + +void MC_dump_stacks(FILE* file) +{ + int raw_mem_set = (mmalloc_get_current_heap() == mc_heap); + MC_SET_MC_HEAP; + + int nstack = 0; + stack_region_t current_stack; + unsigned cursor; + xbt_dynar_foreach(stacks_areas, cursor, current_stack) { + unw_context_t * context = (unw_context_t *)current_stack->context; + fprintf(file, "Stack %i:\n", nstack); + + int nframe = 0; + char buffer[100]; + unw_cursor_t c; + unw_init_local (&c, context); + unw_word_t off; + do { + const char * name = !unw_get_proc_name(&c, buffer, 100, &off) ? buffer : "?"; + fprintf(file, " %i: %s\n", nframe, name); + ++nframe; + } while(unw_step(&c)); + + ++nstack; + } + + if (raw_mem_set) + MC_SET_MC_HEAP; +} diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index 10fcbe9faa..a44df30612 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -909,6 +909,15 @@ void* mc_snapshot_read_pointer_region(void* addr, mc_mem_region_t region) xbt_free(req_str); \ } +/** @brief Dump the stacks of the application processes + * + * This functions is currently not used but it is quite convenient + * to call from the debugger. + * + * Does not work when an application thread is running. + */ +void MC_dump_stacks(FILE* file); + SG_END_DECL() #endif