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.
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 /***********************************************************************
93 * Implementation of the 'help' command.
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",
103 " break [*<addr>] delete break bpnum",
104 " disable bpnum enable bpnum",
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>",
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.",
127 while(helptext
[i
]) fprintf(stderr
,"%s\n", helptext
[i
++]);
132 /***********************************************************************
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
) );
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");