Skip to content

Commit

Permalink
+RTS -xc: print a the closure type of the exception too
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmar committed Nov 14, 2011
1 parent 6696237 commit e37893c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion rts/Exception.cmm
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ stg_raisezh
*/
if (RtsFlags_ProfFlags_showCCSOnException(RtsFlags) != 0::I32) {
SAVE_THREAD_STATE();
foreign "C" fprintCCS_stderr(W_[CCCS] "ptr", CurrentTSO "ptr") [];
foreign "C" fprintCCS_stderr(W_[CCCS] "ptr",
exception "ptr",
CurrentTSO "ptr") [];
LOAD_THREAD_STATE();
}
#endif
Expand Down
24 changes: 22 additions & 2 deletions rts/Profiling.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "ProfHeap.h"
#include "Arena.h"
#include "RetainerProfile.h"
#include "Printer.h"

#include <string.h>

Expand Down Expand Up @@ -1001,7 +1002,7 @@ static rtsBool fprintCallStack (CostCentreStack *ccs)

/* For calling from .cmm code, where we can't reliably refer to stderr */
void
fprintCCS_stderr (CostCentreStack *ccs, StgTSO *tso)
fprintCCS_stderr (CostCentreStack *ccs, StgClosure *exception, StgTSO *tso)
{
rtsBool is_caf;
StgPtr frame;
Expand All @@ -1010,7 +1011,26 @@ fprintCCS_stderr (CostCentreStack *ccs, StgTSO *tso)
nat depth = 0;
const nat MAX_DEPTH = 10; // don't print gigantic chains of stacks

fprintf(stderr, "*** Exception raised (reporting due to +RTS -xc), stack trace:\n ");
{
char *desc;
StgInfoTable *info;
info = get_itbl(exception);
switch (info->type) {
case CONSTR:
case CONSTR_1_0:
case CONSTR_0_1:
case CONSTR_2_0:
case CONSTR_1_1:
case CONSTR_0_2:
case CONSTR_STATIC:
case CONSTR_NOCAF_STATIC:
desc = GET_CON_DESC(itbl_to_con_itbl(info));
default:
desc = closure_type_names[info->type];
}
fprintf(stderr, "*** Exception (reporting due to +RTS -xc): (%s), stack trace: \n ", desc);
}

is_caf = fprintCallStack(ccs);

// traverse the stack down to the enclosing update frame to
Expand Down
2 changes: 1 addition & 1 deletion rts/Profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void reportCCSProfiling ( void );
void PrintNewStackDecls ( void );

void fprintCCS( FILE *f, CostCentreStack *ccs );
void fprintCCS_stderr (CostCentreStack *ccs, StgTSO *tso);
void fprintCCS_stderr (CostCentreStack *ccs, StgClosure *exception, StgTSO *tso);

#ifdef DEBUG
void debugCCS( CostCentreStack *ccs );
Expand Down
2 changes: 1 addition & 1 deletion rts/RaiseAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
*/
if (RtsFlags.ProfFlags.showCCSOnException)
{
fprintCCS_stderr(tso->prof.CCCS,tso);
fprintCCS_stderr(tso->prof.CCCS,exception,tso);
}
#endif
// ASSUMES: the thread is not already complete or dead
Expand Down

0 comments on commit e37893c

Please sign in to comment.