Release 970112
[wine.git] / debugger / info.c
blob6c5f4dec6f827f2fa5246a6277c53265ad2639ea
1 /*
2 * Wine debugger utility routines
4 * Copyright 1993 Eric Youngdale
5 * Copyright 1995 Alexandre Julliard
6 */
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "debugger.h"
11 #include "expr.h"
13 /***********************************************************************
14 * DEBUG_Print
16 * Implementation of the 'print' command.
18 void DEBUG_PrintBasic( const DBG_ADDR *addr, int count, char format )
20 char * default_format;
21 long long int value;
23 if( addr->type == NULL )
25 fprintf(stderr, "Unable to evaluate expression\n");
26 return;
29 default_format = NULL;
30 value = DEBUG_GetExprValue((DBG_ADDR *) addr, &default_format);
32 switch(format)
34 case 'x':
35 if (addr->seg) fprintf( stderr, "0x%04lx", (long unsigned int) value );
36 else fprintf( stderr, "0x%08lx", (long unsigned int) value );
37 break;
39 case 'd':
40 fprintf( stderr, "%ld\n", (long int) value );
41 break;
43 case 'c':
44 fprintf( stderr, "%d = '%c'",
45 (char)(value & 0xff), (char)(value & 0xff) );
46 break;
48 case 'i':
49 case 's':
50 case 'w':
51 case 'b':
52 fprintf( stderr, "Format specifier '%c' is meaningless in 'print' command\n", format );
53 case 0:
54 if( default_format != NULL )
56 fprintf( stderr, default_format, value );
58 break;
64 /***********************************************************************
65 * DEBUG_PrintAddress
67 * Print an 16- or 32-bit address, with the nearest symbol if any.
69 struct symbol_info
70 DEBUG_PrintAddress( const DBG_ADDR *addr, int addrlen, int flag )
72 struct symbol_info rtn;
74 const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, 0,
75 &rtn.list );
77 if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg );
78 if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
79 else fprintf( stderr, "0x%08lx", addr->off );
80 if (name) fprintf( stderr, " (%s)", name );
81 return rtn;
83 /***********************************************************************
84 * DEBUG_PrintAddressAndArgs
86 * Print an 16- or 32-bit address, with the nearest symbol if any.
87 * Similar to DEBUG_PrintAddress, but we print the arguments to
88 * each function (if known). This is useful in a backtrace.
90 struct symbol_info
91 DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr, int addrlen,
92 unsigned int ebp, int flag )
94 struct symbol_info rtn;
96 const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, ebp,
97 &rtn.list );
99 if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg );
100 if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
101 else fprintf( stderr, "0x%08lx", addr->off );
102 if (name) fprintf( stderr, " (%s)", name );
104 return rtn;
108 /***********************************************************************
109 * DEBUG_Help
111 * Implementation of the 'help' command.
113 void DEBUG_Help(void)
115 int i = 0;
116 static const char * const helptext[] =
118 "The commands accepted by the Wine debugger are a reasonable",
119 "of the commands that gdb accepts.",
120 "The commands currently are:",
121 " break [*<addr>] delete break bpnum",
122 " disable bpnum enable bpnum",
123 " condition <bpnum> [<expr>]",
125 " help quit",
126 " bt cont [N]",
127 " step [N] next [N]",
128 " stepi [N] nexti [N]",
129 " x <addr> print <expr>",
130 " set <reg> = <expr> set *<addr> = <expr>",
131 " up down",
132 " list <lines> frame <n>",
133 " finish show dir",
134 " dir <path> display <expr>",
135 " delete display <disnum> undisplay <disnum>\n",
137 "Wine-specific commands:",
138 " mode [16,32] walk [wnd,class,queue] <handle>",
139 " info (see 'help info' for options)\n",
141 "The 'x' command accepts repeat counts and formats (including 'i') in the",
142 "same way that gdb does.\n",
144 " The following are examples of legal expressions:",
145 " $eax $eax+0x3 0x1000 ($eip + 256) *$eax *($esp + 3)",
146 " Also, a nm format symbol table can be read from a file using the",
147 " symbolfile command. Symbols can also be defined individually with",
148 " the define command.",
150 NULL
153 while(helptext[i]) fprintf(stderr,"%s\n", helptext[i++]);
157 /***********************************************************************
158 * DEBUG_HelpInfo
160 * Implementation of the 'help info' command.
162 void DEBUG_HelpInfo(void)
164 int i = 0;
165 static const char * const infotext[] =
167 "The info commands allow you to get assorted bits of interesting stuff",
168 "to be displayed. The options are:",
169 " info break Dumps information about breakpoints",
170 " info display Shows auto-display expressions in use",
171 " info locals Displays values of all local vars for current frame",
172 " info module Displays information about all modules",
173 " info queue <handle> Dumps queue information",
174 " info reg Displays values in all registers at top of stack",
175 " info segments Dumps information about all known segments",
176 " info share Dumps information about shared libraries",
177 " info stack Dumps information about top of stack",
178 " info wnd <handle> Dumps information about all windows",
180 NULL
183 while(infotext[i]) fprintf(stderr,"%s\n", infotext[i++]);