GDB使用手册
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
在执行 symbol-file 一次之后,如果按下回车键,它并不会重复执行。
When GDB is configured for a particular environment, it understands debugging information in whatever format is the standard generated for that environment; you may use either a GNU compiler, or other compilers that adhere to the local conventions. Best results are usually obtained from GNU compilers; for example, using gcc you can generate debugging information for optimized code.
从 filename 中读符号表信息。同样地根据需要查找 PATH。使用 file 命令从同一文件得到符号表和要运行的程序。
symbol-file with no argument clears out GDB information on your program's symbol table.
symbol-file 没有参数时,清除 GDB 中的程序的符号表信息。
The symbol-file command causes GDB to forget the contents of some breakpoints and auto-display expressions. This is because they may contain pointers to the internal data recording symbols and data types, which are part of the old symbol table data being discarded inside GDB.
file
file with no argument makes GDB discard any information it has on both executable file and the symbol table.
没有参数的 file 使 GDB 丢弃可执行程序和符号表中的任何信息。
有时候需要在 GDB 的会话过程中改变为一个不同的文件。或者你可能在运行 GDB 后,忘记指定你想要的文件。或者你是在通过 gdbserver 调试一个远程目标(请看段“文件”)。在这些情况下,用于指定新文件的 GDB 命令就变得很有用了。
file filename
Use filename as the program to be debugged. It is read for its symbols and for the contents of pure memory. It is also the program executed when you use the run command. If you do not specify a directory and the file is not found in the GDB working directory, GDB uses the environment variable PATH as a list of directories to search, just as the shell does when looking for a program to run. You can change the value of this variable, for both GDB and your program, using the path command.
two-stage 的读取策略是让GDB启动更快。在多数情况下,当一个源文件的符号表细节信息被读取的时候,存在一定的暂停。(set verbose 命令可以让这些暂停显示需要的信息,请看段“可选的警告和消息”)
We have not implemented the two-stage strategy for COFF yet. When the symbol table is stored in COFF format, symbol-file reads the symbol table data in full right away. Note that "stabs-in-COFF" still does the two-stage strategy, since the debug info is actually in stabs format.
GDB Manual 15 1
15.1 Commands to specify files 指定文件的命令
You may want to specify executable and core dump file names. The usual way to do this is at start-up time, using the arguments to GDB's start-up commands (see section Getting In and Out of GDB).
当 GDB 为一个特别的环境配置好后,它识别这一环境中产生的标准的不分格式的调试信息;你既可以使用一个 GNU 的编译器,也可以使用遵循本地习惯的编译器。最好的选择通常来自 GNU 的编译器;比如,使用 gcc 可以产生优化的代码的调试信息。
For most kinds of object files, with the exception of old SVR3 systems using COFF, the symbol-file command does not normally read the symbol table in full right away. Instead, it scans the symbol table quickly to find which source files and which symbols are present. The details are read later, one source file at a time, as they are needed.
你可以使用 file 命令在 GDB 中载入没有被链接的 ".o" 文件。你将不可能“运行”一个这样的对象文件,但是你可以反汇编函数和观察变量。同时,如果内在的 BFD 功能性地支持它,你可以使用这一技术用 gdb-write 给对象文件打上补丁。注意在这种情况下,GDB 既不能转换,也不能修改重定向表,所以函数分支和一些已初始化的变量看起来是呆在不合适的地方。但是这一特征将始终被保留,以备不时之需。
你可以指定可执文件和 core dump 文件的名称。通常的做法是在启动的时候,传递参数给启动 GDB 的命令(请看段“进入与退出 GDB”)
Occasionally it is necessary to change to a different file during a GDB session. Or you may run GDB and forget to specify a file you want to use. Or you are debugging a remote target via gdbserver (see section file). In these situations the GDB commands to specify new files are useful.
symbol-file 命令让 GDB 忘记一些断点和 auto-display 表达式的内容。这是因为他们可能包含指向内部数据 (记录符号和数据类型) 的指针(旧的被 GDB 放弃的符号表的一部分)。
symbol-file does not repeat if you press RET again after executing it once.
使用 filename 作为要调试的程序。它的符号表被读取,或者是单一的内存的内容。它也是你运行run命令时执行的程序。如果没有指定目录,这一文件也没有在 GDB 的工作目录中找到,GDB 将使用环境变量 PATH 作为要搜索的目录列表,就像 shell 查找要运行的程序一样。你可以改变这一变量的值,用于 GDB 和你的程序,请使用 path 命令。
exec-file [ filename ]
Specify that the program to be run (but not the symbol table) is found in filename. GDB searches the environment variable PATH if necessary to locate your program. Omitting filename means to discard information on the executable file.
指定在 filename 中找到的要运行的程序(不是符号表)。GDB 根据需要查找 PATH 变量以定位指定的程序。省略 filename 意味放弃可执行文件的信息。
symbol-file [ filename ]
Read symbol table information from file filename. PATH is searched when necessary. Use the file command to get both symbol table and program to run from the same file.
You can load unlinked object `.o' files into GDB using the file command. You will not be able to "run" an object file, but you can disassemble functions and inspect variables. Also, if the underlying BFD functionality supports it, you could use gdb -write to patch object files using this technique. Note that GDB can neither interpret nor modify relocations in this case, so branches and some initialized variables will appear to go to the wrong place. But this feature is still handy from time to time.
对大多数对象文件来说,老的SVR3系统使用COFF,symbol-file 命令并不马上读取符号表。而是快速地扫描符号表,找出哪些源文件,还有哪些符号表是存在的。更多的细节信息将在随后读取,一次读一个所需的源文件。
The purpose of this two-stage reading strategy is to make GDB start up faster. For the most part, it is invisible except for occasional pauses while the symbol table details for a particular source file are being read. (The set verbose command can turn these pauses into messages if desired. See section Optional warnings and messages.)