GDB使用手册.doc
《GDB使用手册.doc》由会员分享,可在线阅读,更多相关《GDB使用手册.doc(13页珍藏版)》请在三一办公上搜索。
1、GDB Manual 15 115.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 GDBs start-up commands (see section Getting In and Out of GDB). 你可以指定可执行文件和 core dump 文件的名称。通常的做法是在启动的时候,传递参数给启动 GDB
2、的命令(请看段“进入与退出 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 u
3、seful. 有时候需要在 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 r
4、un 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
5、program, using the path command. 使用 filename 作为要调试的程序。它的符号表被读取,或者是单一的内存的内容。它也是你运行run命令时执行的程序。如果没有指定目录,这一文件也没有在 GDB 的工作目录中找到,GDB 将使用环境变量 PATH 作为要搜索的目录列表,就像 shell 查找要运行的程序一样。你可以改变这一变量的值,用于 GDB 和你的程序,请使用 path 命令。 You can load unlinked object .o files into GDB using the file command. You will not be abl
6、e 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
7、initialized variables will appear to go to the wrong place. But this feature is still handy from time to time. 你可以使用 file 命令在 GDB 中载入没有被链接的 .o 文件。你将不可能“运行”一个这样的对象文件,但是你可以反汇编函数和观察变量。同时,如果内在的 BFD 功能性地支持它,你可以使用这一技术用 gdb-write 给对象文件打上补丁。注意在这种情况下,GDB 既不能转换,也不能修改重定向表,所以函数分支和一些已初始化的变量看起来是呆在不合适的地方。但是这一特征将始终
8、被保留,以备不时之需。 file file with no argument makes GDB discard any information it has on both executable file and the symbol table. 没有参数的 file 使 GDB 丢弃可执行程序和符号表中的任何信息。 exec-file filename Specify that the program to be run (but not the symbol table) is found in filename. GDB searches the environment variab
9、le 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 necessa
10、ry. Use the file command to get both symbol table and program to run from the same file. 从 filename 中读符号表信息。同样地根据需要查找 PATH。使用 file 命令从同一文件得到符号表和要运行的程序。 symbol-file with no argument clears out GDB information on your programs symbol table. symbol-file 没有参数时,清除 GDB 中的程序的符号表信息。 The symbol-file command
11、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. symbol-file 命令让 GDB 忘记一些断点和 auto-display 表达式的内容
12、。这是因为他们可能包含指向内部数据 (记录符号和数据类型) 的指针(旧的被 GDB 放弃的符号表的一部分)。 symbol-file does not repeat if you press RET again after executing it once. 在执行 symbol-file 一次之后,如果按下回车键,它并不会重复执行。 When GDB is configured for a particular environment, it understands debugging information in whatever format is the standard gener
13、ated 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. 当 GDB 为一个特别的环境配置好后,它识别这一环境中产生的标准的不分格式的调试信息;你既
14、可以使用一个 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
15、 source files and which symbols are present. The details are read later, one source file at a time, as they are needed. 对大多数对象文件来说,老的SVR3系统使用COFF,symbol-file 命令并不马上读取符号表。而是快速地扫描符号表,找出哪些源文件,还有哪些符号表是存在的。更多的细节信息将在随后读取,一次读一个所需的源文件。 The purpose of this two-stage reading strategy is to make GDB start up f
16、aster. 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.) two-stage 的读取策略是让GDB启动更快。在多数情况下,当一个
17、源文件的符号表细节信息被读取的时候,存在一定的暂停。(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, s
18、ince the debug info is actually in stabs format. 我们还没有实现针对 COFF 的 two-stage 。当符号表被存储为 COFF 格式时,symbol-file 立刻完全地读取符号表。注意“stabs-in-COFF”仍然做 two-stage 策略,因为调试信息实际上是 stab 格式的。 symbol-file filename -readnow file filename -readnow You can override the GDB two-stage strategy for reading symbol tables by u
19、sing the -readnow option with any of the commands that load symbol table information, if you want to be sure GDB has the entire symbol table available. 如果你想确定 GDB 读取了整个符号表,你可以使用“-readnow”选项调整 GDB 的读取符号表的 two-stage 策略,这一选项在所有的载入符号表的命令中存在。 core-file filename core Specify the whereabouts of a core dump
20、 file to be used as the contents of memory. Traditionally, core files contain only some parts of the address space of the process that generated them; GDB can access the executable file itself for other parts. 指定要用作“内存内容”的 core dump 文件。按照惯例,core 文件只包含部分产生他们的进程的地址空间;GDB 可以访问可执行文件以得到其他的部分。 core-file w
21、ith no argument specifies that no core file is to be used. core-file 不带参数表示不使用core文件。 Note that the core file is ignored when your program is actually running under GDB. So, if you have been running your program and you wish to debug a core file instead, you must kill the subprocess in which the pro
22、gram is running. To do this, use the kill command (see section Killing the child process). 注意 core 文件在你的程序运行于 GDB 下时是被忽略的。所以,如果你正在运行一个程序,而想改为调试一个 core 文件,那么你必须杀死程序运行的进程。要做这一事情,使用kill命令(请看段“杀死子进程”)。 add-symbol-file filename address add-symbol-file filename address -readnow add-symbol-file filename -s
23、section address . The add-symbol-file command reads additional symbol table information from the file filename. You would use this command when filename has been dynamically loaded (by some other means) into the program that is running. address should be the memory address at which the file has been
24、 loaded; GDB cannot figure this out for itself. You can additionally specify an arbitrary number of -ssection address pairs, to give an explicit section name and base address for that section. You can specify any address as an expression. add-symbol-file 命令从 filename 中读取增加的符号表信息。你将在 filename 被动态载入运行
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- GDB 使用手册
链接地址:https://www.31ppt.com/p-2392442.html