summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2020-11-10 16:37:21 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2020-11-10 16:37:21 +0000
commitb6287f38d50ed46aa337158943ef855bf9000df2 (patch)
tree3791a262bae9dbdb1f93753e3acf8128ac1bf1e4 /rts
parenta4b44644bbbc639ca214aa3b13ec72d93ae51e49 (diff)
downloadhaskell-wip/ghc-debug-stack.tar.gz
WIP: ST example working (small bitmap stack frames)wip/ghc-debug-stack
Diffstat (limited to 'rts')
-rw-r--r--rts/CloneStack.c13
-rw-r--r--rts/Printer.c2
-rw-r--r--rts/Printer.h1
3 files changed, 15 insertions, 1 deletions
diff --git a/rts/CloneStack.c b/rts/CloneStack.c
index a820cb8da3..da447d36dc 100644
--- a/rts/CloneStack.c
+++ b/rts/CloneStack.c
@@ -18,10 +18,12 @@
#if defined(DEBUG)
#include "sm/Sanity.h"
+#include "Printer.h"
#endif
static StgStack* cloneStackChunk(Capability* capability, const StgStack* stack)
{
+ printf("CLONE_STACK_CHUNK");
StgWord spOffset = stack->sp - stack->stack;
StgWord closureSizeBytes = sizeof(StgStack) + (stack->stack_size * sizeof(StgWord));
@@ -29,12 +31,20 @@ static StgStack* cloneStackChunk(Capability* capability, const StgStack* stack)
memcpy(newStackClosure, stack, closureSizeBytes);
+ printf("spOffset: %d", spOffset);
+ debugBelch("spOffset: %d", spOffset);
+ debugBelch("sp: %p\n", stack->sp);
+ debugBelch("sp: %p\n", stack->stack);
+ debugBelch("sp: %p\n", newStackClosure->stack);
newStackClosure->sp = newStackClosure->stack + spOffset;
// The new stack is not on the mutable list; clear the dirty flag such that
// we don't claim that it is.
newStackClosure->dirty = 0;
#if defined(DEBUG)
+ printStack(stack);
+ checkClosure((StgClosure*) stack);
+ printStack(newStackClosure);
checkClosure((StgClosure*) newStackClosure);
#endif
@@ -44,6 +54,7 @@ static StgStack* cloneStackChunk(Capability* capability, const StgStack* stack)
StgStack* cloneStack(Capability* capability, const StgStack* stack)
{
StgStack *top_stack = cloneStackChunk(capability, stack);
+ debugBelch("COPIED TOP: %p", stack);
StgStack *last_stack = top_stack;
while (true) {
// check whether the stack ends in an underflow frame
@@ -51,6 +62,8 @@ StgStack* cloneStack(Capability* capability, const StgStack* stack)
StgUnderflowFrame *underFlowFrame = ((StgUnderflowFrame *) top);
StgUnderflowFrame *frame = underFlowFrame--;
if (frame->info == &stg_stack_underflow_frame_info) {
+ printf("HAS UNDERFLOW");
+ debugBelch("COPying UNDERFLOW: %p", frame->next_chunk);
StgStack *s = cloneStackChunk(capability, frame->next_chunk);
frame->next_chunk = s;
last_stack = s;
diff --git a/rts/Printer.c b/rts/Printer.c
index 729c8067b8..7a9efc86f1 100644
--- a/rts/Printer.c
+++ b/rts/Printer.c
@@ -642,7 +642,7 @@ printStackChunk( StgPtr sp, StgPtr spBottom )
}
}
-static void printStack( StgStack *stack )
+void printStack( StgStack *stack )
{
printStackChunk( stack->sp, stack->stack + stack->stack_size );
}
diff --git a/rts/Printer.h b/rts/Printer.h
index 44c55de3d6..7dc6dca353 100644
--- a/rts/Printer.h
+++ b/rts/Printer.h
@@ -23,6 +23,7 @@ const char * info_update_frame ( const StgClosure *closure );
#if defined(DEBUG)
extern void printClosure ( const StgClosure *obj );
extern void printStackChunk ( StgPtr sp, StgPtr spLim );
+extern void printStack ( StgStack *stack);
extern void printTSO ( StgTSO *tso );
extern void printMutableList( bdescr *bd );
extern void printStaticObjects ( StgClosure *obj );