Skip to content

Commit

Permalink
Merge pull request #374 from bfaccini/ULT-stacks-dump_timestamps+pack-0s
Browse files Browse the repository at this point in the history
info: add start/end tags and pack zeroes in stack dump
  • Loading branch information
shintaro-iwasaki authored Jan 27, 2022
2 parents 36a41b5 + a640817 commit dce6e72
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,10 +1373,20 @@ ABTU_ret_err static int print_all_thread_stacks(ABTI_global *p_global, FILE *fp)
size_t i;
int abt_errno;
struct info_pool_set_t pool_set;
struct tm *tm = NULL;
time_t seconds;

abt_errno = info_initialize_pool_set(&pool_set);
ABTI_CHECK_ERROR(abt_errno);
ABTI_xstream *p_xstream = p_global->p_xstream_head;

seconds = (time_t)ABT_get_wtime();
tm = localtime(&seconds);
ABTI_ASSERT(tm != NULL);
fprintf(fp, "Start of ULT stacks dump %04d/%02d/%02d-%02d:%02d:%02d\n",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
tm->tm_min, tm->tm_sec);

while (p_xstream) {
ABTI_sched *p_main_sched = p_xstream->p_main_sched;
fprintf(fp, "= xstream[%d] (%p) =\n", p_xstream->rank,
Expand Down Expand Up @@ -1404,6 +1414,14 @@ ABTU_ret_err static int print_all_thread_stacks(ABTI_global *p_global, FILE *fp)
if (abt_errno != ABT_SUCCESS)
fprintf(fp, " Failed to print (errno = %d).\n", abt_errno);
}

seconds = (time_t)ABT_get_wtime();
tm = localtime(&seconds);
ABTI_ASSERT(tm != NULL);
fprintf(fp, "End of ULT stacks dump %04d/%02d/%02d-%02d:%02d:%02d\n",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
tm->tm_min, tm->tm_sec);

info_finalize_pool_set(&pool_set);
return ABT_SUCCESS;
}
19 changes: 19 additions & 0 deletions src/ythread.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ ABTU_no_sanitize_address void ABTI_ythread_print_stack(ABTI_global *p_global,
char buffer[32];
const size_t value_width = 8;
const int num_bytes = sizeof(buffer);
static const char zero[sizeof(buffer)];
ABT_bool full_zeroes = ABT_FALSE, multi_lines = ABT_FALSE;

for (i = 0; i < stacksize; i += num_bytes) {
if (stacksize >= i + num_bytes) {
Expand All @@ -282,6 +284,23 @@ ABTU_no_sanitize_address void ABTI_ythread_print_stack(ABTI_global *p_global,
memset(buffer, 0, num_bytes);
memcpy(buffer, &((uint8_t *)p_stack)[i], stacksize - i);
}

/* pack full lines of zeroes */
if (!memcmp(zero, buffer, sizeof(buffer))) {
if (!full_zeroes) {
full_zeroes = ABT_TRUE;
} else {
multi_lines = ABT_TRUE;
continue;
}
} else {
full_zeroes = ABT_FALSE;
if (multi_lines) {
fprintf(p_os, "*\n");
multi_lines = ABT_FALSE;
}
}

/* Print the stack address */
#if SIZEOF_VOID_P == 8
fprintf(p_os, "%016" PRIxPTR ":",
Expand Down

0 comments on commit dce6e72

Please sign in to comment.