Release 960811
[wine/multimedia.git] / debugger / info.c
blob36e5cabd6070b2c3085baa5885ae8a7541a57a5d
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"
12 /***********************************************************************
13 * DEBUG_Print
15 * Implementation of the 'print' command.
17 void DEBUG_Print( const DBG_ADDR *addr, int count, char format )
19 if (count != 1)
21 fprintf( stderr, "Count other than 1 is meaningless in 'print' command\n" );
22 return;
25 if (addr->seg && (addr->seg != 0xffffffff))
27 switch(format)
29 case 'x':
30 fprintf( stderr, "0x%04lx:", addr->seg );
31 break;
33 case 'd':
34 fprintf( stderr, "%ld:", addr->seg );
35 break;
37 case 'c':
38 break; /* No segment to print */
40 case 'i':
41 case 's':
42 case 'w':
43 case 'b':
44 break; /* Meaningless format */
48 switch(format)
50 case 'x':
51 if (addr->seg) fprintf( stderr, "0x%04lx\n", addr->off );
52 else fprintf( stderr, "0x%08lx\n", addr->off );
53 break;
55 case 'd':
56 fprintf( stderr, "%ld\n", addr->off );
57 break;
59 case 'c':
60 fprintf( stderr, "%d = '%c'\n",
61 (char)(addr->off & 0xff), (char)(addr->off & 0xff) );
62 break;
64 case 'i':
65 case 's':
66 case 'w':
67 case 'b':
68 fprintf( stderr, "Format specifier '%c' is meaningless in 'print' command\n", format );
69 break;
74 /***********************************************************************
75 * DEBUG_PrintAddress
77 * Print an 16- or 32-bit address, with the nearest symbol if any.
79 void DEBUG_PrintAddress( const DBG_ADDR *addr, int addrlen )
81 const char *name = DEBUG_FindNearestSymbol( addr );
83 if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg );
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 );
90 /***********************************************************************
91 * DEBUG_Help
93 * Implementation of the 'help' command.
95 void DEBUG_Help(void)
97 int i = 0;
98 static const char * const helptext[] =
100 "The commands accepted by the Wine debugger are a small subset",
101 "of the commands that gdb would accept. The commands currently",
102 "are:\n",
103 " break [*<addr>] delete break bpnum",
104 " disable bpnum enable bpnum",
105 " help quit",
106 " x <addr> cont",
107 " step next",
108 " mode [16,32] print <expr>",
109 " set <reg> = <expr> set *<addr> = <expr>",
110 " walk [wnd] <expr> dump [wnd, queue] <expr>",
111 " info [reg,stack,break,segments] bt",
112 " symbolfile <filename> define <identifier> <addr>",
113 " list <addr> ",
115 "The 'x' command accepts repeat counts and formats (including 'i') in the",
116 "same way that gdb does.",
118 " The following are examples of legal expressions:",
119 " $eax $eax+0x3 0x1000 ($eip + 256) *$eax *($esp + 3)",
120 " Also, a nm format symbol table can be read from a file using the",
121 " symbolfile command. Symbols can also be defined individually with",
122 " the define command.",
124 NULL
127 while(helptext[i]) fprintf(stderr,"%s\n", helptext[i++]);
132 /***********************************************************************
133 * DEBUG_List
135 * Implementation of the 'list' command.
137 void DEBUG_List( DBG_ADDR *addr, int count )
139 static DBG_ADDR lasttime = { 0xffffffff, 0 };
141 if (addr == NULL) addr = &lasttime;
142 DBG_FIX_ADDR_SEG( addr, CS_reg(DEBUG_context) );
143 while (count-- > 0)
145 DEBUG_PrintAddress( addr, dbg_mode );
146 fprintf( stderr, ": " );
147 if (!DBG_CHECK_READ_PTR( addr, 1 )) return;
148 DEBUG_Disasm( addr );
149 fprintf (stderr, "\n");
151 lasttime = *addr;