GDB使用手册

更新时间:2023-05-20 23:14:56 阅读: 评论:0

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 (e ction Getting In and Out of GDB).
你可以指定可执行文件和 core dump 文件的名称。通常的做法是在启动的时候,传递参数给启动 GDB 的命令(请看段“进入与退出 GDB”)
Occasionally it is necessary to change to a different file during a GDB ssion. Or you may run GDB and forget to specify a file you want to u. Or you are debugging a remote target via gdbrver (e ction file). In the situations the GDB commands to specify new files are uful.
有时候需要在 GDB 的会话过程中改变为一个不同的文件。或者你可能在运行 GDB 后,忘记指定你想要的文件。或者你是在通过 gdbrver 调试一个远程目标(请看段“文件”)。在这些情况下,用于指定新文件的 GDB 命令就变得很有用了。
file filename
U 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 u the run command. If you do not specify a directory and the file is not found in the GDB working directory, GDB us the environment variable PATH as a list of directories to arch, 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.
使用 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 able to "run" an object file, but you can disasmble functions and inspect variables. Also, if the underlying BFD functionality supports it, you could u gdb -write to patch object files using this technique. Note that GDB can neither interpret nor modify relocations in this ca, so branches and some 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 既不能转换,也不能修改重定向表,所以函数分支和一些已初始化的变量看起来是呆在不合适的地方。但是这一特征
将始终被保留,以备不时之需。
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 arches 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 arched when necessary. U 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 program's symbol table.
symbol-file 没有参数时,清除 GDB 中的程序的符号表信息。
The symbol-file command caus GDB to forget the contents of some breakpoints and auto-display expressions. This is becau 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 表达式的内容。这是因为他们可能包含指向内部数据 (记录符号和数据类型) 的指针(旧的被 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 generated for that environment; you may u 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 为一个特别的环境配置好后,它识别这一环境中产生的标准的不分格式的调试信息;你既可以使用一个 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 prent. The details are read later, one source file at a time, as they are needed.
对大多数对象文件来说
老的SVR3系统使用COFF,symbol-file 命令并不马上读取符号表。而是快速地扫描符号表,找出哪些源文件,还有哪些符号表是存在的。更多的细节信息将在随后读取,一次读一个所需的源文件。
The purpo of this two-stage reading strategy is to make GDB start up faster. For the most part, it is invisible except for occasional paus while the symbol table details for a particular source file are being read. (The t verbo command can turn the paus into messages if desired. See ction Optional warnings and messages.)
two-stage 的读取策略是让GDB启动更快。在多数情况下,当一个源文件的符号表细节信息被读取的时候,存在一定的暂停。(t verbo 命令可以让这些暂停显示需要的信息,请看段“可选的警告和消息”)
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.
我们还没有实现针对 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 using 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 file to be ud 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 itlf for other parts.
指定要用作“内存内容”的 core dump 文件。按照惯例,core 文件只包含部分产生他们的进程的地址空间;GDB 可以访问可执行文件以得到其他的部分。
core-file with no argument specifies that no core file is to be ud.
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 program is running. To do this, u the kill command (e ction Killing the child process).
注意 core 文件在你的程序运行于 GDB 下时是被忽略的。所以,如果你正在运行一个程序,而想改为调试一个 core 文件,那么你必须杀死程序运行的
进程。要做这一事情,使用kill命令(请看段“杀死子进程”)。
第三次印巴战争add-symbol-file filename address
add-symbol-file filename address [ -readnow ]
add-symbol-file filename -sction address ...
The add-symbol-file command reads additional symbol table information from the file filename. You would u this command when filename has been dynamically loaded (by some other means) into th
e program that is running. address should be the memory address at which the file has been loaded; GDB cannot figure this out for itlf. You can additionally specify an arbitrary number of `-sction address' pairs, to give an explicit ction name and ba address for that ction. You can specify any address as an expression.
add-symbol-file 命令从 filename 中读取增加的符号表信息。你将在 filename 被动态载入运行中的程序(通过一些其他的途径)时使用这一命令。address 是文件被载入时的地址;GDB 不能指出这一点。你可以指定任意数量的“-sction address”对,以给出显式的段名和基地址。你可以把address指定为表达式。
The symbol table of the file filename is added to the symbol table originally read with the symbol-file command. You can u the add-symbol-file command any number of times; the new symbol data thus read keeps adding to the old. To discard all old symbol data instead, u the symbol-file command without any arguments.
filename 的符号表被增加到使用 symbol-file 命令读取的符号表中。你可以任意次地使用 add-symbol-file 命令:新的符号就这样被增加到旧的之上。要丢弃所有旧的符号数据,使用不带参数的 symbol-file 命令。
我的初中时代
新员工欢迎词Although filename is typically a shared library file, an executable file, or some other object file which has been fully relocated for loading into a process, you can also load symbolic information from relocatable `.o' files, as long as:
虽然 filename 通常是一个共享库文件,一个可执行文件,或者其他为了载入进程而完全重分配的对象文件,你也可以从可重定位的“.o”文件中载入符号信息。只要:
? the file's symbolic information refers only to linker symbols defined in that file, not to symbols defined by other object files,
? 文件的符号信息都在这一文件中,而不指向其他的对象文件。
? every ction the file's symbolic information refers to has actually been loaded into the inferior, as it appears in the file, and ? you can determine the address at which every ction was loaded, and provide the to the add-symbol-file command.
? 文件符号信息有关的每个段实际上已被载入 inferior,就像在文件中显示的一样。并且你可以决定每个段载入的地址,提供它们给 add-symbol-file 命令。
Some embedded operating systems, like Sun Chorus and VxWorks, can load relocatable files into a
n already running program; such system
s typically make the requirements above easy to meet. However, it's important to recognize that many native systems u complex link procedures (.linkonce ction factoring and C++ constructor table asmbly, for example) that make the requirements difficult to meet. In general, one cannot assume that using add-symbol-file to read a relocatable object file's symbolic information will have the same effect as linking the relocatable object file into the program in the normal way.
一些嵌入式系统,比如 Sun Chorus 和 VxWorks ,可以载入可重定位的文件到一个已经运行的系统;这些系统可以让需求很容易地得到满足。然而,要认识到的重要的一点是,许多本地系统使用复杂的链接过程(比如.linkonce段因子和C++构造表的装配),而让需求很难得到满足。通常来说,我们不能假定使用 add-symbol-file 读取一个可重定位的对象文件的符号信息,和链接这一对象文件到程序是一样的效果。
add-symbol-file does not repeat if you press RET after using it.
add-symbol-file 在你使用它后按下回车时,并不重复执行。
add-symbol-file-from-memory address 形容风景美的成语
Load symbols from the given address in a dynamically loaded object file who image is mapped directly into the inferior's memory. For example, the Linux kernel maps a syscall DSO into each process's address space; this DSO provides kernel-specific code for some system calls. The argument can be any expression who evaluation yields the address of the file's shared object file header. For this command to work, you must have ud symbol-file or exec-file commands in advance.
从一个给定的 address 中读取符号,它在一个动态载入的对象文件中,它的映像直接映射较低的内存中。比如,linux 内核映射一个系统调用DSO到每个进程的地址空间;这一DSO提供了一些系统调用的核心指定的代码。参数可以是任何表达式,对它的评估倾向于文件的共享对象的文件头的地址。要让这一命令工作,你必须预先使用 symbol-file 或者exec-file 命令。
add-shared-symbol-files library-file
assf library-file
The add-shared-symbol-files command can currently be ud only in the Cygwin build of GDB on MS-Windows OS, where it is an alias for the dll-symbols command (e ction 18.1.5 Features for Debugging MS Windows PE executables). GDB automatically looks for shared libraries, however if
GDB does not find yours, you can invoke add-shared-symbol-files. It takes one argument: the shared library's file name. assf is a shorthand alias for add-shared-symbol-files.
add-shared-symbol-files 现在只能用于微软操作系统上的 Cygwin 环境上编译的GDB,在那里它是 dll-symbols 命令的一个变种(请看段“调试微软 PE 格式的程序”)。GDB 自动查找共享库,如果没有找到你的共享库时,你可以调用 add-shared-symbol-files,它使用

本文发布于:2023-05-20 23:14:56,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/920939.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

上一篇:qmgr命令
下一篇:abaqus接触分析
标签:文件   使用   符号表   指定   信息   程序
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图