Release 950817
[wine] / debugger / info.c
1 /*
2  * Wine debugger utility routines
3  *
4  * Copyright 1993 Eric Youngdale
5  * Copyright 1995 Alexandre Julliard
6  */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "debugger.h"
11
12
13 /***********************************************************************
14  *           DEBUG_Print
15  *
16  * Implementation of the 'print' command.
17  */
18 void DEBUG_Print( const DBG_ADDR *addr, int count, char format )
19 {
20     if (count != 1)
21     {
22         fprintf( stderr, "Count other than 1 is meaningless in 'print' command\n" );
23         return;
24     }
25
26     if (addr->seg && (addr->seg != 0xffffffff))
27     {
28         switch(format)
29         {
30         case 'x':
31             fprintf( stderr, "0x%04lx:", addr->seg );
32             break;
33
34         case 'd':
35             fprintf( stderr, "%ld:", addr->seg );
36             break;
37
38         case 'c':
39             break;  /* No segment to print */
40
41         case 'i':
42         case 's':
43         case 'w':
44         case 'b':
45             break;  /* Meaningless format */
46         }
47     }
48
49     switch(format)
50     {
51     case 'x':
52         if (addr->seg) fprintf( stderr, "0x%04lx\n", addr->off );
53         else fprintf( stderr, "0x%08lx\n", addr->off );
54         break;
55
56     case 'd':
57         fprintf( stderr, "%ld\n", addr->off );
58         break;
59
60     case 'c':
61         fprintf( stderr, "%d = '%c'\n",
62                  (char)(addr->off & 0xff), (char)(addr->off & 0xff) );
63         break;
64
65     case 'i':
66     case 's':
67     case 'w':
68     case 'b':
69         fprintf( stderr, "Format specifier '%c' is meaningless in 'print' command\n", format );
70         break;
71     }
72 }
73
74
75 /***********************************************************************
76  *           DEBUG_PrintAddress
77  *
78  * Print an 16- or 32-bit address, with the nearest symbol if any.
79  */
80 void DEBUG_PrintAddress( const DBG_ADDR *addr, int addrlen )
81 {
82     const char *name = DEBUG_FindNearestSymbol( addr );
83
84     if (addr->seg) fprintf( stderr, "0x%04lx:", addr->seg );
85     if (addrlen == 16) fprintf( stderr, "0x%04lx", addr->off );
86     else fprintf( stderr, "0x%08lx", addr->off );
87     if (name) fprintf( stderr, " (%s)", name );
88 }
89
90
91 /***********************************************************************
92  *           DEBUG_Help
93  *
94  * Implementation of the 'help' command.
95  */
96 void DEBUG_Help(void)
97 {
98     int i = 0;
99     static const char * helptext[] =
100 {
101 "The commands accepted by the Wine debugger are a small subset",
102 "of the commands that gdb would accept.  The commands currently",
103 "are:\n",
104 "  break [*<addr>]                      delete break bpnum",
105 "  disable bpnum                        enable bpnum",
106 "  help                                 quit",
107 "  x <addr>                             cont",
108 "  step                                 next",
109 "  mode [16,32]                         print <expr>",
110 "  set <reg> = <expr>                   set *<addr> = <expr>",
111 "  info [reg,stack,break,segments]      bt",
112 "  symbolfile <filename>                define <identifier> <addr>",
113 "",
114 "The 'x' command accepts repeat counts and formats (including 'i') in the",
115 "same way that gdb does.",
116 "",
117 " The following are examples of legal expressions:",
118 " $eax     $eax+0x3   0x1000   ($eip + 256)  *$eax   *($esp + 3)",
119 " Also, a nm format symbol table can be read from a file using the",
120 " symbolfile command.  Symbols can also be defined individually with",
121 " the define command.",
122 "",
123 NULL
124 };
125
126     while(helptext[i]) fprintf(stderr,"%s\n", helptext[i++]);
127 }