⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdb.texinfo

📁 早期freebsd实现
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
If the modification time of your symbol file has changed since thelast time _GDBN__ read its symbols, _GDBN__ will discard its symbol table andre-read it.  When it does this, _GDBN__ tries to retain your currentbreakpoints._if__(!_BARE__)@node Arguments@section Your Program's Arguments@cindex arguments (to your program)The arguments to your program can be specified by the arguments of the@code{run} command.  They are passed to a shell, which expands wildcardcharacters and performs redirection of I/O, and thence to your program._GDBN__ uses the shell indicated by your environment variable@code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}.@code{run} with no arguments uses the same arguments used by the previous@code{run}, or those set by the @code{set args} command.@kindex set args@table @code@item set argsSpecify the arguments to be used the next time your program is run.  If@code{set args} has no arguments, @code{run} will execute your programwith no arguments.  Once you have run your program with arguments,using @code{set args} before the next @code{run} is the only way to runit again without arguments.@item show args@kindex show argsShow the arguments to give your program when it is started.@end table@node Environment@section Your Program's Environment@cindex environment (of your program)The @dfn{environment} consists of a set of environment variables andtheir values.  Environment variables conventionally record such things asyour user name, your home directory, your terminal type, and your searchpath for programs to run.  Usually you set up environment variables withthe shell and they are inherited by all the other programs you run.  Whendebugging, it can be useful to try running your program with a modifiedenvironment without having to start _GDBN__ over again.@table @code@item path @var{directory}@kindex pathAdd @var{directory} to the front of the @code{PATH} environment variable(the search path for executables), for both _GDBN__ and your program.You may specify several directory names, separated by @samp{:} orwhitespace.  If @var{directory} is already in the path, it is moved tothe front, so it will be searched sooner.You can use the string @samp{$cwd} to refer to whatever is the currentworking directory at the time _GDBN__ searches the path.  If you use@samp{.} instead, it refers to the directory where you executed the@code{path} command.  _GDBN__ fills in the current path where needed inthe @var{directory} argument, before adding it to the search path.@c 'path' is explicitly nonrepeatable, but RMS points out it is silly to@c document that, since repeating it would be a no-op.@item show paths@kindex show pathsDisplay the list of search paths for executables (the @code{PATH}environment variable).@item show environment @r{[}@var{varname}@r{]}@kindex show environmentPrint the value of environment variable @var{varname} to be given toyour program when it starts.  If you do not supply @var{varname},print the names and values of all environment variables to be given toyour program.  You can abbreviate @code{environment} as @code{env}.@item set environment @var{varname} @r{[}=@r{]} @var{value}@kindex set environmentSets environment variable @var{varname} to @var{value}.  The valuechanges for your program only, not for _GDBN__ itself.  @var{value} maybe any string; the values of environment variables are just strings, andany interpretation is supplied by your program itself.  The @var{value}parameter is optional; if it is eliminated, the variable is set to anull value.@c "any string" here does not include leading, trailing@c blanks. Gnu asks: does anyone care?For example, this command:@exampleset env USER = foo@end example@noindenttells a Unix program, when subsequently run, that its user is named@samp{foo}.  (The spaces around @samp{=} are used for clarity here; theyare not actually required.)@item unset environment @var{varname}@kindex unset environmentRemove variable @var{varname} from the environment to be passed to yourprogram.  This is different from @samp{set env @var{varname} =};@code{unset environment} removes the variable from the environment,rather than assigning it an empty value.@end table@node Working Directory@section Your Program's Working Directory@cindex working directory (of your program)Each time you start your program with @code{run}, it inherits itsworking directory from the current working directory of _GDBN__.  _GDBN__'sworking directory is initially whatever it inherited from its parentprocess (typically the shell), but you can specify a new workingdirectory in _GDBN__ with the @code{cd} command.The _GDBN__ working directory also serves as a default for the commandsthat specify files for _GDBN__ to operate on.  @xref{Files, ,Commands toSpecify Files}.@table @code@item cd @var{directory}@kindex cdSet _GDBN__'s working directory to @var{directory}.@item pwd@kindex pwdPrint _GDBN__'s working directory.@end table@node Input/Output@section Your Program's Input and Output@cindex redirection@cindex i/o@cindex terminalBy default, the program you run under _GDBN__ does input and output tothe same terminal that _GDBN__ uses.  _GDBN__ switches the terminal toits own terminal modes to interact with you, but it records the terminalmodes your program was using and switches back to them when you continuerunning your program.@table @code@item info terminal@kindex info terminalDisplays _GDBN__'s recorded information about the terminal modes yourprogram is using.@end tableYou can redirect your program's input and/or output using shellredirection with the @code{run} command.  For example,_0__@examplerun > outfile_1__@end example@noindentstarts your program, diverting its output to the file @file{outfile}.@kindex tty@cindex controlling terminalAnother way to specify where your program should do input and output iswith the @code{tty} command.  This command accepts a file name asargument, and causes this file to be the default for future @code{run}commands.  It also resets the controlling terminal for the childprocess, for future @code{run} commands.  For example,@exampletty /dev/ttyb@end example@noindentdirects that processes started with subsequent @code{run} commandsdefault to do input and output on the terminal @file{/dev/ttyb} and havethat as their controlling terminal.An explicit redirection in @code{run} overrides the @code{tty} command'seffect on the input/output device, but not its effect on the controllingterminal.When you use the @code{tty} command or redirect input in the @code{run}command, only the input @emph{for your program} is affected.  The inputfor _GDBN__ still comes from your terminal.@node Attach@section Debugging an Already-Running Process@kindex attach@cindex attach@table @code@item attach @var{process-id}This commandattaches to a running process---one that was started outside _GDBN__.(@code{info files} will show your active targets.)  The command takes asargument a process ID.  The usual way to find out the process-id ofa Unix process is with the @code{ps} utility, or with the @samp{jobs -l}shell command.@code{attach} will not repeat if you press @key{RET} a second time afterexecuting the command.@end tableTo use @code{attach}, you must be debugging in an environment whichsupports processes.  You must also have permission to send the process asignal, and it must have the same effective user ID as the _GDBN__process.When using @code{attach}, you should first use the @code{file} commandto specify the program running in the process and load its symbol table.@xref{Files, ,Commands to Specify Files}.The first thing _GDBN__ does after arranging to debug the specifiedprocess is to stop it.  You can examine and modify an attached processwith all the _GDBN__ commands that are ordinarily available when you startprocesses with @code{run}.  You can insert breakpoints; you can step andcontinue; you can modify storage.  If you would rather the processcontinue running, you may use the @code{continue} command afterattaching _GDBN__ to the process.@table @code@item detach@kindex detachWhen you have finished debugging the attached process, you can use the@code{detach} command to release it from _GDBN__'s control.  Detachingthe process continues its execution.  After the @code{detach} command,that process and _GDBN__ become completely independent once more, and youare ready to @code{attach} another process or start one with @code{run}.@code{detach} will not repeat if you press @key{RET} again afterexecuting the command.@end tableIf you exit _GDBN__ or use the @code{run} command while you have an attachedprocess, you kill that process.  By default, you will be asked forconfirmation if you try to do either of these things; you can controlwhether or not you need to confirm by using the @code{set confirm} command(@pxref{Messages/Warnings, ,Optional Warnings and Messages}).@node Kill Process@c @group@section Killing the Child Process@table @code@item kill@kindex killKill the child process in which your program is running under _GDBN__.@end tableThis command is useful if you wish to debug a core dump instead of arunning process.  _GDBN__ ignores any core dump file while your programis running.@c @end groupOn some operating systems, a program cannot be executed outside _GDBN__while you have breakpoints set on it inside _GDBN__.  You can use the@code{kill} command in this situation to permit running your programoutside the debugger.The @code{kill} command is also useful if you wish to recompile andrelink your program, since on many systems it is impossible to modify anexecutable file while it is running in a process.  In this case, when younext type @code{run}, _GDBN__ will notice that the file has changed, andwill re-read the symbol table (while trying to preserve your currentbreakpoint settings).@node Process Information@section Additional Process Information@kindex /proc@cindex process imageSome operating systems provide a facility called @samp{/proc} that canbe used to examine the image of a running process using file-systemsubroutines.  If _GDBN__ is configured for an operating system with thisfacility, the command @code{info proc} is available to report on severalkinds of information about the process running your program.@table @code@item info proc@kindex info procSummarize available information about the process.@item info proc mappings@kindex info proc mappingsReport on the address ranges accessible in the program, with informationon whether your program may read, write, or execute each range.@item info proc times@kindex info proc timesStarting time, user CPU time, and system CPU time for your program andits children.@item info proc id@kindex info proc idReport on the process ID's related to your program: its own process id,the id of its parent, the process group id, and the session id.@item info proc status@kindex info proc statusGeneral information on the state of the process.  If the process isstopped, this report includes the reason for stopping, and any signalreceived.@item info proc allShow all the above information about the process.@end table_fi__(!_BARE__)@node Stopping@chapter Stopping and ContinuingThe principal purpose of using a debugger is so that you can stop yourprogram before it terminates; or so that, if your program runs intotrouble, you can investigate and find out why.Inside _GDBN__, your program may stop for any of several reasons, suchas a signal, a breakpoint, or reaching a new line after a _GDBN__command such as @code{step}.  You may then examine and changevariables, set new breakpoints or remove old ones, and then continueexecution.  Usually, the messages shown by _GDBN__ provide ampleexplanation of the status of your program---but you can also explicitlyrequest this information at any time.@table @code@item info program@kindex info programDisplay information about the status of your program: whether it isrunning or not, what process it is, and why it stopped.@end table@menu_if__(!_CONLY__)* Breakpoints::                 Breakpoints, Watchpoints, and Exceptions_fi__(!_CONLY__)_if__(_CONLY__)* Breakpoints::                 Breakpoints and Watchpoints_fi__(_CONLY__)* Continuing and Stepping::     Resuming Execution_if__(_GENERIC__ || !_H8__)* Signals::                     Signals_fi__(_GENERIC__ || !_H8__)@end menu@node Breakpoints_if__(!_CONLY__)@section Breakpoints, Watchpoints, and Exceptions_fi__(!_CONLY__)_if__(_CONLY__)@section Breakpoints and Watchpoints_fi__(_CONLY__)@cindex breakpointsA @dfn{breakpoint} makes your program stop whenever a certain point inthe program is reached.  For each breakpoint, you can add variousconditions to control in finer detail whether your program will stop.You can set breakpoints with the @code{break} command and its variants(@pxref{Set Breaks, ,Setting Breakpoints}), to specify the place whereyour program should stop by line number, function name or exact addressin the program.  _if__(!_CONLY__)In languages with exception handling (such as GNU C++), you can al

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -