Skip to content

Commit

Permalink
ENHANCED: Crash reports
Browse files Browse the repository at this point in the history
Avoid recursive crash reports and only print the GC and shift stacks
if the environment variable ``SWIPL_DEBUG_GC_STACK`` is set.
  • Loading branch information
JanWielemaker committed May 14, 2024
1 parent 3706834 commit 1cc90f6
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/pl-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,11 @@ printCrashContext(const char *btname)
time_t now;
char tbuf[48];
int btflags = 0;
static bool running = FALSE;

if ( running )
Sdprintf("Recursive crash; omitting crash report\n");
running = TRUE;

now = time(NULL);
ctime_r(&now, tbuf);
Expand Down Expand Up @@ -1803,19 +1808,23 @@ printCrashContext(const char *btname)

print_backtrace_named(btname);
if ( LD )
{ if ( LD->shift_status.inferences )
{ Sdprintf("Last stack shift at %" PRIu64 " inferences\n",
LD->shift_status.inferences);
print_backtrace_named("SHIFT");
}
if ( LD->gc.inferences )
{ Sdprintf("Last garbage collect at %" PRIu64 " inferences\n",
LD->gc.inferences);
print_backtrace_named("GC");
{ if ( getenv("SWIPL_DEBUG_GC_STACK") )
{ if ( LD->shift_status.inferences )
{ Sdprintf("Last stack shift at %" PRIu64 " inferences\n",
LD->shift_status.inferences);
print_backtrace_named("SHIFT");
}
if ( LD->gc.inferences )
{ Sdprintf("Last garbage collect at %" PRIu64 " inferences\n",
LD->gc.inferences);
print_backtrace_named("GC");
}
}
Sdprintf("\n\nPROLOG STACK:\n");
PL_backtrace(10, btflags);
}

running = FALSE;
}


Expand Down

0 comments on commit 1cc90f6

Please sign in to comment.