Command line windows debug

DEBUG – запустить стандартный отдачик MS DOS — Windows XP.

Debug.exe — программа-отладчик, разработанная для операционной системы MS DOS и используемая для отладки исполняемых файлов. Под более поздние версии операционных систем (Windows NT и старше) работает через эмулятор MS-DOS и имеет ограниченные возможности. До Windows XP включительно, отладчик debug.exe являлся стандартным компонентом системы.

Формат командной строки:

DEBUG [[диск:][путь]имя_файла [параметры_программы]]

Параметры командной строки:

[диск:][путь]имя_файла — путь и имя отлаживаемой программы.

параметры_программы — параметры командной строки для отлаживаемой программы.

debug /? — отобразить краткую справку по использованию.

debug C:\windows\system32\edit.com C:\boot.ini — запустить отладку текстового редактора edit.com , передав ему в качестве параметра командной строки путь и имя редактируемого файла.

debug — при запуске без параметров, отладчик переходит в интерактивный режим, ожидая ввода команд. Подсказку по используемым командам можно получить, введя знак вопроса — ? :

Краткая подсказка по использованию отладчика Debug:

assemble A [адрес]
compare C диапазон адрес
dump D [диапазон]
enter E адрес [список]
fill F диапазон список
go G [=адрес] [адреса]
hex H значение1 значение2
input I порт
load L [адрес] [диск] [превый_сектор] [число]
move M диапазон адрес
name N [путь] [список_аргументов]
output O порт байт
proceed P [=адрес] [число]
quit Q
register R [регистр]
search S диапазон список
trace T [=адрес] [значение]
unassemble U [диапазон]
write W [адрес] [диск] [первый_сектор] [число]
выделение памяти EMS XA [#число_страниц]
освобождение памяти EMS XD [дескриптор]
сопоставление страниц EMS XM [Lстраница] [Pстраница] [дескриптор]
вывод состояния памяти EMS XS

При небольших размерах исполняемого файла, отладчик обладал очень неплохими возможностями, позволяя не только выполнять отладку программ, но и просматривать содержимое памяти, в том числе BIOS материнской платы и плат расширения, выполнять операции ввода-вывода с доступом к регистрам устройств ( в среде MS DOS ), и например, позволял легко сохранить в файл и дизасемблировать главную загрузочную запись MBR.

Для выхода из отладчика используется клавиша q .

Debug Commands

Debug Commands can be used in the Command Window and in debug functions. You must use the CAPITAL letters of a command. For example, BreakAccess must be entered as BA or ba.

Debug commands can be built using:

Breakpoint Commands

Use breakpoint commands to halt program execution, to stop commands, or interrupt user functions.

Command Description
BreakAccess Add an access breakpoint with a length parameter to the breakpoint list.
BreakDisable Disable one or more breakpoints.
BreakEnable Enable one or more breakpoints.
BreakKill Remove one or more breakpoints from the breakpoint list.
BreakList List all breakpoints.
BreakSet Add a breakpoint expression to the list of breakpoints.
SBC (only Cortex-M) Define SW breakpoint configuration for a memory block.

General Commands

General commands perform a number of miscellaneous debugging operations.

Command Description
ASSIGN Assign input and output sources for the Serial window.
DEFINE Create a Toolbox button.
DIR Generate a directory of symbol names.
EventRecorder Protocol events to a file or save/restore event filter settings.
EXIT Exit debug mode.
FUNC Create C-like functions for debugging.
INCLUDE Read and execute commands in a command file.
ITMLOG Create a log file for writing ITM channel output of Cortex-M devices. Each ITM channel has its own log file.
IRLOG Create a log file for writing printf-data of ITM channel 0 of Cortex-M devices to one common file. Create a log file for RTA channel output of Arm7 or Arm9 devices.
KILL Delete user- or signal functions and Toolbox buttons.
LOAD Load object modules and HEX files.
LOG Create log files, querie log status, and close log files for the Debug window.
MODE Set the baud rate, parity, and number of stop bits for PC COM ports.
RESET Reset the CPU, memory map assignments, and predefined variables.
SAVE Save a memory range in an Intel HEX386 file.
SCOPE Display address assignments of modules and functions of a target program.
SET Set the string value for predefined variables.
SIGNAL Display signal function status and remove active signal functions.
SLOG Create log files, querie log status, and close log files for the Serial window.

Memory Commands

Memory commands display and change the content of memory.

Command Description
ASM Assemble in-line code.
DEFINE Define symbols or Toolbar buttons.
DISPLAY Display the content of memory.
ENTER Enter values into a specified memory area.
EVALuate Evaluate an expression and output the results.
MAP Specifie access parameters for memory areas.
Unassemble Disassemble program memory.
WatchSet Add a watch variable to the Watch window.
WatchKill Kill all watch variable in the Watch window.

Program Commands

Program commands execute target programs and analyze their performance.

Command Description
COVERAGE Display code coverage information.
COVTOFILE Save code coverage information quickly without displaying it.
Go Start program execution.
LogicAnalyze Add, delete, or display Logic Analyser variables.
PerformanceAnalyze Add, delete, display, or reset Performance Analyzer ranges.
Pstep Step over instructions but do not step into procedures or functions.
Ostep Step out of the current function.
Tstep Step over instructions and into functions.

Tracepoint Commands

Tracepoint commands define tracepoints for Cortex-M3 and Cortex-M4 processor-based devices.

Remote Debugging Using WinDbg

Remote debugging involves two debuggers running at two different locations. The debugger that performs the debugging is called the debugging server. The second debugger, called the debugging client, controls the debugging session from a remote location. To establish a remote session, you must set up the debugging server first and then activate the debugging client.

The code that is being debugged could be running on the same computer that is running the debugging server, or it could be running on a separate computer. If the debugging server is performing user-mode debugging, then the process that is being debugged can run on the same computer as the debugging server. If the debugging server is performing kernel-mode debugging, then the code being debugged would typically run on a separate target computer.

The following diagram illustrates a remote session where the debugging server, running on a host computer, is performing kernel-mode debugging of code that is running on a separate target computer.

There are several transport protocols you can use for a remote debugging connection: TCP, NPIPE, SPIPE, SSL, and COM Port. Suppose you have chosen to use TCP as the protocol and you have chosen to use WinDbg as both the debugging client and the debugging server. You can use the following procedure to establish a remote kernel-mode debugging session:

On the host computer, open WinDbg and establish a kernel-mode debugging session with a target computer. (See Live Kernel-Mode Debugging Using WinDbg.)

Break in by choosing Break from the Debug menu or by pressing CTRL-Break.

In the Debugger Command Window, enter the following command.

.server tcp:port=5005

Note The port number 5005 is arbitrary. The port number is your choice.

WinDbg will respond with output similar to the following.

On the remote computer, open WinDbg, and choose Connect to Remote Session from the File menu.

Under Connection String, enter the following string.

tcp:Port=5005,Server=YourHostComputer

where YourHostComputer is the name of your host computer, which is running the debugging server.

Select OK.

Using the Command Line

As an alternative to the procedure given in the preceding section, you can set up a remote debugging session at the command line. Suppose you are set up to establish a kernel-mode debugging session, between a host computer and a target computer, over a 1394 cable on channel 32. You can use the following procedure to establish a remote debugging session:

On the host computer, enter the following command in a Command Prompt window.

windbg -server tcp:port=5005 -k 1394:channel=32

On the remote computer, enter the following command in a Command Prompt window.

windbg -remote tcp:Port=5005,Server=YourHostComputer

where YourHostComputer is the name of your host computer, which is running the debugging server.

Additional Information

There are many ways to establish remote debugging other than the ones shown in this topic. For complete information about setting up a debugging server in the WinDbg Debugger Command Window, see .server (Create Debugging Server). For complete information about launching WinDbg (and establishing remote debugging) at the command line, see WinDbg Command-Line Options.

WinDbg Command-Line Options

First-time users of WinDbg should begin with the Debugging Using WinDbg section.

The WinDbg command line uses the following syntax:

Descriptions of the WinDbg command-line options follow. All command-line options are case-sensitive except for -j. The initial hyphen can be replaced with a forward-slash (/).

If the -remote or -server option is used, it must appear before any other options on the command line. If an executable is specified, it must appear last on the command line; any text after the executable name is passed to the executable program as its own command-line parameters.

Parameters

-server ServerTransport
Creates a debugging server that can be accessed by other debuggers. For an explanation of the possible ServerTransport values, see Activating a Debugging Server. When this parameter is used, it must be the first parameters on the command line.

-remote ClientTransport
Creates a debugging client, and connects to a debugging server that is already running. For an explanation of the possible ClientTransport values, see Activating a Debugging Client. When this parameter is used, it must be the first parameters on the command line.

-premote SmartClientTransport
Creates a smart client, and connects to a process server that is already running. For an explanation of the possible SmartClientTransport values, see Activating a Smart Client.

-a Extension
Sets the default extension DLL. The default is kdextx86.dll or kdexts.dll. There must be no space after the «a», and the .dll file name extension must not be included. For details, and other methods of setting this default, see Loading Debugger Extension DLLs.

-b
This option is no longer supported.

-c « command «
Specifies the initial debugger command to run at start-up. This command must be enclosed in quotation marks. Multiple commands can be separated with semicolons. (If you have a long command list, it may be easier to put them in a script and then use the -c option with the $ -clines lines
Sets the approximate number of commands in the command history which can be accessed during remote debugging. For details, and for other ways to change this number, see Using Debugger Commands.

-d
(Kernel mode only) After a reboot, the debugger will break into the target computer as soon as a kernel module is loaded. (This break is earlier than the break from the -b option.) See Crashing and Rebooting the Target Computer for details and for other methods of changing this status.

-ee <masm|c++>
Sets the default expression evaluator. If masm is specified, MASM expression syntax will be used. If c++ is specified, C++ expression syntax will be used. If the -ee option is omitted, MASM expression syntax is used as the default. See Evaluating Expressions for details.

-failinc
Causes the debugger to ignore any questionable symbols. When debugging a user-mode or kernel-mode minidump file, this option will also prevent the debugger from loading any modules whose images can’t be mapped. For details and for other methods of controlling this, see SYMOPT_EXACT_SYMBOLS.

-g
(User mode only) Ignores the initial breakpoint in target application. This option will cause the target application to continue running after it is started or WinDbg attaches to it, unless another breakpoint has been set. See Initial Breakpoint for details.

-G
(User mode only) Ignores the final breakpoint at process termination. Typically, the debugging session ends during the image run-down process. This option will cause the debugging session to end immediately when the child terminates. This has the same effect as entering the command sxd epr. For more information, see Controlling Exceptions and Events.

-hd
(User mode only) Specifies that the debug heap should not be used.

-I[S]
Installs WinDbg as the postmortem debugger. For details, see Enabling Postmortem Debugging.

After this action is attempted, a success or failure message is displayed. If S is included, this procedure is done silently if it is successful; only failure messages are displayed.

The -I parameter must not be used with any other parameters. This command will not actually start WinDbg, although a WinDbg window may appear for a moment.

-IA[S]
Associates WinDbg with the file extensions .dmp, .mdmp, and .wew in the registry. After this action is attempted, a success or failure message is displayed. If S is included, this procedure is done silently if it is successful; only failure messages are displayed. After this association is made, selecting and holding (or right-clicking) a file with one of these extensions will start WinDbg.

The -IA parameter must not be used with any other parameters. This command will not actually start WinDbg, although a WinDbg window may appear for a moment.

-IU KeyString
Registers debugger remoting as an URL type so that users can auto-launch a debugger remote client with an URL. KeyString has the format remdbgeng://RemotingOption . RemotingOption is a string that defines the transport protocol as defined in the topic Activating a Debugging Client. If this action succeeds, no message is displayed; if it fails, an error message is displayed.

The -IU parameter must not be used with any other parameters. Although a WinDbg window may appear for a moment, this command will not actually start WinDbg.

-i ImagePath
Specifies the location of the executables that generated the fault. If the path contains spaces, it should be enclosed in quotation marks.

-j
Allow journaling.

-k [ConnectType]
(Kernel mode only) Starts a kernel debugging session. For details, see Live Kernel-Mode Debugging Using WinDbg. If -k is used without any ConnectType options following it, it must be the final entry on the command line.

-kl
(Kernel mode only) Starts a kernel debugging session on the same machine as the debugger.

-kx ExdiOptions
(Kernel mode only) Starts a kernel debugging session using an EXDI driver. EXDI drivers are not described in this documentation. If you have an EXDI interface to your hardware probe or hardware simulator, please contact Microsoft for debugging information.

-log<o|a> LogFile
Begins logging information to a log file. If the specified log file already exists, it will be overwritten if -logo is used. If loga is used, the output will be appended to the file. For more details, see Keeping a Log File in WinDbg.

-lsrcpath
Sets the local source path for a remote client. This option must follow -remote on the command line.

-n
Noisy symbol load: Enables verbose output from symbol handler. For details and for other methods of controlling this, see SYMOPT_DEBUG.

-noinh
(User mode only) Prevents processes created by the debugger from inheriting handles from the debugger. For other methods of controlling this, see Debugging a User-Mode Process Using WinDbg.

-noprio
Prevents any priority change. This parameter will prevent WinDbg from taking priority for CPU time while active.

-noshell
Prohibits all .shell commands. This prohibition will last as long as the debugger is running, even if a new debugging session is begun. For details, and for other ways to disable shell commands, see Using Shell Commands.

-o
(User mode only) Debugs all processes launched by the target application (child processes). By default, processes created by the one you are debugging will run as they normally do.

-openPrivateDumpByHandle Handle
Specifies the handle of a crash dump file to debug.

-p PID
Specifies the decimal process ID to be debugged. This is used to debug a process that is already running.

-pb
(User mode only) Prevents the debugger from requesting an initial break-in when attaching to a target process. This can be useful if the application is already suspended, or if you wish to avoid creating a break-in thread in the target.

-pd
(User mode only) Causes the target application not to be terminated at the end of the debugging session. See Ending a Debugging Session in WinDbg for details.

-pe
(User mode only) Indicates that the target application is already being debugged. See Re-attaching to the Target Application for details.

-pn Name
Specifies the name of the process to be debugged. (This name must be unique.) This is used to debug a process that is already running.

-pr
(User mode only) Causes the debugger to start the target process running when it attaches to it. This can be useful if the application is already suspended and you wish it to resume execution.

-psn ServiceName
Specifies the name of a service contained in the process to be debugged. This is used to debug a process that is already running.

-pt Seconds
Specifies the break timeout, in seconds. The default is 30. See Controlling the Target for details.

-pv
(User mode only) Specifies that the debugger should attach to the target process noninvasively. For details, see Noninvasive Debugging (User Mode).

-Q
Suppresses the «Save Workspace?» dialog box. Workspaces are not automatically saved. See Using Workspaces for details.

-QS
Suppresses the «Reload Source?» dialog box. Source files are not automatically reloaded.

-QSY
Suppresses the «Reload Source?» dialog box and automatically reloads source files.

-QY
Suppresses the «Save Workspace?» dialog box and automatically saves workspaces. See Using Workspaces for details.

-robp
This allows CDB to set a breakpoint on a read-only memory page. (The default is for such an operation to fail.)

-sdce
Causes the debugger to display File access error messages during symbol load. For details and for other methods of controlling this, see SYMOPT_FAIL_CRITICAL_ERRORS.

-secure
Activates Secure Mode.

-ses
Causes the debugger to perform a strict evaluation of all symbol files and ignore any questionable symbols. For details and for other methods of controlling this, see SYMOPT_EXACT_SYMBOLS.

-sflags 0x Number
Sets all the symbol handler options at once. Number should be a hexadecimal number prefixed with 0x — a decimal without the 0x is permitted, but the symbol options are binary flags and therefore hexadecimal is recommended. This option should be used with care, since it will override all the symbol handler defaults. For details, see Setting Symbol Options.

-sicv
Causes the symbol handler to ignore the CV record. For details and for other methods of controlling this, see SYMOPT_IGNORE_CVREC.

-sins
Causes the debugger to ignore the symbol path and executable image path environment variables. For details, see SYMOPT_IGNORE_NT_SYMPATH.

-snc
Causes the debugger to turn off C++ translation. For details and for other methods of controlling this, see SYMOPT_NO_CPP.

-snul
Disables automatic symbol loading for unqualified names. For details and for other methods of controlling this, see SYMOPT_NO_UNQUALIFIED_LOADS.

-srcpath SourcePath
Specifies the source file search path. Separate multiple paths with a semicolon (;). If the path contains spaces, it should be enclosed in quotation marks. For details, and for other ways to change this path, see Source Path.

-sup
Causes the symbol handler to search the public symbol table during every symbol search. For details and for other methods of controlling this, see SYMOPT_AUTO_PUBLICS.

-T Title
Sets WinDbg window title.

-v
Enables verbose output from debugger.

-W Workspace
Loads the given named workspace. If the workspace name contains spaces, enclose it in quotation marks. If no workspace of this name exists, you will be given the option of creating a new workspace with this name or abandoning the load attempt. For details, see Using Workspaces.

-WF Filename
Loads the workspace from the given file. Filename should include the file and the extension (usually .wew). If the workspace name contains spaces, enclose it in quotation marks. If no workspace file with this name exists, you will be given the option of creating a new workspace file with this name or abandoning the load attempt. For details, see Using Workspaces.

-WX
Disables automatic workspace loading. For details, see Using Workspaces.

-y SymbolPath
Specifies the symbol search path. Separate multiple paths with a semicolon (;). If the path contains spaces, it should be enclosed in quotation marks. For details, and for other ways to change this path, see Symbol Path.

-z DumpFile
Specifies the name of a crash dump file to debug. If the path and file name contain spaces, this must be surrounded by quotation marks. It is possible to open several dump files at once by including multiple -z options, each followed by a different DumpFile value. For details, see Analyzing a User-Mode Dump File or Analyzing a Kernel-Mode Dump File with WinDbg.

-zp PageFile
Specifies the name of a modified page file. This is useful if you are debugging a dump file and want to use the .pagein (Page In Memory) command. You cannot use -zp with a standard Windows page file — only specially-modified page files can be used.

executable
Specifies the command line of an executable process. This is used to launch a new process and debug it. This has to be the final item on the command line. All text after the executable name is passed to the executable as its argument string. For details, see Debugging a User-Mode Process Using WinDbg.

-?
Pops up this HTML Help window.

When you are running the debugger from the command line, specify arguments for the target application after application’s file name. For instance:

Читайте также:  Как установить linux когда установлена xp
Оцените статью