Implementation of custom dialog messages and notifications.
[wine.git] / debugger / info.c
blobec1f0989596c47a6f46d88e59d4586cc5dcf98d0
1 /*
2 * Wine debugger utility routines
4 * Copyright 1993 Eric Youngdale
5 * Copyright 1995 Alexandre Julliard
6 */
8 #include "config.h"
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include "debugger.h"
12 #include "expr.h"
14 /***********************************************************************
15 * DEBUG_PrintBasic
17 * Implementation of the 'print' command.
19 void DEBUG_PrintBasic( const DBG_ADDR *addr, int count, char format )
21 char * default_format;
22 long long int value;
24 if( addr->type == NULL )
26 fprintf(stderr, "Unable to evaluate expression\n");
27 return;
30 default_format = NULL;
31 value = DEBUG_GetExprValue((DBG_ADDR *) addr, &default_format);
33 switch(format)
35 case 'x':
36 if (addr->seg)
38 DEBUG_nchar += fprintf( stderr, "0x%04lx", (long unsigned int) value );
40 else
42 DEBUG_nchar += fprintf( stderr, "0x%08lx", (long unsigned int) value );
44 break;
46 case 'd':
47 DEBUG_nchar += fprintf( stderr, "%ld\n", (long int) value );
48 break;
50 case 'c':
51 DEBUG_nchar += fprintf( stderr, "%d = '%c'",
52 (char)(value & 0xff), (char)(value & 0xff) );
53 break;
55 case 'i':
56 case 's':
57 case 'w':
58 case 'b':
59 fprintf( stderr, "Format specifier '%c' is meaningless in 'print' command\n", format );
60 case 0:
61 if( default_format != NULL )
63 DEBUG_nchar += fprintf( stderr, default_format, value );
65 break;
70 /***********************************************************************
71 * DEBUG_PrintAddress
73 * Print an 16- or 32-bit address, with the nearest symbol if any.
75 struct symbol_info
76 DEBUG_PrintAddress( const DBG_ADDR *addr, int addrlen, int flag )
78 struct symbol_info rtn;
80 const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, 0,
81 &rtn.list );
83 if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg&0xFFFF );
84 if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
85 else fprintf( stderr, "0x%08lx", addr->off );
86 if (name) fprintf( stderr, " (%s)", name );
87 return rtn;
89 /***********************************************************************
90 * DEBUG_PrintAddressAndArgs
92 * Print an 16- or 32-bit address, with the nearest symbol if any.
93 * Similar to DEBUG_PrintAddress, but we print the arguments to
94 * each function (if known). This is useful in a backtrace.
96 struct symbol_info
97 DEBUG_PrintAddressAndArgs( const DBG_ADDR *addr, int addrlen,
98 unsigned int ebp, int flag )
100 struct symbol_info rtn;
102 const char *name = DEBUG_FindNearestSymbol( addr, flag, &rtn.sym, ebp,
103 &rtn.list );
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 );
110 return rtn;
114 /***********************************************************************
115 * DEBUG_Help
117 * Implementation of the 'help' command.
119 void DEBUG_Help(void)
121 int i = 0;
122 static const char * const helptext[] =
124 "The commands accepted by the Wine debugger are a reasonable",
125 "subset of the commands that gdb accepts.",
126 "The commands currently are:",
127 " help quit",
128 " break [*<addr>] delete break bpnum",
129 " disable bpnum enable bpnum",
130 " condition <bpnum> [<expr>] pass",
131 " bt cont [N]",
132 " step [N] next [N]",
133 " stepi [N] nexti [N]",
134 " x <addr> print <expr>",
135 " set <reg> = <expr> set *<addr> = <expr>",
136 " up down",
137 " list <lines> disassemble [<addr>][,<addr>]",
138 " frame <n> finish",
139 " show dir dir <path>",
140 " display <expr> undisplay <disnum>",
141 " delete display <disnum> debugmsg <class>[-+]<type>\n",
142 " mode [16,32] walk [wnd,class,queue,module,",
143 " process,modref <pid>]",
144 " info (see 'help info' for options)\n",
146 "The 'x' command accepts repeat counts and formats (including 'i') in the",
147 "same way that gdb does.\n",
149 " The following are examples of legal expressions:",
150 " $eax $eax+0x3 0x1000 ($eip + 256) *$eax *($esp + 3)",
151 " Also, a nm format symbol table can be read from a file using the",
152 " symbolfile command. Symbols can also be defined individually with",
153 " the define command.",
155 NULL
158 while(helptext[i]) fprintf(stderr,"%s\n", helptext[i++]);
162 /***********************************************************************
163 * DEBUG_HelpInfo
165 * Implementation of the 'help info' command.
167 void DEBUG_HelpInfo(void)
169 int i = 0;
170 static const char * const infotext[] =
172 "The info commands allow you to get assorted bits of interesting stuff",
173 "to be displayed. The options are:",
174 " info break Dumps information about breakpoints",
175 " info display Shows auto-display expressions in use",
176 " info locals Displays values of all local vars for current frame",
177 " info maps Dumps all virtual memory mappings",
178 " info module <handle> Displays internal module state",
179 " info queue <handle> Displays internal queue state",
180 " info reg Displays values in all registers at top of stack",
181 " info segments Dumps information about all known segments",
182 " info share Dumps information about shared libraries",
183 " info stack Dumps information about top of stack",
184 " info wnd <handle> Displays internal window state",
186 NULL
189 while(infotext[i]) fprintf(stderr,"%s\n", infotext[i++]);