diff --git a/src/interpret.c b/src/interpret.c
index 65393641175348b29f2e3ffddd4b836eedf92472..76051e67f4ecd0b6a831d7c634e00c8c742819dd 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -3353,7 +3353,11 @@ void gdb_backtrace (
 	if(of) {
           tmp = of->locals - f->locals;
         } else {
+#ifdef PIKE_THREADS
           tmp = ts->state.stack_pointer - f->locals;
+#else
+	  tmp = Pike_sp - f->locals;
+#endif
         }
         args = (INT32)tmp;
 	args = MAXIMUM(MINIMUM(args, f->num_args),0);