- added instructions how to update the online documentation
[bochs-mirror.git] / bx_debug / parser.y
blobe429b1ab50ed2821a0aaeb5b0f36d6f64b026b0a
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: parser.y,v 1.33 2008/10/08 17:13:35 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
5 %{
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "debug.h"
10 #if BX_DEBUGGER
13 %union {
14 char *sval;
15 Bit64u uval;
16 bx_bool bval;
19 // Common registers
20 %type <uval> BX_TOKEN_NONSEG_REG
21 %type <uval> BX_TOKEN_SEGREG
22 %type <bval> BX_TOKEN_TOGGLE_ON_OFF
24 %token <uval> BX_TOKEN_8BH_REG
25 %token <uval> BX_TOKEN_8BL_REG
26 %token <uval> BX_TOKEN_16B_REG
27 %token <uval> BX_TOKEN_32B_REG
28 %token <uval> BX_TOKEN_64B_REG
29 %token <uval> BX_TOKEN_CS
30 %token <uval> BX_TOKEN_ES
31 %token <uval> BX_TOKEN_SS
32 %token <uval> BX_TOKEN_DS
33 %token <uval> BX_TOKEN_FS
34 %token <uval> BX_TOKEN_GS
35 %token <uval> BX_TOKEN_FLAGS
36 %token <bval> BX_TOKEN_ON
37 %token <bval> BX_TOKEN_OFF
38 %token <sval> BX_TOKEN_CONTINUE
39 %token <sval> BX_TOKEN_STEPN
40 %token <sval> BX_TOKEN_STEP_OVER
41 %token <sval> BX_TOKEN_NEXT_STEP
42 %token <sval> BX_TOKEN_SET
43 %token <sval> BX_TOKEN_DEBUGGER
44 %token <sval> BX_TOKEN_LIST_BREAK
45 %token <sval> BX_TOKEN_VBREAKPOINT
46 %token <sval> BX_TOKEN_LBREAKPOINT
47 %token <sval> BX_TOKEN_PBREAKPOINT
48 %token <sval> BX_TOKEN_DEL_BREAKPOINT
49 %token <sval> BX_TOKEN_ENABLE_BREAKPOINT
50 %token <sval> BX_TOKEN_DISABLE_BREAKPOINT
51 %token <sval> BX_TOKEN_INFO
52 %token <sval> BX_TOKEN_QUIT
53 %token <sval> BX_TOKEN_REGISTERS
54 %token <sval> BX_TOKEN_CPU
55 %token <sval> BX_TOKEN_FPU
56 %token <sval> BX_TOKEN_SSE
57 %token <sval> BX_TOKEN_MMX
58 %token <sval> BX_TOKEN_IDT
59 %token <sval> BX_TOKEN_IVT
60 %token <sval> BX_TOKEN_GDT
61 %token <sval> BX_TOKEN_LDT
62 %token <sval> BX_TOKEN_TSS
63 %token <sval> BX_TOKEN_TAB
64 %token <sval> BX_TOKEN_DIRTY
65 %token <sval> BX_TOKEN_LINUX
66 %token <sval> BX_TOKEN_CONTROL_REGS
67 %token <sval> BX_TOKEN_SEGMENT_REGS
68 %token <sval> BX_TOKEN_EXAMINE
69 %token <sval> BX_TOKEN_XFORMAT
70 %token <sval> BX_TOKEN_DISFORMAT
71 %token <sval> BX_TOKEN_RESTORE
72 %token <sval> BX_TOKEN_SETPMEM
73 %token <sval> BX_TOKEN_SYMBOLNAME
74 %token <sval> BX_TOKEN_QUERY
75 %token <sval> BX_TOKEN_PENDING
76 %token <sval> BX_TOKEN_TAKE
77 %token <sval> BX_TOKEN_DMA
78 %token <sval> BX_TOKEN_IRQ
79 %token <sval> BX_TOKEN_DISASSEMBLE
80 %token <sval> BX_TOKEN_INSTRUMENT
81 %token <sval> BX_TOKEN_STRING
82 %token <sval> BX_TOKEN_STOP
83 %token <sval> BX_TOKEN_DOIT
84 %token <sval> BX_TOKEN_CRC
85 %token <sval> BX_TOKEN_TRACE
86 %token <sval> BX_TOKEN_TRACEREG
87 %token <sval> BX_TOKEN_TRACEMEM
88 %token <sval> BX_TOKEN_SWITCH_MODE
89 %token <sval> BX_TOKEN_SIZE
90 %token <sval> BX_TOKEN_PTIME
91 %token <sval> BX_TOKEN_TIMEBP_ABSOLUTE
92 %token <sval> BX_TOKEN_TIMEBP
93 %token <sval> BX_TOKEN_RECORD
94 %token <sval> BX_TOKEN_PLAYBACK
95 %token <sval> BX_TOKEN_MODEBP
96 %token <sval> BX_TOKEN_PRINT_STACK
97 %token <sval> BX_TOKEN_WATCH
98 %token <sval> BX_TOKEN_UNWATCH
99 %token <sval> BX_TOKEN_READ
100 %token <sval> BX_TOKEN_WRITE
101 %token <sval> BX_TOKEN_SHOW
102 %token <sval> BX_TOKEN_LOAD_SYMBOLS
103 %token <sval> BX_TOKEN_SYMBOLS
104 %token <sval> BX_TOKEN_LIST_SYMBOLS
105 %token <sval> BX_TOKEN_GLOBAL
106 %token <sval> BX_TOKEN_WHERE
107 %token <sval> BX_TOKEN_PRINT_STRING
108 %token <uval> BX_TOKEN_NUMERIC
109 %token <sval> BX_TOKEN_NE2000
110 %token <sval> BX_TOKEN_PIC
111 %token <sval> BX_TOKEN_PAGE
112 %token <sval> BX_TOKEN_HELP
113 %token <sval> BX_TOKEN_CALC
114 %token <sval> BX_TOKEN_VGA
115 %token <sval> BX_TOKEN_PCI
116 %token <sval> BX_TOKEN_COMMAND
117 %token <sval> BX_TOKEN_GENERIC
118 %token BX_TOKEN_RSHIFT
119 %token BX_TOKEN_LSHIFT
120 %token BX_TOKEN_REG_IP
121 %token BX_TOKEN_REG_EIP
122 %token BX_TOKEN_REG_RIP
123 %type <uval> optional_numeric
124 %type <uval> vexpression
125 %type <uval> expression
127 %left '+' '-' '|' '^'
128 %left '*' '/' '&' BX_TOKEN_LSHIFT BX_TOKEN_RSHIFT
129 %left NOT NEG
131 %start commands
134 commands:
135 commands command
136 | command
139 command:
140 continue_command
141 | stepN_command
142 | step_over_command
143 | set_command
144 | breakpoint_command
145 | info_command
146 | regs_command
147 | fpu_regs_command
148 | mmx_regs_command
149 | sse_regs_command
150 | segment_regs_command
151 | control_regs_command
152 | blist_command
153 | slist_command
154 | delete_command
155 | bpe_command
156 | bpd_command
157 | quit_command
158 | examine_command
159 | restore_command
160 | setpmem_command
161 | query_command
162 | take_command
163 | disassemble_command
164 | instrument_command
165 | doit_command
166 | crc_command
167 | trace_command
168 | trace_reg_command
169 | trace_mem_command
170 | ptime_command
171 | timebp_command
172 | record_command
173 | playback_command
174 | modebp_command
175 | print_stack_command
176 | watch_point_command
177 | page_command
178 | show_command
179 | symbol_command
180 | where_command
181 | print_string_command
182 | help_command
183 | calc_command
185 | '\n'
190 BX_TOKEN_TOGGLE_ON_OFF:
191 BX_TOKEN_ON
192 | BX_TOKEN_OFF
193 { $$=$1; }
196 BX_TOKEN_SEGREG:
197 BX_TOKEN_CS
198 | BX_TOKEN_ES
199 | BX_TOKEN_SS
200 | BX_TOKEN_DS
201 | BX_TOKEN_FS
202 | BX_TOKEN_GS
203 { $$=$1; }
206 timebp_command:
207 BX_TOKEN_TIMEBP BX_TOKEN_NUMERIC '\n'
209 bx_dbg_timebp_command(0, $2);
210 free($1);
212 | BX_TOKEN_TIMEBP_ABSOLUTE BX_TOKEN_NUMERIC '\n'
214 bx_dbg_timebp_command(1, $2);
215 free($1);
219 record_command:
220 BX_TOKEN_RECORD BX_TOKEN_STRING '\n'
222 bx_dbg_record_command($2);
223 free($1); free($2);
227 playback_command:
228 BX_TOKEN_PLAYBACK BX_TOKEN_STRING '\n'
230 bx_dbg_playback_command($2);
231 free($1); free($2);
235 modebp_command:
236 BX_TOKEN_MODEBP '\n'
238 bx_dbg_modebp_command();
239 free($1);
243 show_command:
244 BX_TOKEN_SHOW BX_TOKEN_COMMAND '\n'
246 bx_dbg_show_command($2);
247 free($1); free($2);
249 | BX_TOKEN_SHOW BX_TOKEN_STRING '\n'
251 bx_dbg_show_param_command($2);
252 free($1); free($2);
254 | BX_TOKEN_SHOW '\n'
256 bx_dbg_show_command(0);
257 free($1);
261 page_command:
262 BX_TOKEN_PAGE expression '\n'
264 bx_dbg_xlate_address($2);
265 free($1);
269 ptime_command:
270 BX_TOKEN_PTIME '\n'
272 bx_dbg_ptime_command();
273 free($1);
277 trace_command:
278 BX_TOKEN_TRACE BX_TOKEN_TOGGLE_ON_OFF '\n'
280 bx_dbg_trace_command($2);
281 free($1);
285 trace_reg_command:
286 BX_TOKEN_TRACEREG BX_TOKEN_TOGGLE_ON_OFF '\n'
288 bx_dbg_trace_reg_command($2);
289 free($1);
293 trace_mem_command:
294 BX_TOKEN_TRACEMEM BX_TOKEN_TOGGLE_ON_OFF '\n'
296 bx_dbg_trace_mem_command($2);
297 free($1);
301 print_stack_command:
302 BX_TOKEN_PRINT_STACK '\n'
304 bx_dbg_print_stack_command(16);
305 free($1);
307 | BX_TOKEN_PRINT_STACK BX_TOKEN_NUMERIC '\n'
309 bx_dbg_print_stack_command($2);
310 free($1);
314 watch_point_command:
315 BX_TOKEN_WATCH BX_TOKEN_STOP '\n'
317 watchpoint_continue = 0;
318 dbg_printf("Will stop on watch points\n");
319 free($1); free($2);
321 | BX_TOKEN_WATCH BX_TOKEN_CONTINUE '\n'
323 watchpoint_continue = 1;
324 dbg_printf("Will not stop on watch points (they will still be logged)\n");
325 free($1); free($2);
327 | BX_TOKEN_WATCH '\n'
329 bx_dbg_watch(-1, 0);
330 free($1);
332 | BX_TOKEN_WATCH BX_TOKEN_READ expression '\n'
334 bx_dbg_watch(0, $3); /* BX_READ */
335 free($1); free($2);
337 | BX_TOKEN_WATCH BX_TOKEN_WRITE expression '\n'
339 bx_dbg_watch(1, $3); /* BX_WRITE */
340 free($1); free($2);
342 | BX_TOKEN_UNWATCH '\n'
344 bx_dbg_unwatch(-1);
345 free($1);
347 | BX_TOKEN_UNWATCH expression '\n'
349 bx_dbg_unwatch($2);
350 free($1);
354 symbol_command:
355 BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_STRING '\n'
357 bx_dbg_symbol_command($2, 0, 0);
358 free($1); free($2);
360 | BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_STRING BX_TOKEN_NUMERIC '\n'
362 bx_dbg_symbol_command($2, 0, $3);
363 free($1); free($2);
365 | BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_GLOBAL BX_TOKEN_STRING '\n'
367 bx_dbg_symbol_command($3, 1, 0);
368 free($1); free($2); free($3);
370 | BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_GLOBAL BX_TOKEN_STRING BX_TOKEN_NUMERIC '\n'
372 bx_dbg_symbol_command($3, 1, $4);
373 free($1); free($2); free($3);
377 where_command:
378 BX_TOKEN_WHERE '\n'
380 bx_dbg_where_command();
381 free($1);
385 print_string_command:
386 BX_TOKEN_PRINT_STRING BX_TOKEN_NUMERIC '\n'
388 bx_dbg_print_string_command($2);
389 free($1);
393 continue_command:
394 BX_TOKEN_CONTINUE '\n'
396 bx_dbg_continue_command();
397 free($1);
401 stepN_command:
402 BX_TOKEN_STEPN '\n'
404 bx_dbg_stepN_command(1);
405 free($1);
407 | BX_TOKEN_STEPN BX_TOKEN_NUMERIC '\n'
409 bx_dbg_stepN_command($2);
410 free($1);
414 step_over_command:
415 BX_TOKEN_STEP_OVER '\n'
417 bx_dbg_step_over_command();
418 free($1);
422 set_command:
423 BX_TOKEN_SET BX_TOKEN_DISASSEMBLE BX_TOKEN_TOGGLE_ON_OFF '\n'
425 bx_dbg_set_auto_disassemble($3);
426 free($1); free($2);
428 | BX_TOKEN_SET BX_TOKEN_SYMBOLNAME '=' BX_TOKEN_NUMERIC '\n'
430 bx_dbg_set_symbol_command($2, $4);
431 free($1); free($2);
433 | BX_TOKEN_SET BX_TOKEN_8BL_REG '=' expression '\n'
435 bx_dbg_set_reg8l_value($2, $4);
437 | BX_TOKEN_SET BX_TOKEN_8BH_REG '=' expression '\n'
439 bx_dbg_set_reg8h_value($2, $4);
441 | BX_TOKEN_SET BX_TOKEN_16B_REG '=' expression '\n'
443 bx_dbg_set_reg16_value($2, $4);
445 | BX_TOKEN_SET BX_TOKEN_32B_REG '=' expression '\n'
447 bx_dbg_set_reg32_value($2, $4);
449 | BX_TOKEN_SET BX_TOKEN_64B_REG '=' expression '\n'
451 bx_dbg_set_reg64_value($2, $4);
455 breakpoint_command:
456 BX_TOKEN_VBREAKPOINT '\n'
458 bx_dbg_vbreakpoint_command(bkAtIP, 0, 0);
459 free($1);
461 | BX_TOKEN_VBREAKPOINT vexpression ':' vexpression '\n'
463 bx_dbg_vbreakpoint_command(bkRegular, $2, $4);
464 free($1);
466 | BX_TOKEN_LBREAKPOINT '\n'
468 bx_dbg_lbreakpoint_command(bkAtIP, 0);
469 free($1);
471 | BX_TOKEN_LBREAKPOINT expression '\n'
473 bx_dbg_lbreakpoint_command(bkRegular, $2);
474 free($1);
476 | BX_TOKEN_LBREAKPOINT BX_TOKEN_STRING '\n'
478 bx_dbg_lbreakpoint_symbol_command($2);
479 free($1);free($2);
481 | BX_TOKEN_PBREAKPOINT '\n'
483 bx_dbg_pbreakpoint_command(bkAtIP, 0);
484 free($1);
486 | BX_TOKEN_PBREAKPOINT expression '\n'
488 bx_dbg_pbreakpoint_command(bkRegular, $2);
489 free($1);
491 | BX_TOKEN_PBREAKPOINT '*' expression '\n'
493 bx_dbg_pbreakpoint_command(bkRegular, $3);
494 free($1);
498 blist_command:
499 BX_TOKEN_LIST_BREAK '\n'
501 bx_dbg_info_bpoints_command();
502 free($1);
506 slist_command:
507 BX_TOKEN_LIST_SYMBOLS '\n'
509 bx_dbg_info_symbols_command(0);
510 free($1);
512 | BX_TOKEN_LIST_SYMBOLS BX_TOKEN_STRING '\n'
514 bx_dbg_info_symbols_command($2);
515 free($1);free($2);
519 info_command:
520 BX_TOKEN_INFO BX_TOKEN_PBREAKPOINT '\n'
522 bx_dbg_info_bpoints_command();
523 free($1); free($2);
525 | BX_TOKEN_INFO BX_TOKEN_CPU '\n'
527 bx_dbg_info_registers_command(BX_INFO_GENERAL_PURPOSE_REGS | BX_INFO_FPU_REGS | BX_INFO_SSE_REGS);
528 free($1); free($2);
530 | BX_TOKEN_INFO BX_TOKEN_DIRTY '\n'
532 bx_dbg_info_dirty_command();
533 free($1); free($2);
535 | BX_TOKEN_INFO BX_TOKEN_IDT optional_numeric optional_numeric '\n'
537 bx_dbg_info_idt_command($3, $4);
538 free($1); free($2);
540 | BX_TOKEN_INFO BX_TOKEN_IVT optional_numeric optional_numeric '\n'
542 bx_dbg_info_ivt_command($3, $4);
543 free($1); free($2);
545 | BX_TOKEN_INFO BX_TOKEN_GDT optional_numeric optional_numeric '\n'
547 bx_dbg_info_gdt_command($3, $4);
548 free($1); free($2);
550 | BX_TOKEN_INFO BX_TOKEN_LDT optional_numeric optional_numeric '\n'
552 bx_dbg_info_ldt_command($3, $4);
553 free($1); free($2);
555 | BX_TOKEN_INFO BX_TOKEN_TAB '\n'
557 bx_dbg_dump_table();
558 free($1); free($2);
560 | BX_TOKEN_INFO BX_TOKEN_TSS '\n'
562 bx_dbg_info_tss_command();
563 free($1); free($2);
565 | BX_TOKEN_INFO BX_TOKEN_FLAGS '\n'
567 bx_dbg_info_flags();
568 free($1);
570 | BX_TOKEN_INFO BX_TOKEN_LINUX '\n'
572 bx_dbg_info_linux_command();
573 free($1); free($2);
575 | BX_TOKEN_INFO BX_TOKEN_SYMBOLS '\n'
577 bx_dbg_info_symbols_command(0);
578 free($1); free($2);
580 | BX_TOKEN_INFO BX_TOKEN_SYMBOLS BX_TOKEN_STRING '\n'
582 bx_dbg_info_symbols_command($3);
583 free($1); free($2); free($3);
585 | BX_TOKEN_INFO BX_TOKEN_NE2000 '\n'
587 bx_dbg_info_ne2k(-1, -1);
588 free($1); free($2);
590 | BX_TOKEN_INFO BX_TOKEN_NE2000 BX_TOKEN_PAGE BX_TOKEN_NUMERIC '\n'
592 free($1); free($2); free($3);
593 bx_dbg_info_ne2k($4, -1);
595 | BX_TOKEN_INFO BX_TOKEN_NE2000 BX_TOKEN_PAGE BX_TOKEN_NUMERIC BX_TOKEN_REGISTERS BX_TOKEN_NUMERIC '\n'
597 free($1); free($2); free($3); free($5);
598 bx_dbg_info_ne2k($4, $6);
600 | BX_TOKEN_INFO BX_TOKEN_PIC '\n'
602 bx_dbg_info_pic();
603 free($1); free($2);
605 | BX_TOKEN_INFO BX_TOKEN_VGA '\n'
607 bx_dbg_info_vga();
608 free($1); free($2);
610 | BX_TOKEN_INFO BX_TOKEN_PCI '\n'
612 bx_dbg_info_pci();
613 free($1); free($2);
617 optional_numeric :
618 /* empty */ { $$ = EMPTY_ARG; }
619 | BX_TOKEN_NUMERIC;
621 regs_command:
622 BX_TOKEN_REGISTERS '\n'
624 bx_dbg_info_registers_command(BX_INFO_GENERAL_PURPOSE_REGS);
625 free($1);
629 fpu_regs_command:
630 BX_TOKEN_FPU '\n'
632 bx_dbg_info_registers_command(BX_INFO_FPU_REGS);
633 free($1);
637 mmx_regs_command:
638 BX_TOKEN_MMX '\n'
640 bx_dbg_info_registers_command(BX_INFO_MMX_REGS);
641 free($1);
645 sse_regs_command:
646 BX_TOKEN_SSE '\n'
648 bx_dbg_info_registers_command(BX_INFO_SSE_REGS);
649 free($1);
653 segment_regs_command:
654 BX_TOKEN_SEGMENT_REGS '\n'
656 bx_dbg_info_segment_regs_command();
657 free($1);
661 control_regs_command:
662 BX_TOKEN_CONTROL_REGS '\n'
664 bx_dbg_info_control_regs_command();
665 free($1);
669 delete_command:
670 BX_TOKEN_DEL_BREAKPOINT BX_TOKEN_NUMERIC '\n'
672 bx_dbg_del_breakpoint_command($2);
673 free($1);
677 bpe_command:
678 BX_TOKEN_ENABLE_BREAKPOINT BX_TOKEN_NUMERIC '\n'
680 bx_dbg_en_dis_breakpoint_command($2, 1);
681 free($1);
684 bpd_command:
685 BX_TOKEN_DISABLE_BREAKPOINT BX_TOKEN_NUMERIC '\n'
687 bx_dbg_en_dis_breakpoint_command($2, 0);
688 free($1);
692 quit_command:
693 BX_TOKEN_QUIT '\n'
695 bx_dbg_quit_command();
696 free($1);
700 examine_command:
701 BX_TOKEN_EXAMINE BX_TOKEN_XFORMAT expression '\n'
703 bx_dbg_examine_command($1, $2,1, $3, 1);
704 free($1); free($2);
706 | BX_TOKEN_EXAMINE BX_TOKEN_XFORMAT '\n'
708 bx_dbg_examine_command($1, $2,1, 0, 0);
709 free($1); free($2);
711 | BX_TOKEN_EXAMINE expression '\n'
713 bx_dbg_examine_command($1, NULL,0, $2, 1);
714 free($1);
716 | BX_TOKEN_EXAMINE '\n'
718 bx_dbg_examine_command($1, NULL,0, 0, 0);
719 free($1);
723 restore_command:
724 BX_TOKEN_RESTORE BX_TOKEN_STRING BX_TOKEN_STRING '\n'
726 bx_dbg_restore_command($2, $3);
727 free($1); free($2); free($3);
731 setpmem_command:
732 BX_TOKEN_SETPMEM BX_TOKEN_NUMERIC BX_TOKEN_NUMERIC BX_TOKEN_NUMERIC '\n'
734 bx_dbg_setpmem_command($2, $3, $4);
735 free($1);
739 query_command:
740 BX_TOKEN_QUERY BX_TOKEN_PENDING '\n'
742 bx_dbg_query_command($2);
743 free($1); free($2);
747 take_command:
748 BX_TOKEN_TAKE BX_TOKEN_DMA '\n'
750 bx_dbg_take_command($2, 1);
751 free($1); free($2);
753 | BX_TOKEN_TAKE BX_TOKEN_DMA BX_TOKEN_NUMERIC '\n'
755 bx_dbg_take_command($2, $3);
756 free($1); free($2);
758 | BX_TOKEN_TAKE BX_TOKEN_IRQ '\n'
760 bx_dbg_take_command($2, 1);
761 free($1); free($2);
765 disassemble_command:
766 BX_TOKEN_DISASSEMBLE '\n'
768 bx_dbg_disassemble_current(NULL);
769 free($1);
771 | BX_TOKEN_DISASSEMBLE expression '\n'
773 bx_dbg_disassemble_command(NULL, $2, $2);
774 free($1);
776 | BX_TOKEN_DISASSEMBLE expression expression '\n'
778 bx_dbg_disassemble_command(NULL, $2, $3);
779 free($1);
781 | BX_TOKEN_DISASSEMBLE BX_TOKEN_DISFORMAT '\n'
783 bx_dbg_disassemble_current($2);
784 free($1); free($2);
786 | BX_TOKEN_DISASSEMBLE BX_TOKEN_DISFORMAT expression '\n'
788 bx_dbg_disassemble_command($2, $3, $3);
789 free($1); free($2);
791 | BX_TOKEN_DISASSEMBLE BX_TOKEN_DISFORMAT expression expression '\n'
793 bx_dbg_disassemble_command($2, $3, $4);
794 free($1); free($2);
796 | BX_TOKEN_DISASSEMBLE BX_TOKEN_SWITCH_MODE '\n'
798 bx_dbg_disassemble_switch_mode();
799 free($1); free($2);
801 | BX_TOKEN_DISASSEMBLE BX_TOKEN_SIZE '=' BX_TOKEN_NUMERIC '\n'
803 bx_dbg_set_disassemble_size($4);
804 free($1); free($2);
808 instrument_command:
809 BX_TOKEN_INSTRUMENT BX_TOKEN_STOP '\n'
811 bx_dbg_instrument_command($2);
812 free($1); free($2);
814 | BX_TOKEN_INSTRUMENT BX_TOKEN_COMMAND '\n'
816 bx_dbg_instrument_command($2);
817 free($1); free($2);
821 doit_command:
822 BX_TOKEN_DOIT BX_TOKEN_NUMERIC '\n'
824 bx_dbg_doit_command($2);
825 free($1);
829 crc_command:
830 BX_TOKEN_CRC BX_TOKEN_NUMERIC BX_TOKEN_NUMERIC '\n'
832 bx_dbg_crc_command($2, $3);
833 free($1);
837 help_command:
838 BX_TOKEN_HELP BX_TOKEN_QUIT '\n'
840 dbg_printf("q|quit|exit - quit debugger and emulator execution\n");
841 free($1);free($2);
843 | BX_TOKEN_HELP BX_TOKEN_CONTINUE '\n'
845 dbg_printf("c|cont|continue - continue executing\n");
846 free($1);free($2);
848 | BX_TOKEN_HELP BX_TOKEN_STEPN '\n'
850 dbg_printf("s|step|stepi [count] - execute #count instructions (default is one instruction)\n");
851 free($1);free($2);
853 | BX_TOKEN_HELP BX_TOKEN_STEP_OVER '\n'
855 dbg_printf("n|next|p - execute instruction stepping over subroutines\n");
856 free($1);free($2);
858 | BX_TOKEN_HELP BX_TOKEN_VBREAKPOINT '\n'
860 dbg_printf("vb|vbreak <seg:offset> - set a virtual address instruction breakpoint\n");
861 free($1);free($2);
863 | BX_TOKEN_HELP BX_TOKEN_LBREAKPOINT '\n'
865 dbg_printf("lb|lbreak <addr> - set a linear address instruction breakpoint\n");
866 free($1);free($2);
868 | BX_TOKEN_HELP BX_TOKEN_PBREAKPOINT '\n'
870 dbg_printf("p|pb|break|pbreak <addr> - set a physical address instruction breakpoint\n");
871 free($1);free($2);
873 | BX_TOKEN_HELP BX_TOKEN_DEL_BREAKPOINT '\n'
875 dbg_printf("d|del|delete <n> - delete a breakpoint\n");
876 free($1);free($2);
878 | BX_TOKEN_HELP BX_TOKEN_ENABLE_BREAKPOINT '\n'
880 dbg_printf("bpe <n> - enable a breakpoint\n");
881 free($1);free($2);
883 | BX_TOKEN_HELP BX_TOKEN_DISABLE_BREAKPOINT '\n'
885 dbg_printf("bpd <n> - disable a breakpoint\n");
886 free($1);free($2);
888 | BX_TOKEN_HELP BX_TOKEN_LIST_BREAK '\n'
890 dbg_printf("blist - list all breakpoints (same as 'info break')\n");
891 free($1);free($2);
893 | BX_TOKEN_HELP BX_TOKEN_MODEBP '\n'
895 dbg_printf("modebp - toggles mode switch breakpoint\n");
896 free($1);free($2);
898 | BX_TOKEN_HELP BX_TOKEN_CRC '\n'
900 dbg_printf("crc <addr1> <addr2> - show CRC32 for physical memory range addr1..addr2\n");
901 free($1);free($2);
903 | BX_TOKEN_HELP BX_TOKEN_TRACE '\n'
905 dbg_printf("trace on - print disassembly for every executed instruction\n");
906 dbg_printf("trace off - disable instruction tracing\n");
907 free($1);free($2);
909 | BX_TOKEN_HELP BX_TOKEN_TRACEREG '\n'
911 dbg_printf("trace-reg on - print all registers before every executed instruction\n");
912 dbg_printf("trace-reg off - disable registers state tracing\n");
913 free($1);free($2);
915 | BX_TOKEN_HELP BX_TOKEN_TRACEMEM '\n'
917 dbg_printf("trace-mem on - print all memory accesses occured during instruction execution\n");
918 dbg_printf("trace-mem off - disable memory accesses tracing\n");
919 free($1);free($2);
921 | BX_TOKEN_HELP BX_TOKEN_RESTORE '\n'
923 dbg_printf("restore <param_name> [path] - restore bochs root param from the file\n");
924 dbg_printf("for example:\n");
925 dbg_printf("restore \"cpu0\" - restore CPU #0 from file \"cpu0\" in current directory\n");
926 dbg_printf("restore \"cpu0\" \"/save\" - restore CPU #0 from file \"cpu0\" located in directory \"/save\"\n");
927 free($1);free($2);
929 | BX_TOKEN_HELP BX_TOKEN_PTIME '\n'
931 dbg_printf("ptime - print current time (number of ticks since start of simulation)\n");
932 free($1);free($2);
934 | BX_TOKEN_HELP BX_TOKEN_TIMEBP '\n'
936 dbg_printf("sb <delta> - insert a time breakpoint delta instructions into the future\n");
937 free($1);free($2);
939 | BX_TOKEN_HELP BX_TOKEN_TIMEBP_ABSOLUTE '\n'
941 dbg_printf("sba <time> - insert breakpoint at specific time\n");
942 free($1);free($2);
944 | BX_TOKEN_HELP BX_TOKEN_PRINT_STACK '\n'
946 dbg_printf("print-stack [num_words] - print the num_words top 16 bit words on the stack\n");
947 free($1);free($2);
949 | BX_TOKEN_HELP BX_TOKEN_RECORD '\n'
951 dbg_printf("record <filename> - record console input to file filename\n");
952 free($1);free($2);
954 | BX_TOKEN_HELP BX_TOKEN_PLAYBACK '\n'
956 dbg_printf("playback <filename> - playback console input from file filename\n");
957 free($1);free($2);
959 | BX_TOKEN_HELP BX_TOKEN_LOAD_SYMBOLS '\n'
961 dbg_printf("ldsym [global] <filename> [offset] - load symbols from file\n");
962 free($1);free($2);
964 | BX_TOKEN_HELP BX_TOKEN_LIST_SYMBOLS '\n'
966 dbg_printf("slist [string] - list symbols whose preffix is string (same as 'info symbols')\n");
967 free($1);free($2);
969 | BX_TOKEN_HELP BX_TOKEN_REGISTERS '\n'
971 dbg_printf("r|reg|regs|registers - list of CPU registers and their contents (same as 'info registers')\n");
972 free($1);free($2);
974 | BX_TOKEN_HELP BX_TOKEN_FPU '\n'
976 dbg_printf("fp|fpu| - print FPU state\n");
977 free($1);free($2);
979 | BX_TOKEN_HELP BX_TOKEN_MMX '\n'
981 dbg_printf("mmx - print MMX state\n");
982 free($1);free($2);
984 | BX_TOKEN_HELP BX_TOKEN_SSE '\n'
986 dbg_printf("sse|xmm - print SSE state\n");
987 free($1);free($2);
989 | BX_TOKEN_HELP BX_TOKEN_SEGMENT_REGS '\n'
991 dbg_printf("sreg - show segment registers\n");
992 free($1);free($2);
994 | BX_TOKEN_HELP BX_TOKEN_CONTROL_REGS '\n'
996 dbg_printf("creg - show control registers\n");
997 free($1);free($2);
999 | BX_TOKEN_HELP BX_TOKEN_SETPMEM '\n'
1001 dbg_printf("setpmem <addr> <datasize> <val> - set physical memory location of size 'datasize' to value 'val'\n");
1002 free($1);free($2);
1004 | BX_TOKEN_HELP BX_TOKEN_DISASSEMBLE '\n'
1006 dbg_printf("u|disasm|disassemble [/count] <start> <end> - disassemble instructions for given linear address\n");
1007 dbg_printf(" Optional 'count' is the number of disassembled instructions\n");
1008 dbg_printf("u|disasm|disassemble switch-mode - switch between Intel and AT&T disassembler syntax\n");
1009 dbg_printf("u|disasm|disassemble size = n - tell debugger what segment size [16|32|64] to use\n");
1010 dbg_printf(" when \"disassemble\" command is used.\n");
1011 free($1);free($2);
1013 | BX_TOKEN_HELP BX_TOKEN_WATCH '\n'
1015 dbg_printf("watch - print current watch point status\n");
1016 dbg_printf("watch stop - stop simulation when a watchpoint is encountred\n");
1017 dbg_printf("watch continue - do not stop the simulation when watch point is encountred\n");
1018 dbg_printf("watch read addr - insert a read watch point at physical address addr\n");
1019 dbg_printf("watch write addr - insert a write watch point at physical address addr\n");
1020 free($1);free($2);
1022 | BX_TOKEN_HELP BX_TOKEN_UNWATCH '\n'
1024 dbg_printf("unwatch - remove all watch points\n");
1025 dbg_printf("unwatch addr - remove a watch point\n");
1026 free($1);free($2);
1028 | BX_TOKEN_HELP BX_TOKEN_EXAMINE '\n'
1030 dbg_printf("x /nuf <addr> - examine memory at linear address\n");
1031 dbg_printf("xp /nuf <addr> - examine memory at physical address\n");
1032 dbg_printf(" nuf is a sequence of numbers (how much values to display)\n");
1033 dbg_printf(" and one or more of the [mxduotcsibhwg] format specificators:\n");
1034 dbg_printf(" x,d,u,o,t,c,s,i select the format of the output (they stand for\n");
1035 dbg_printf(" hex, decimal, unsigned, octal, binary, char, asciiz, instr)\n");
1036 dbg_printf(" b,h,w,g select the size of a data element (for byte, half-word,\n");
1037 dbg_printf(" word and giant word)\n");
1038 dbg_printf(" m selects an alternative output format (memory dump)\n");
1039 free($1);free($2);
1041 | BX_TOKEN_HELP BX_TOKEN_INSTRUMENT '\n'
1043 dbg_printf("instrument start - calls bx_instr_start() callback\n");
1044 dbg_printf("instrument stop - calls bx_instr_stop () callback\n");
1045 dbg_printf("instrument reset - calls bx_instr_reset() callback\n");
1046 dbg_printf("instrument print - calls bx_instr_print() callback\n");
1047 free($1);free($2);
1049 | BX_TOKEN_HELP BX_TOKEN_SET '\n'
1051 dbg_printf("set <regname> = <expr> - set register value to expression\n");
1052 dbg_printf("set $reg = val - set CPU register to value val\n");
1053 dbg_printf("set $auto_disassemble = 1 - cause debugger to disassemble current instruction\n");
1054 dbg_printf(" every time execution stops\n");
1055 dbg_printf("set u|disasm|disassemble on - same as 'set $auto_disassemble = 1'\n");
1056 dbg_printf("set u|disasm|disassemble off - same as 'set $auto_disassemble = 0'\n");
1057 free($1);free($2);
1059 | BX_TOKEN_HELP BX_TOKEN_PAGE '\n'
1061 dbg_printf("page <laddr> - show linear to physical xlation for linear address laddr\n");
1062 free($1);free($2);
1064 | BX_TOKEN_HELP BX_TOKEN_INFO '\n'
1066 dbg_printf("info break - show information about current breakpoint status\n");
1067 dbg_printf("info dirty - show physical pages dirtied (written to) since last display\n");
1068 dbg_printf("info idt - show interrupt descriptor table\n");
1069 dbg_printf("info ivt - show interrupt vector table\n");
1070 dbg_printf("info gdt - show global descriptor table\n");
1071 dbg_printf("info tss - show current task state segment\n");
1072 dbg_printf("info tab - show page tables\n");
1073 dbg_printf("info eflags - show decoded EFLAGS register\n");
1074 dbg_printf("info symbols [string] - list symbols whose prefix is string\n");
1075 dbg_printf("info pic - show PICs registers\n");
1076 dbg_printf("info ne2000 - show NE2000 registers\n");
1077 dbg_printf("info vga - show vga registers\n");
1078 dbg_printf("info pci - show i440fx PCI state\n");
1079 free($1);free($2);
1081 | BX_TOKEN_HELP BX_TOKEN_SHOW '\n'
1083 dbg_printf("show <command> - toggles show symbolic info (calls to begin with)\n");
1084 dbg_printf("show - shows current show mode\n");
1085 dbg_printf("show mode - show, when processor switch mode\n");
1086 dbg_printf("show int - show, when interrupt is happens\n");
1087 dbg_printf("show call - show, when call is happens\n");
1088 dbg_printf("show off - toggles off symbolic info\n");
1089 dbg_printf("show dbg-all - turn on all show flags\n");
1090 dbg_printf("show dbg-none - turn off all show flags\n");
1091 free($1);free($2);
1093 | BX_TOKEN_HELP BX_TOKEN_CALC '\n'
1095 dbg_printf("calc|? <expr> - calculate a expression and display the result.\n");
1096 dbg_printf(" 'expr' can reference any general-purpose and segment\n");
1097 dbg_printf(" registers, use any arithmetic and logic operations, and\n");
1098 dbg_printf(" also the special ':' operator which computes the linear\n");
1099 dbg_printf(" address for a segment:offset (in real and v86 mode) or\n");
1100 dbg_printf(" of a selector:offset (in protected mode) pair.\n");
1101 free($1);free($2);
1103 | BX_TOKEN_HELP BX_TOKEN_HELP '\n'
1105 bx_dbg_print_help();
1106 free($1);free($2);
1108 | BX_TOKEN_HELP '\n'
1110 bx_dbg_print_help();
1111 free($1);
1115 calc_command:
1116 BX_TOKEN_CALC expression '\n'
1118 bx_dbg_calc_command($2);
1119 free($1);
1123 BX_TOKEN_NONSEG_REG:
1124 BX_TOKEN_8BL_REG
1125 | BX_TOKEN_8BH_REG
1126 | BX_TOKEN_16B_REG
1127 | BX_TOKEN_32B_REG
1128 | BX_TOKEN_64B_REG
1129 { $$=$1; }
1132 /* Arithmetic expression for vbreak command */
1133 vexpression:
1134 BX_TOKEN_NUMERIC { $$ = $1; }
1135 | BX_TOKEN_8BL_REG { $$ = bx_dbg_get_reg8l_value($1); }
1136 | BX_TOKEN_8BH_REG { $$ = bx_dbg_get_reg8h_value($1); }
1137 | BX_TOKEN_16B_REG { $$ = bx_dbg_get_reg16_value($1); }
1138 | BX_TOKEN_32B_REG { $$ = bx_dbg_get_reg32_value($1); }
1139 | BX_TOKEN_64B_REG { $$ = bx_dbg_get_reg64_value($1); }
1140 | BX_TOKEN_SEGREG { $$ = bx_dbg_get_selector_value($1); }
1141 | BX_TOKEN_REG_IP { $$ = bx_dbg_get_ip (); }
1142 | BX_TOKEN_REG_EIP { $$ = bx_dbg_get_eip(); }
1143 | BX_TOKEN_REG_RIP { $$ = bx_dbg_get_instruction_pointer(); }
1144 | vexpression '+' vexpression { $$ = $1 + $3; }
1145 | vexpression '-' vexpression { $$ = $1 - $3; }
1146 | vexpression '*' vexpression { $$ = $1 * $3; }
1147 | vexpression '/' vexpression { $$ = $1 / $3; }
1148 | vexpression BX_TOKEN_RSHIFT vexpression { $$ = $1 >> $3; }
1149 | vexpression BX_TOKEN_LSHIFT vexpression { $$ = $1 << $3; }
1150 | vexpression '|' vexpression { $$ = $1 | $3; }
1151 | vexpression '^' vexpression { $$ = $1 ^ $3; }
1152 | vexpression '&' vexpression { $$ = $1 & $3; }
1153 | '!' vexpression %prec NOT { $$ = !$2; }
1154 | '-' vexpression %prec NEG { $$ = -$2; }
1155 | '(' vexpression ')' { $$ = $2; }
1158 /* Same as vexpression but includes the ':' operator - used in most commands */
1159 expression:
1160 BX_TOKEN_NUMERIC { $$ = $1; }
1161 | BX_TOKEN_STRING { $$ = bx_dbg_get_symbol_value($1); free($1);}
1162 | BX_TOKEN_8BL_REG { $$ = bx_dbg_get_reg8l_value($1); }
1163 | BX_TOKEN_8BH_REG { $$ = bx_dbg_get_reg8h_value($1); }
1164 | BX_TOKEN_16B_REG { $$ = bx_dbg_get_reg16_value($1); }
1165 | BX_TOKEN_32B_REG { $$ = bx_dbg_get_reg32_value($1); }
1166 | BX_TOKEN_64B_REG { $$ = bx_dbg_get_reg64_value($1); }
1167 | BX_TOKEN_SEGREG { $$ = bx_dbg_get_selector_value($1); }
1168 | BX_TOKEN_REG_IP { $$ = bx_dbg_get_ip (); }
1169 | BX_TOKEN_REG_EIP { $$ = bx_dbg_get_eip(); }
1170 | BX_TOKEN_REG_RIP { $$ = bx_dbg_get_instruction_pointer(); }
1171 | expression ':' expression { $$ = bx_dbg_get_laddr ($1, $3); }
1172 | expression '+' expression { $$ = $1 + $3; }
1173 | expression '-' expression { $$ = $1 - $3; }
1174 | expression '*' expression { $$ = $1 * $3; }
1175 | expression '/' expression { $$ = ($3 != 0) ? $1 / $3 : 0; }
1176 | expression BX_TOKEN_RSHIFT expression { $$ = $1 >> $3; }
1177 | expression BX_TOKEN_LSHIFT expression { $$ = $1 << $3; }
1178 | expression '|' expression { $$ = $1 | $3; }
1179 | expression '^' expression { $$ = $1 ^ $3; }
1180 | expression '&' expression { $$ = $1 & $3; }
1181 | '!' expression %prec NOT { $$ = !$2; }
1182 | '-' expression %prec NEG { $$ = -$2; }
1183 | '(' expression ')' { $$ = $2; }