2 * Debugger stack handling
4 * Copyright 1995 Alexandre Julliard
28 /***********************************************************************
31 * Dump the top of the stack
33 void DEBUG_InfoStack(void)
37 fprintf(stderr
,"Stack dump:\n");
38 if ((SS_reg(DEBUG_context
) == WINE_DATA_SELECTOR
) ||
39 (GET_SEL_FLAGS(SS_reg(DEBUG_context
)) & LDT_FLAGS_32BIT
))
42 addr
.off
= ESP_reg(DEBUG_context
);
43 DEBUG_ExamineMemory( &addr
, 24, 'x' );
45 else /* 16-bit mode */
47 addr
.seg
= SS_reg(DEBUG_context
);
48 addr
.off
= SP_reg(DEBUG_context
);
49 DEBUG_ExamineMemory( &addr
, 24, 'w' );
55 /***********************************************************************
58 * Display a stack back-trace.
60 void DEBUG_BackTrace(void)
65 fprintf(stderr
,"Backtrace:\n");
66 if (SS_reg(DEBUG_context
) == WINE_DATA_SELECTOR
) /* 32-bit mode */
69 addr
.off
= EBP_reg(DEBUG_context
);
72 FRAME32
*frame
= (FRAME32
*)addr
.off
;
73 if (!DBG_CHECK_READ_PTR( &addr
, sizeof(FRAME32
) )) return;
74 if (!frame
->ip
) break;
75 fprintf(stderr
,"%d ",frameno
++);
77 DEBUG_PrintAddress( &addr
, 32 );
78 fprintf( stderr
, "\n" );
82 else /* 16-bit mode */
84 WORD ss
= SS_reg(DEBUG_context
), cs
= CS_reg(DEBUG_context
);
85 if (GET_SEL_FLAGS(ss
) & LDT_FLAGS_32BIT
)
87 fprintf( stderr
, "Not implemented: 32-bit backtrace on a different stack segment.\n" );
90 addr
.seg
= SS_reg(DEBUG_context
);
91 addr
.off
= BP_reg(DEBUG_context
) & ~1;
94 FRAME16
*frame
= (FRAME16
*)DBG_ADDR_TO_LIN(&addr
);
95 if (!DBG_CHECK_READ_PTR( &addr
, sizeof(FRAME16
) )) return;
96 if (!frame
->bp
) break;
97 if (frame
->bp
& 1) cs
= frame
->cs
;
98 fprintf( stderr
,"%d ", frameno
++ );
100 addr
.off
= frame
->ip
;
101 DEBUG_PrintAddress( &addr
, 16 );
102 fprintf( stderr
, "\n" );
104 addr
.off
= frame
->bp
& ~1;
107 fprintf( stderr
, "\n" );