3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 // Debugger Command Table
20 EFI_DEBUGGER_COMMAND_SET mDebuggerCommandSet
[] = {
26 L
"G/[F5] - continue to run the program\n",
27 L
"The go command is used to cause the debugger to not interrupt execution of the EBC image. The debugger will only break execution of the interpreter if an exception is encountered (including an EBC breakpoint).\n\n",
28 L
"G [til <Address|Symbol>]\n"
29 L
" (No Argument) - It means continue run the program.\n"
30 L
" til - It means continuing run the program till IP is the Address.\n"
31 L
" <Address> - The hexical address user want to break at.\n"
32 L
" <Symbol> - The symbol name for target address user want to break at. It has following format [MapFileName:]SymbolName\n",
39 L
"T/[F8] - step into\n",
40 L
"The step into command will cause the EBC debugger to step a single instruction. If the instruction is a call to internal code (CALL), then the debugger will break at the new function CALL.\n\n",
49 L
"P/[F10] - step over\n",
50 L
"The step over command will cause the EBC debugger to step a single instruction. If the instruction is a call to internal code (CALL), then the external call will be made and the debugger will break at the instruction following the CALL.\n\n",
54 {SCAN_F10
, CHAR_NULL
},
59 L
"O/[F11] - step out\n",
60 L
"The step out command causes the EBC debugger to step out function calls. The function will be executed, but the debugger will stop after the called function returns.\n\n",
64 {SCAN_F11
, CHAR_NULL
},
69 L
"Q - reset the debugger to default value and go\n",
70 L
"The quit command will reset the debugger to default value and go.\n\n",
74 {SCAN_NULL
, CHAR_NULL
},
82 L
"BO[C|CX|R|E|T|K] - break on CALL/CALLEX/RET/Entrypoint/Native Thunk/Key\n",
83 L
"Enabling break-on-call will cause the debugger to halt execution and display the debugger prompt prior to executing any EBC CALL (to EBC) instructions.\n\n",
85 L
" (No Argument) - show current state\n"
86 L
" on - enable break-on-call\n"
87 L
" off - disable break-on-call\n",
89 {SCAN_NULL
, CHAR_NULL
},
95 L
"Enabling break-on-callex will cause the debugger to halt execution and display the debugger prompt prior to executing EBC CALLEX (thunk out) instructions.\n\n",
97 L
" (No Argument) - show current state\n"
98 L
" on - enable break-on-callex\n"
99 L
" off - disable break-on-callex\n",
101 {SCAN_NULL
, CHAR_NULL
},
102 DebuggerBreakOnCALLEX
107 L
"Enabling break-on-return will cause the debugger to halt execution and display the debugger prompt prior to executing EBC RET instructions.\n\n",
109 L
" (No Argument) - show current state\n"
110 L
" on - enable break-on-return\n"
111 L
" off - disable break-on-return\n",
113 {SCAN_NULL
, CHAR_NULL
},
119 L
"Enabling break-on-entrypoint will cause the debugger to halt execution and display the debugger prompt prior to start a driver entry point. (Default is on)\n\n",
121 L
" (No Argument) - show current state\n"
122 L
" on - enable break-on-entrypoint\n"
123 L
" off - disable break-on-entrypoint\n",
125 {SCAN_NULL
, CHAR_NULL
},
126 DebuggerBreakOnEntrypoint
131 L
"Enabling break-on-thunk will cause the debugger to halt execution and display the debugger prompt prior to start native call EBC thunk. (Default is on)\n\n",
133 L
" (No Argument) - show current state\n"
134 L
" on - enable break-on-thunk\n"
135 L
" off - disable break-on-thunk\n",
137 {SCAN_NULL
, CHAR_NULL
},
143 L
"Enabling break-on-key will cause the debugger to halt execution and display the debugger prompt after press any key.\n\n",
145 L
" (No Argument) - show current state\n"
146 L
" on - enable break-on-key\n"
147 L
" off - disable break-on-key\n",
149 {SCAN_NULL
, CHAR_NULL
},
154 L
"B[L|P|C|D|E] - breakpoint list/set/clear/disable/enable\n",
155 L
"List Breakpoint\n\n",
157 L
" (No Argument) - show the state for current breakpoint\n",
159 {SCAN_NULL
, CHAR_NULL
},
160 DebuggerBreakpointList
165 L
"Set Breakpoint\n\n",
166 L
"BP <Address|Symbol>\n"
167 L
" <Address> - Hexical breakpoint address\n"
168 L
" <Symbol> - Symbol name for breakpoint address. It has following format [MapFileName:]SymbolName.\n",
170 {SCAN_NULL
, CHAR_NULL
},
171 DebuggerBreakpointSet
176 L
"Clear Breakpoint\n\n",
178 L
" <Index> - Decimal breakpoint index, which can be got from BL command\n"
179 L
" * - For all the breakpoint\n",
181 {SCAN_NULL
, CHAR_NULL
},
182 DebuggerBreakpointClear
187 L
"Disable Breakpoint\n\n",
189 L
" <Index> - Decimal breakpoint index, which can be got from BL command\n"
190 L
" * - For all the breakpoint\n",
192 {SCAN_NULL
, CHAR_NULL
},
193 DebuggerBreakpointDisable
198 L
"Enable Breakpoint\n\n",
200 L
" <Index> - Decimal breakpoint index, which can be got from BL command\n"
201 L
" * - For all the breakpoint\n",
203 {SCAN_NULL
, CHAR_NULL
},
204 DebuggerBreakpointEnable
211 L
"K - show/clear call-stack\n",
212 L
"The call-stack command will show or clear the current call-stack.\n\n",
213 L
"K [p [<ParameterNum>]|c]\n"
214 L
" (No Argument) - Show current call-stack\n"
215 L
" p - Show current call-stack with parameters\n"
216 L
" ParameterNum - Decimal call-stack parameters number, 8 by default, 16 as max\n"
217 L
" c - Clear current call-stack\n",
219 {SCAN_NULL
, CHAR_NULL
},
224 L
"TRACE - show/clear trace instruction branch\n",
225 L
"The trace command will show or clear the latest instruction branch.\n\n",
227 L
" (No Argument) - Show current instrcution branch\n"
228 L
" c - Clear current instruction branch\n",
230 {SCAN_NULL
, CHAR_NULL
},
231 DebuggerInstructionBranch
235 L
"R/[F2] - display/modify register\n",
236 L
"The register command is used to display or modify the contents of EBC VM registers. (R0~R7, Flags, IP)\n\n",
237 L
"R [<Register> <Value>]\n"
238 L
" (No Argument) - Display all registers\n"
239 L
" <Register> - EBC VM register name (R0~R7, Flags, ControlFlags, and IP\n"
240 L
" <Value> - The Hexical value of register\n",
242 {SCAN_F2
, CHAR_NULL
},
247 L
"L/[F4] - show/load instruction assembly count\n",
248 L
"The list assembly command will disassemble instructions starting with the current EBC VM instruction pointer. (by default 5 instructions)\n\n",
250 L
" (No Argument) - List current assembly code\n"
251 L
" Count - The decimal instruction assembly count\n",
253 {SCAN_F4
, CHAR_NULL
},
258 L
"SCOPE - load scope address\n",
259 L
"The scope command will disassemble instructions starting with the Scope. (by default current EBC VM IP)\n\n",
260 L
"SCOPE <Address|Symbol>\n"
261 L
" <Address> - The Hexical address where user wants to see the assembly code\n"
262 L
" <Symbol> - Symbol name for scope address. It has following format [MapFileName:]SymbolName.\n",
264 {SCAN_NULL
, CHAR_NULL
},
269 L
"[D|E][B|W|D|Q] - display/modify memory\n",
270 L
"Display BYTES Memory\n\n",
271 L
"DB <Address|Symbol> [<Count>]\n"
272 L
" <Address> - The hexical memory address\n"
273 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
274 L
" <Count> - The hexical memory count (not set means 1)\n",
276 {SCAN_NULL
, CHAR_NULL
},
282 L
"Display WORDS Memory\n\n",
283 L
"DW <Address|Symbol> [<Count>]\n"
284 L
" <Address> - The hexical memory address\n"
285 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
286 L
" <Count> - The hexical memory count (not set means 1)\n",
288 {SCAN_NULL
, CHAR_NULL
},
294 L
"Display DWORDS Memory\n\n",
295 L
"DD <Address|Symbol> [<Count>]\n"
296 L
" <Address> - The hexical memory address\n"
297 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
298 L
" <Count> - The hexical memory count (not set means 1)\n",
300 {SCAN_NULL
, CHAR_NULL
},
306 L
"Display QWORDS Memory\n\n",
307 L
"DQ <Address|Symbol> [<Count>]\n"
308 L
" <Address> - The hexical memory address\n"
309 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
310 L
" <Count> - The hexical memory count (not set means 1)\n",
312 {SCAN_NULL
, CHAR_NULL
},
318 L
"Enter BYTES Memory\n\n",
319 L
"EB <Address|Symbol> <Value>\n"
320 L
" <Address> - The hexical memory address\n"
321 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
322 L
" <Value> - The hexical memory value\n",
324 {SCAN_NULL
, CHAR_NULL
},
330 L
"Enter WORDS Memory\n\n",
331 L
"EW <Address|Symbol> <Value>\n"
332 L
" <Address> - The hexical memory address\n"
333 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
334 L
" <Value> - The hexical memory value\n",
336 {SCAN_NULL
, CHAR_NULL
},
342 L
"Enter DWORDS Memory\n\n",
343 L
"ED <Address|Symbol> <Value>\n"
344 L
" <Address> - The hexical memory address\n"
345 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
346 L
" <Value> - The hexical memory value\n",
348 {SCAN_NULL
, CHAR_NULL
},
354 L
"Enter QWORDS Memory\n\n",
355 L
"EQ <Address|Symbol> <Value>\n"
356 L
" <Address> - The hexical memory address\n"
357 L
" <Symbol> - Symbol name for memory address. It has following format [MapFileName:]SymbolName.\n"
358 L
" <Value> - The hexical memory value\n",
360 {SCAN_NULL
, CHAR_NULL
},
368 L
"LN - list the symbol\n",
369 L
"The show symbol command will list all the current symbol. It can list the symbol in one symbol file, or list the same symbol in all the files. It can also list the symbol according to nearest address.\n\n",
370 L
"LN [[F <SymbolFile>] [S <Symbol>]] | <Address>\n"
371 L
" (No Argument) - List all the symbol\n"
372 L
" F <SymbolFile> - List the symbol in this symbol file only\n"
373 L
" S <Symbol> - List this symbol only\n"
374 L
" <Address> - The hexical memory address, which user want to find the symbol for.\n",
376 {SCAN_NULL
, CHAR_NULL
},
381 L
"[UN]LOADSYMBOL - load/unload the symbol file\n",
382 L
"The load symbol command will load the ebc map file. Then it parses the function name and global variable, and the print real name when do the disassembly. (Symbol file name should be XXX.MAP)\n\n",
383 L
"LOADSYMBOL <SymbolFile> [a]\n"
384 L
" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n"
385 L
" a - Automatically load code files in the same dir\n",
387 {SCAN_NULL
, CHAR_NULL
},
393 L
"The unload symbol command will unload the ebc map and cod file. After that the name will not be print.\n\n",
394 L
"UNLOADSYMBOL <SymbolFile>\n"
395 L
" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n",
397 {SCAN_NULL
, CHAR_NULL
},
402 L
"[UN]LOADCODE - load/unload the code file\n",
403 L
"The load code command will load the ebc cod file. Then it parses the cod file, and the print source code when do the disassembly. (Code file name should be XXX.COD)\n\n",
404 L
"LOADCODE <CodeFile> <SymbolFile>\n"
405 L
" CodeFile - The EBC code file (Its name should be XXX.COD)\n"
406 L
" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n",
408 {SCAN_NULL
, CHAR_NULL
},
414 L
"The unload code command will unload the ebc cod file. After that the source code will not be print.\n\n",
415 L
"UNLOADCODE <CodeFile> <SymbolFile>\n"
416 L
" CodeFile - The EBC code file (Its name should be XXX.COD)\n"
417 L
" SymbolFile - The EBC symbol file (Its name should be XXX.MAP)\n",
419 {SCAN_NULL
, CHAR_NULL
},
424 L
"DISPLAYSYMBOL/[F3] - disable/enable the symbol output\n",
426 L
"The display symbol command will configure the symbol show or not-show when disassembly.\n\n"
427 L
"DISPLAYSYMBOL [on|off]\n"
428 L
" (No Argument) - swtich symbol output state to another one\n"
429 L
" on - enable symbol output\n"
430 L
" off - disable symbol output\n",
432 {SCAN_F3
, CHAR_NULL
},
433 DebuggerDisplaySymbol
437 L
"DISPLAYCODE/[F6] - disable/enable the source code only output\n",
439 L
"The display code command will configure the source code only show or misc source code with assembly.\n\n"
440 L
"DISPLAYCODE [on|off]\n"
441 L
" (No Argument) - swtich source only output state to another one\n"
442 L
" on - enable source only output\n"
443 L
" off - disable source only output\n",
445 {SCAN_F6
, CHAR_NULL
},
454 L
"The help command will print help information for each command\n\n",
457 {SCAN_F1
, CHAR_NULL
},
466 L"![I|O][B|W|D] - display/modify IO\n",
470 {SCAN_NULL, CHAR_NULL},
479 {SCAN_NULL, CHAR_NULL},
488 {SCAN_NULL, CHAR_NULL},
495 L"!OB <Address> <Value>\n",
497 {SCAN_NULL, CHAR_NULL},
504 L"!OW <Address> <Value>\n",
506 {SCAN_NULL, CHAR_NULL},
513 L"!OD <Address> <Value>\n",
515 {SCAN_NULL, CHAR_NULL},
520 L"!PCIL - list PCI device, with BAR\n",
524 {SCAN_NULL, CHAR_NULL},
529 L"!PCID - show PCI space\n",
531 L"!PCID Bus Device Function [H|B|E]\n",
533 {SCAN_NULL, CHAR_NULL},
538 L"!CFG[B|W|D] - show/modify PCI space",
540 L"!CFGB <Address> [<Value>]\n",
542 {SCAN_NULL, CHAR_NULL},
549 L"!CFGW <Address> [<Value>]\n",
551 {SCAN_NULL, CHAR_NULL},
558 L"!CFGD <Address> [<Value>]\n",
560 {SCAN_NULL, CHAR_NULL},
570 {SCAN_NULL
, CHAR_NULL
},
577 Find the command according to name.
579 @param CommandName - Command Name
580 @param CommandArg - Command Argument
582 @return Not NULL - The DebuggerCommand is found successfully
583 @return NULL - not found
587 MatchDebuggerCommand (
588 IN CHAR16
*CommandName
,
589 IN CHAR16
**CommandArg
598 Temp
= StrGetNewTokenLine (CommandName
, L
" ");
601 // Get Command Argument
603 Temp
= StrGetNextTokenLine (L
" ");
606 if (CommandName
== NULL
) {
611 // Go through each command, check the CommandName
613 for (Index
= 0; mDebuggerCommandSet
[Index
].CommandName
!= NULL
; Index
++) {
614 if (StriCmp (CommandName
, mDebuggerCommandSet
[Index
].CommandName
) == 0) {
618 return mDebuggerCommandSet
[Index
].CommandFunc
;
630 Find the command name according to the function key.
632 @param CommandKey - Command Function Key
634 @return Not NULL - The DebuggerName is found successfully
635 @return NULL - not found
639 GetCommandNameByKey (
640 IN EFI_INPUT_KEY CommandKey
646 // Go through each command, check the CommandKey
648 for (Index
= 0; mDebuggerCommandSet
[Index
].CommandName
!= NULL
; Index
++) {
649 if ((mDebuggerCommandSet
[Index
].CommandKey
.UnicodeChar
== CommandKey
.UnicodeChar
) &&
650 (mDebuggerCommandSet
[Index
].CommandKey
.ScanCode
== CommandKey
.ScanCode
)) {
654 return mDebuggerCommandSet
[Index
].CommandName
;