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

📄 gdb.texinfo

📁 早期freebsd实现
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
You can also start with both an executable program and a core filespecified:@example_GDBP__ @var{program} @var{core}@end exampleYou can, instead, specify a process ID as a second argument, if you wantto debug a running process:@example_GDBP__ @var{program} 1234@end example@noindentwould attach _GDBN__ to process @code{1234} (unless you also have a filenamed @file{1234}; _GDBN__ does check for a core file first).Taking advantage of the second command-line argument requires a fairlycomplete operating system; when you use _GDBN__ as a remote debuggerattached to a bare board, there may not be any notion of ``process'',and there is often no way to get a core dump._fi__(!_BARE__)@noindentYou can further control how _GDBN__ starts up by using command-lineoptions.  _GDBN__ itself can remind you of the options available.@noindentType@example_GDBP__ -help@end example@noindentto display all available options and briefly describe their use(@samp{_GDBP__ -h} is a shorter equivalent).All options and command line arguments you give are processedin sequential order.  The order makes a difference when the@samp{-x} option is used.@menu_if__(!_GENERIC__)_include__(gdbinv-m.m4)_dnl___fi__(!_GENERIC__)* File Options::                Choosing Files* Mode Options::                Choosing Modes@end menu_if__(!_GENERIC__)_include__(gdbinv-s.m4)_fi__(!_GENERIC__)@node File Options@subsection Choosing Files_if__(!_BARE__)When _GDBN__ starts, it reads any arguments other than options asspecifying an executable file and core file (or process ID).  This isthe same as if the arguments were specified by the @samp{-se} and@samp{-c} options respectively.  (_GDBN__ reads the first argumentthat does not have an associated option flag as equivalent to the@samp{-se} option followed by that argument; and the second argumentthat does not have an associated option flag, if any, as equivalent tothe @samp{-c} option followed by that argument.)_fi__(!_BARE__)_if__(_BARE__)When _GDBN__ starts, it reads any argument other than options asspecifying an executable file.  This is the same as if the argument wasspecified by the @samp{-se} option._fi__(_BARE__)Many options have both long and short forms; both are shown in thefollowing list.  _GDBN__ also recognizes the long forms if you truncatethem, so long as enough of the option is present to be unambiguous.(If you prefer, you can flag option arguments with @samp{--} ratherthan @samp{-}, though we illustrate the more usual convention.)@table @code@item -symbols=@var{file}@itemx -s @var{file}Read symbol table from file @var{file}.@item -exec=@var{file}@itemx -e @var{file}Use file @var{file} as the executable file to execute whenappropriate, and for examining pure data in conjunction with a coredump.@item -se=@var{file}Read symbol table from file @var{file} and use it as the executablefile._if__(!_BARE__)@item -core=@var{file}@itemx -c @var{file}Use file @var{file} as a core dump to examine._fi__(!_BARE__)@item -command=@var{file}@itemx -x @var{file}Execute _GDBN__ commands from file @var{file}.  @xref{Command Files}.@item -directory=@var{directory}@itemx -d @var{directory}Add @var{directory} to the path to search for source files._if__(!_BARE__)@item -m@itemx -mapped@emph{Warning: this option depends on operating system facilities that are notsupported on all systems.}@*If memory-mapped files are available on your system through the @code{mmap}system call, you can use this option to have _GDBN__ write the symbols from yourprogram into a reusable file in the current directory.  If the program you are debugging iscalled @file{/tmp/fred}, the mapped symbol file will be @file{./fred.syms}.Future _GDBN__ debugging sessions will notice the presence of this file,and will quickly map in symbol information from it, rather than readingthe symbol table from the executable program.The @file{.syms} file is specific to the host machine on which _GDBN__ is run.It holds an exact image of _GDBN__'s internal symbol table.  It cannot beshared across multiple host platforms._fi__(!_BARE__)@item -r@itemx -readnowRead each symbol file's entire symbol table immediately, rather thanthe default, which is to read it incrementally as it is needed.This makes startup slower, but makes future operations faster.@end table_if__(!_BARE__)The @code{-mapped} and @code{-readnow} options are typically combined in order tobuild a @file{.syms} file that contains complete symbol information.A simple GDB invocation to do nothing but build a @file{.syms} file for futureuse is:@example	gdb -batch -nx -mapped -readnow programname@end example_fi__(!_BARE__)@node Mode Options@subsection Choosing ModesYou can run _GDBN__ in various alternative modes---for example, inbatch mode or quiet mode.@table @code@item -nx@itemx -nDo not execute commands from any @file{_GDBINIT__} initialization files.Normally, the commands in these files are executed after all thecommand options and arguments have been processed.@xref{Command Files}.@item -quiet@itemx -q``Quiet''.  Do not print the introductory and copyright messages.  Thesemessages are also suppressed in batch mode.@item -batchRun in batch mode.  Exit with status @code{0} after processing all the commandfiles specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited).Exit with nonzero status if an error occurs in executing the _GDBN__commands in the command files.Batch mode may be useful for running _GDBN__ as a filter, for example todownload and run a program on another computer; in order to make thismore useful, the message@exampleProgram exited normally.@end example@noindent(which is ordinarily issued whenever a program running under _GDBN__ controlterminates) is not issued when running in batch mode.@item -cd=@var{directory}Run _GDBN__ using @var{directory} as its working directory,instead of the current directory._if__(_LUCID__)@item -context @var{authentication}When the Energize programming system starts up _GDBN__, it uses thisoption to trigger an alternate mode of interaction.@var{authentication} is a pair of numeric codes that identify _GDBN__as a client in the Energize environment.  Avoid this option when you run_GDBN__ directly from the command line.  See @ref{Energize,,Using_GDBN__ with Energize} for more discussion of using _GDBN__ with Energize._fi__(_LUCID__)@item -fullname@itemx -fEmacs sets this option when it runs _GDBN__ as a subprocess.  It tells _GDBN__to output the full file name and line number in a standard,recognizable fashion each time a stack frame is displayed (whichincludes each time your program stops).  This recognizable format lookslike two @samp{\032} characters, followed by the file name, line numberand character position separated by colons, and a newline.  TheEmacs-to-_GDBN__ interface program uses the two @samp{\032} characters asa signal to display the source code for the frame._if__(_GENERIC__ || !_H8__)@item -b @var{bps}Set the line speed (baud rate or bits per second) of any serialinterface used by _GDBN__ for remote debugging.@item -tty=@var{device}Run using @var{device} for your program's standard input and output.@c FIXME: kingdon thinks there is more to -tty.  Investigate._fi__(_GENERIC__ || !_H8__)@end table@node Leaving _GDBN__@section Leaving _GDBN__@cindex exiting _GDBN__@table @code@item quit@kindex quit@kindex qTo exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or typean end-of-file character (usually @kbd{C-d}).@end table@cindex interruptAn interrupt (often @kbd{C-c}) will not exit from _GDBN__, but ratherwill terminate the action of any _GDBN__ command that is in progress andreturn to _GDBN__ command level.  It is safe to type the interruptcharacter at any time because _GDBN__ does not allow it to take effectuntil a time when it is safe._if__(!_BARE__)If you have been using _GDBN__ to control an attached process or device, youcan release it with the @code{detach} command; @pxref{Attach,,Debugging an Already-Running Process}.._fi__(!_BARE__)_if__(!_BARE__)@node Shell Commands@section Shell CommandsIf you need to execute occasional shell commands during yourdebugging session, there is no need to leave or suspend _GDBN__; you canjust use the @code{shell} command.@table @code@item shell @var{command string}@kindex shell@cindex shell escapeDirects _GDBN__ to invoke an inferior shell to execute @var{commandstring}.  If it exists, the environment variable @code{SHELL} is usedfor the name of the shell to run.  Otherwise _GDBN__ uses@code{/bin/sh}.@end tableThe utility @code{make} is often needed in development environments.You do not have to use the @code{shell} command for this purpose in _GDBN__:@table @code@item make @var{make-args}@kindex make@cindex calling makeCauses _GDBN__ to execute an inferior @code{make} program with the specifiedarguments.  This is equivalent to @samp{shell make @var{make-args}}.@end table_fi__(!_BARE__)@node Commands@chapter _GDBN__ CommandsYou can abbreviate a _GDBN__ command to the first few letters of the commandname, if that abbreviation is unambiguous; and you can repeat certain_GDBN__ commands by typing just @key{RET}.  You can also use the @key{TAB}key to get _GDBN__ to fill out the rest of a word in a command (or toshow you the alternatives available, if there's more than one possibility).@menu* Command Syntax::              Command Syntax* Completion::                  Command Completion* Help::                        Getting Help@end menu@node Command Syntax@section Command SyntaxA _GDBN__ command is a single line of input.  There is no limit on how longit can be.  It starts with a command name, which is followed by argumentswhose meaning depends on the command name.  For example, the command@code{step} accepts an argument which is the number of times to step,as in @samp{step 5}.  You can also use the @code{step} command withno arguments.  Some command names do not allow any arguments.@cindex abbreviation_GDBN__ command names may always be truncated if that abbreviation isunambiguous.  Other possible command abbreviations are listed in thedocumentation for individual commands.  In some cases, even ambiguousabbreviations are allowed; for example, @code{s} is specially defined asequivalent to @code{step} even though there are other commands whosenames start with @code{s}.  You can test abbreviations by using them asarguments to the @code{help} command.@cindex repeating commands@kindex RETA blank line as input to _GDBN__ (typing just @key{RET}) means torepeat the previous command. Certain commands (for example, @code{run})will not repeat this way; these are commands for which unintentionalrepetition might cause trouble and which you are unlikely to want torepeat.The @code{list} and @code{x} commands, when you repeat them with@key{RET}, construct new arguments rather than repeatingexactly as typed.  This permits easy scanning of source or memory._GDBN__ can also use @key{RET} in another way: to partition lengthyoutput, in a way similar to the common utility @code{more}(@pxref{Screen Size}).  Since it is easy to press one @key{RET} too manyin this situation, _GDBN__ disables command repetition after any commandthat generates this sort of display.@kindex #@cindex commentA line of input starting with @kbd{#} is a comment; it does nothing.This is useful mainly in command files (@pxref{Command Files}).@node Completion@section Command Completion@cindex completion@cindex word completion_GDBN__ can fill in the rest of a word in a command for you, if there'sonly one possibility; it can also show you what the valid possibilitiesare for the next word in a command, at any time.  This works for _GDBN__commands, _GDBN__ subcommands, and the names of symbols in your program.Press the @key{TAB} key whenever you want _GDBN__ to fill out the restof a word.  If there's only one possibility, _GDBN__ will fill in theword, and wait for you to finish the command (or press @key{RET} toenter it).  For example, if you type@c FIXME "@key" doesn't distinguish its argument sufficiently to permit@c complete accuracy in these examples; space introduced for clarity.@c If texinfo enhancements make it unnecessary, it would be nice to@c replace " @key" by "@key" in the following...@example(_GDBP__) info bre @key{TAB}@end example@noindent_GDBN__ fills in the rest of the word @samp{breakpoints}, since that'sthe only @code{info} subcommand beginning with @samp{bre}:@example(_GDBP__) info breakpoints@end example

⌨️ 快捷键说明

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