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 fprintf(stderr
,"%d ",frameno
++);
70 addr
.off
= EIP_reg(DEBUG_context
);
71 DEBUG_PrintAddress( &addr
, 32 );
72 fprintf( stderr
, "\n" );
73 addr
.off
= EBP_reg(DEBUG_context
);
76 FRAME32
*frame
= (FRAME32
*)addr
.off
;
77 if (!DBG_CHECK_READ_PTR( &addr
, sizeof(FRAME32
) )) return;
78 if (!frame
->ip
) break;
79 fprintf(stderr
,"%d ",frameno
++);
81 DEBUG_PrintAddress( &addr
, 32 );
82 fprintf( stderr
, "\n" );
86 else /* 16-bit mode */
88 WORD ss
= SS_reg(DEBUG_context
), cs
= CS_reg(DEBUG_context
);
89 if (GET_SEL_FLAGS(ss
) & LDT_FLAGS_32BIT
)
91 fprintf( stderr
, "Not implemented: 32-bit backtrace on a different stack segment.\n" );
94 fprintf( stderr
,"%d ", frameno
++ );
96 addr
.off
= IP_reg(DEBUG_context
);
97 DEBUG_PrintAddress( &addr
, 16 );
98 fprintf( stderr
, "\n" );
100 addr
.off
= BP_reg(DEBUG_context
) & ~1;
103 FRAME16
*frame
= (FRAME16
*)DBG_ADDR_TO_LIN(&addr
);
104 if (!DBG_CHECK_READ_PTR( &addr
, sizeof(FRAME16
) )) return;
105 if (!frame
->bp
) break;
106 if (frame
->bp
& 1) cs
= frame
->cs
;
107 fprintf( stderr
,"%d ", frameno
++ );
109 addr
.off
= frame
->ip
;
110 DEBUG_PrintAddress( &addr
, 16 );
111 fprintf( stderr
, "\n" );
113 addr
.off
= frame
->bp
& ~1;
116 fprintf( stderr
, "\n" );