2 * Wine debugger utility routines
4 * Copyright 1993 Eric Youngdale
5 * Copyright 1995 Alexandre Julliard
12 /***********************************************************************
15 * Implementation of the 'print' command.
17 void DEBUG_Print( const DBG_ADDR
*addr
, int count
, char format
)
21 fprintf( stderr
, "Count other than 1 is meaningless in 'print' command\n" );
25 if (addr
->seg
&& (addr
->seg
!= 0xffffffff))
30 fprintf( stderr
, "0x%04lx:", addr
->seg
);
34 fprintf( stderr
, "%ld:", addr
->seg
);
38 break; /* No segment to print */
44 break; /* Meaningless format */
51 if (addr
->seg
) fprintf( stderr
, "0x%04lx\n", addr
->off
);
52 else fprintf( stderr
, "0x%08lx\n", addr
->off
);
56 fprintf( stderr
, "%ld\n", addr
->off
);
60 fprintf( stderr
, "%d = '%c'\n",
61 (char)(addr
->off
& 0xff), (char)(addr
->off
& 0xff) );
68 fprintf( stderr
, "Format specifier '%c' is meaningless in 'print' command\n", format
);
74 /***********************************************************************
77 * Print an 16- or 32-bit address, with the nearest symbol if any.
80 DEBUG_PrintAddress( const DBG_ADDR
*addr
, int addrlen
, int flag
)
82 struct name_hash
* nh
;
83 const char *name
= DEBUG_FindNearestSymbol( addr
, flag
, &nh
, 0 );
85 if (addr
->seg
) fprintf( stderr
, "0x%04lx:", addr
->seg
);
86 if (addrlen
== 16) fprintf( stderr
, "0x%04lx", addr
->off
);
87 else fprintf( stderr
, "0x%08lx", addr
->off
);
88 if (name
) fprintf( stderr
, " (%s)", name
);
91 /***********************************************************************
92 * DEBUG_PrintAddressAndArgs
94 * Print an 16- or 32-bit address, with the nearest symbol if any.
95 * Similar to DEBUG_PrintAddress, but we print the arguments to
96 * each function (if known). This is useful in a backtrace.
99 DEBUG_PrintAddressAndArgs( const DBG_ADDR
*addr
, int addrlen
,
100 unsigned int ebp
, int flag
)
102 struct name_hash
* nh
;
103 const char *name
= DEBUG_FindNearestSymbol( addr
, flag
, &nh
, ebp
);
105 if (addr
->seg
) fprintf( stderr
, "0x%04lx:", addr
->seg
);
106 if (addrlen
== 16) fprintf( stderr
, "0x%04lx", addr
->off
);
107 else fprintf( stderr
, "0x%08lx", addr
->off
);
108 if (name
) fprintf( stderr
, " (%s)", name
);
114 /***********************************************************************
117 * Implementation of the 'help' command.
119 void DEBUG_Help(void)
122 static const char * const helptext
[] =
124 "The commands accepted by the Wine debugger are a small subset",
125 "of the commands that gdb would accept.",
126 "The commands currently are:",
127 " break [*<addr>] delete break bpnum",
128 " disable bpnum enable bpnum",
132 " x <addr> print <expr>",
133 " set <reg> = <expr> set *<addr> = <expr>",
134 " symbolfile <filename> define <identifier> <addr>",
136 " list <addr> frame <n>\n",
138 "Wine-specific commands:",
139 " mode [16,32] walk [wnd,class,queue] <handle>",
140 " info [reg,stack,break,segments,locals] info [wnd, queue] <handle>\n",
142 "The 'x' command accepts repeat counts and formats (including 'i') in the",
143 "same way that gdb does.\n",
145 " The following are examples of legal expressions:",
146 " $eax $eax+0x3 0x1000 ($eip + 256) *$eax *($esp + 3)",
147 " Also, a nm format symbol table can be read from a file using the",
148 " symbolfile command. Symbols can also be defined individually with",
149 " the define command.",
154 while(helptext
[i
]) fprintf(stderr
,"%s\n", helptext
[i
++]);
159 /***********************************************************************
162 * Implementation of the 'list' command.
164 void DEBUG_List( DBG_ADDR
*addr
, int count
)
166 static DBG_ADDR lasttime
= { 0xffffffff, 0 };
168 if (addr
== NULL
) addr
= &lasttime
;
169 DBG_FIX_ADDR_SEG( addr
, CS_reg(DEBUG_context
) );
172 DEBUG_PrintAddress( addr
, dbg_mode
, FALSE
);
173 fprintf( stderr
, ": " );
174 if (!DBG_CHECK_READ_PTR( addr
, 1 )) return;
175 DEBUG_Disasm( addr
);
176 fprintf (stderr
, "\n");