-
Notifications
You must be signed in to change notification settings - Fork 0
/
internal-debugger.html
685 lines (639 loc) · 16 KB
/
internal-debugger.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
http://bochs.sourceforge.net/doc/docbook/user/internal-debugger.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Using Bochs internal debugger</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Bochs User Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Tips and Techniques"
HREF="howto.html"><LINK
REL="PREVIOUS"
TITLE="Using the 'socket' networking module"
HREF="using-socket.html"><LINK
REL="NEXT"
TITLE="Using Bochs and the remote GDB stub"
HREF="debugging-with-gdb.html"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Bochs User Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="using-socket.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 8. Tips and Techniques</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="debugging-with-gdb.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="INTERNAL-DEBUGGER"
>8.14. Using Bochs internal debugger</A
></H1
><P
>You can now conditionally compile in a GDB like command line debugger, that
allows you to set breakpoints, step through instructions, and other
useful functions. If there isn't a command for something you believe
is generally useful for the debugger, let me know and I'll implement
it if possible.</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>This section describes how to enable and use the Bochs command line debugger.
For it's builtin graphical front-end please see the <A
HREF="internal-debugger.html#DEBUGGER-GUI"
>debugger gui</A
>
section how to enable it.</P
></BLOCKQUOTE
></DIV
><P
>To use the debugger, you must configure Bochs with the
<CODE
CLASS="OPTION"
>--enable-debugger</CODE
> and <CODE
CLASS="OPTION"
>--enable-disasm</CODE
> flags.
For example:
<PRE
CLASS="SCREEN"
> ./configure --enable-debugger --enable-disasm</PRE
></P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>You must use flex version 2.5.4 or greater. I have heard that
version 2.5.2 will not work.</P
></BLOCKQUOTE
></DIV
><P
>When you first start up Bochs, you will see the command line prompt
<PRE
CLASS="SCREEN"
> bochs:1></PRE
>
From here, you may use the following commands:</P
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4156"
>8.14.1. Execution Control</A
></H2
><P
><PRE
CLASS="SCREEN"
> c continue executing
cont
continue
s [count] execute count instructions, default is 1
step [count]
s [cpu] [count] for SMP simulation, execute count instructions on cpu, default is 1
step [cpu] [count]
s all [count] for SMP simulation, execute count instructions on all cpus
step all [count]
Ctrl-C stop execution, and return to command line prompt
Ctrl-D if at empty line on command line, exit
q quit debugger and execution
quit
exit</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4160"
>8.14.2. BreakPoints</A
></H2
><P
><PRE
CLASS="SCREEN"
> NOTE: The format of 'seg', 'off', and 'addr' in these descriptions,
are as follows. I don't have any way to set the current radix.
hexidecimal: 0xcdef0123
decimal: 123456789
octal: 01234567
vbreak seg:off Set a virtual address instruction breakpoint
vb seg:off
lbreak addr Set a linear address instruction breakpoint
lb addr
pbreak [*] addr Set a physical address instruction breakpoint
pb [*] addr (the '*' is optional for GDB compatibility)
break [*] addr
b [*] addr
info break Display state of all current breakpoints
bpe n Enable a breakpoint
bpd n Disable a breakpoint
delete n Delete a breakpoint
del n
d n </PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4164"
>8.14.3. Memory WatchPoints</A
></H2
><P
><PRE
CLASS="SCREEN"
> watch read addr Insert a read watch point at physical address <CODE
CLASS="VARNAME"
>addr</CODE
>
watch r addr Insert a read watch point at physical address <CODE
CLASS="VARNAME"
>addr</CODE
>
watch write addr Insert a write watch point at physical address <CODE
CLASS="VARNAME"
>addr</CODE
>
watch w addr Insert a write watch point at physical address <CODE
CLASS="VARNAME"
>addr</CODE
>
watch Display state of current memory watchpoints
watch stop Stop simulation when a watchpoint is encountered (default)
watch continue Do not stop simulation when a watchpoint is encountered
unwatch addr Remove watchpoint to specific physical address
unwatch Remove all watch points
trace-mem on/off Enable/Disable memory access tracing </PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4172"
>8.14.4. Manipulating Memory</A
></H2
><P
><PRE
CLASS="SCREEN"
> x /nuf addr Examine memory at linear address addr
xp /nuf addr Examine memory at physical address addr
n Count of how many units to display
u Unit size; one of
b Individual bytes
h Halfwords (2 bytes)
w Words (4 bytes)
g Giant words (8 bytes)
NOTE: these are *not* typical Intel nomenclature sizes,
but they are consistent with GDB convention.
f Printing format. one of
x Print in hexadecimal
d Print in decimal
u Print in unsigned decimal
o Print in octal
t Print in binary
n, f, and u are optional parameters. u and f default to the last values
you used, or to w(words) and x(hex) if none have been supplied.
n currently defaults to 1. If none of these optional parameters are
used, no slash should be typed. addr is also optional. If you don't
specify it, it will be the value the next address (as if you had
specified n+1 in the last x command).
setpmem addr datasize val Set physical memory location of size
datasize to value val.
writemem dump a number of bytes of virtual memory starting from
the specified linear address into a file
crc addr1 addr2 Show CRC32 for physical memory range addr1..addr2 </PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4176"
>8.14.5. Info commands</A
></H2
><P
><PRE
CLASS="SCREEN"
> r|reg|regs|registers List of CPU integer registers and their contents
fp|fpu List of all FPU registers and their contents
mmx List of all MMX registers and their contents
sse|xmm List of all SSE registers and their contents
ymm List of all AVX registers and their contents
sreg Show segment registers and their contents
dreg Show debug registers and their contents
creg Show control registers and their contents
info cpu List of all CPU registers and their contents
info eflags Show decoded EFLAGS register
info break Information about current breakpoint status
info tab Show paging address translation
info device Show state of the specified device</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4180"
>8.14.6. Manipulating CPU Registers</A
></H2
><P
><PRE
CLASS="SCREEN"
> set reg = expr Change a CPU register to value of expression.
Currently only general purpose registers and instruction pointer
are supported. You may not change eflags, segment registers,
floating point or SIMD registers.
Examples: set eax = 2+2/2
set esi = 2*eax+ebx
registers List of CPU registers and their contents
regs
reg
r</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4184"
>8.14.7. Disassembly commands</A
></H2
><P
><PRE
CLASS="SCREEN"
> disassemble start end Disassemble instructions in given linear address
range, inclusive of start, exclusive of end.
Use "set $disassemble_size =" to tell
debugger desired segment size. Use a value for
end of less than start (or zero) if you only
want the first instruction disassembled.
disassemble switch-mode Switch between Intel and AT&T disassebly styles
for debugger disassembler.
disassemble size = n Tell debugger what segment size to use when
the "disassemble" command is used. Use values
of 0, 16 or 32 for n. Value of 0 means
"use segment size specified by current CS
segment". Default is 0.
set $auto_disassemble = n Cause debugger to disassemble current instruction
every time execution stops if n=1. Default is 0.
Segment size of current CPU context is used for
disassembly, so the "disassemble size" variable is
ignored.
set disassemble on The same as 'set $auto_disassemble = 1'
set disassemble off The same as 'set $auto_disassemble = 0'</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4188"
>8.14.8. Instruction tracing</A
></H2
><P
><PRE
CLASS="SCREEN"
> trace on Disassemble every executed instruction. Note
that instructions which caused exceptions are
not really executed, and therefore not traced.
trace off Disable instruction tracing.</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4192"
>8.14.9. Instrumentation</A
></H2
><P
> To use instrumentation features in bochs, you must compile in support for it.
You should build a custom instrumentation library in a separate directory in
the "instrument/" directory. To tell configure which instrumentation library
you want to use, use the <CODE
CLASS="OPTION"
>--enable-instrumentation</CODE
> option.
The default library consists of a set of stubs, and the following are
equivalent:
<PRE
CLASS="SCREEN"
> ./configure [...] --enable-instrumentation
./configure [...] --enable-instrumentation="instrument/stubs"</PRE
>
You could make a separate directory with your custom library,
for example "instrument/myinstrument", copy the contents of
the "instrument/stubs" directory to it, then customize it. Use:
<PRE
CLASS="SCREEN"
> ./configure [...] --enable-instrumentation="instrument/myinstrument"</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4198"
>8.14.10. Instrumentation commands</A
></H2
><P
><PRE
CLASS="SCREEN"
> instrument [command] calls BX_INSTR_DEBUG_CMD instrumentation callback with [command]</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4202"
>8.14.11. Other Commands</A
></H2
><P
> <PRE
CLASS="SCREEN"
>ptime</PRE
>
Print the current time (number of ticks since start of simulation).
<PRE
CLASS="SCREEN"
>sb <CODE
CLASS="VARNAME"
>delta</CODE
></PRE
>
Insert a time break point "delta" instructions into the future ("delta" is a 64-bit integer followed by "L", for example 1000L).
<PRE
CLASS="SCREEN"
>sba <CODE
CLASS="VARNAME"
>time</CODE
></PRE
>
Insert a time break point at "time" ("time" is a 64-bit integer followed by "L", for example 1000L).
<PRE
CLASS="SCREEN"
>print-stack [<CODE
CLASS="VARNAME"
>num words</CODE
>]</PRE
>
Print the <CODE
CLASS="VARNAME"
>num words</CODE
> top 16-bit words on the stack. <CODE
CLASS="VARNAME"
>Num
words</CODE
> defaults to 16. Only works reliably in protected mode when
the base address of the stack segment is zero.
<PRE
CLASS="SCREEN"
>modebp</PRE
>
Toggles CPU mode switch breakpoint.
<PRE
CLASS="SCREEN"
>ldsym [global] <CODE
CLASS="VARNAME"
>filename</CODE
> [<CODE
CLASS="VARNAME"
>offset</CODE
>]</PRE
>
Load symbols from file <CODE
CLASS="VARNAME"
>filename</CODE
>. If the global keyword is
added, then the the symbols will be visible in all contexts for which
symbols have not been loaded. <CODE
CLASS="VARNAME"
>Offset</CODE
> (default is 0) is added to
every symbol entry. The symbols are loaded in the current (executing)
context.</P
><P
>The symbol file consists of zero or more lines of the format <PRE
CLASS="SCREEN"
>"%x %s"</PRE
>.
<PRE
CLASS="SCREEN"
>show [<CODE
CLASS="VARNAME"
>string</CODE
>]</PRE
>
<PRE
CLASS="SCREEN"
> Toggles show symbolic info (calls to begin with).
show - shows current show mode
show mode - show, when processor switch mode
show int - show, when interrupt is happens
show call - show, when call is happens
show ret - show, when iret is happens
show off - toggles off symbolic info
show dbg-all - turn on all show flags
show dbg-none - turn off all show flags</PRE
></P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="DEBUGGER-GUI"
>8.14.12. The Bochs debugger gui</A
></H2
><P
>The graphical front-end for the Bochs command line debugger
is available for Windows and GTK2 hosts.</P
><P
>To use the gui debugger, you must configure Bochs with the
default debugger switches and the <CODE
CLASS="OPTION"
>--enable-debugger-gui</CODE
> flag.
For example:
<PRE
CLASS="SCREEN"
> ./configure --enable-debugger --enable-disasm --enable-debugger-gui</PRE
></P
><P
>At runtime you need to add the value <CODE
CLASS="OPTION"
>gui_debug</CODE
> to the
<A
HREF="bochsrc.html#BOCHSOPT-DISPLAYLIBRARY"
>display_library</A
> options parameter
in order to use the gui instead of the command line debugger. This example shows how to
use it with the 'x' gui:
<PRE
CLASS="SCREEN"
>display_library: x, options="gui_debug"</PRE
></P
><P
>The gui debugger consists of a gui window with a menu bar, a button bar and some
child windows that show the cpu registers, disassembler output, memory dump and
the internal debugger output. A command prompt for entering debugger commands is
also available.</P
><P
><IMG
SRC="../images/undercon.png"> List the features here.</P
><P
>Most of the gui debugger settings are now saved to an INI file on exit and
restored at the next run.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN4239"
>8.14.13. Related links</A
></H2
><P
><IMG
SRC="../images/undercon.png"> For information on advanced debugger usage see the <A
HREF="../development/debugger-advanced.html"
TARGET="_top"
>developer documentation</A
>
(under construction).</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="using-socket.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="debugging-with-gdb.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Using the 'socket' networking module</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="howto.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Using Bochs and the remote GDB stub</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>