欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOC文档下载  

    GDB使用手册.doc

    • 资源ID:2392442       资源大小:57KB        全文页数:13页
    • 资源格式: DOC        下载积分:8金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要8金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    GDB使用手册.doc

    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 GDB's start-up commands (see section Getting In and Out of 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. 有时候需要在 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. 使用 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 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. 你可以使用 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 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. 从 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. 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 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 为一个特别的环境配置好后,它识别这一环境中产生的标准的不分格式的调试信息;你既可以使用一个 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. 对大多数对象文件来说,老的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.) 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. 我们还没有实现针对 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 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 with 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 program 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 -ssection 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 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 被动态载入运行中的程序(通过一些其他的途径)时使用这一命令。address 是文件被载入时的地址;GDB 不能指出这一点。你可以指定任意数量的“-ssection address”对,以给出显式的段名和基地址。你可以把address指定为表达式。 The symbol table of the file filename is added to the symbol table originally read with the symbol-file command. You can use 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, use 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 section 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 section was loaded, and provide these to the add-symbol-file command. ? 文件符号信息有关的每个段实际上已被载入 inferior,就像在文件中显示的一样。并且你可以决定每个段载入的地址,提供它们给 add-symbol-file 命令。 Some embedded operating systems, like Sun Chorus and VxWorks, can load relocatable files into an already running program; such systems typically make the requirements above easy to meet. However, it's important to recognize that many native systems use complex link procedures (.linkonce section factoring and C+ constructor table assembly, 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 whose 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 whose evaluation yields the address of the file's shared object file header. For this command to work, you must have used 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 used only in the Cygwin build of GDB on MS-Windows OS, where it is an alias for the dll-symbols command (see section 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,它使用一个参数:共享库文件的名称。assf 是add-shared-symbol-files 一个简写的别名。 section section addr The section command changes the base address of the named section of the exec file to addr. This can be used if the exec file does not contain section addresses, (such as in the a.out format), or when the addresses specified in the file itself are wrong. Each section must be changed separately. The info files command, described below, lists all the sections and their addresses. section 命令改变命名的可执行文件 section 的基地址为 addr。在可执行文件没有包含段地址时这是有用的(比如a.out的格式),或者当文件中指定的地址是错误的。每个段必须被单独地改变。下面描述的info files命令,列出了所有的段和他们的地址。 info files info target info files and info target are synonymous; both print the current target (see section Specifying a Debugging Target), including the names of the executable and core dump files currently in use by GDB, and the files from which symbols were loaded. The command help target lists all possible targets rather than current ones. info files 和 info target 是同义的;都打印当前的目标(请看段“指定一个调试目标”),包含可执行文件的名字和当前 GDB 使用的 core dump 文件,还有载入符号的文件。help target 命令列出所有可能的 target,而不仅是当前的那一个。 maint info sections Another command that can give you extra information about program sections is maint info sections. In addition to the section information displayed by info files, this command displays the flags and file offset of each section in the executable and core dump files. In addition, maint info sections provides the following command options (which may be arbitrarily combined): 另一个能给你有关程序段的额外信息的命令是 maint info sections。作为对 info files 显示的信息的增加,这一命令显示标记和在可执行文件及core dump 文件中的每个段的文件偏移。另外,maint info sections 提供下面的命令行选项(可以随意的组合): ALLOBJ Display sections for all loaded object files, including shared libraries. 显示所有载入的对象文件的段,包括共享库。 sections Display info only for named sections. 只显示名为sections的段的信息。 section-flags Display info only for sections for which section-flags are true. 只显示 section-flags 设为 true 的段。 The section flags that GDB currently knows about are: GDB 当前支持的段标记有: ALLOC Section will have space allocated in the process when loaded. Set for all sections except those containing debug information. 在载入时,段将有空间分配在进程中。除了包含调试信息的段外,都将被设置。 LOAD Section will be loaded from the file into the child process memory. Set for pre-initialized code and data, clear for .bss sections. 段从文件中载入,进入子进程的内存。在预初始化的代码和数据中设置,在 .bss 段中清除。 RELOC Section needs to be relocated before loading. 段需要在载入前被重定位 READONLY Section cannot be modified by the child process. 段不能被子进程修改。 CODE Section contains executable code only. 段只包含可执行代码。 DATA Section contains data only (no executable code). 段只包含数据(没有可执行代码)。 ROM Section will reside in ROM. 段将保持在 ROM 中。 CONSTRUCTOR Section contains data for constructor/destructor lists. 段包含构造/析构列表的数据。 HAS_CONTENTS Section is not empty. 段不为空。 NEVER_LOAD An instruction to the linker to not output the section. 链接器的指令不输出这一段。 COFF_SHARED_LIBRARY A notification to the linker that the section contains COFF shared library information. 告知链接器,段包含共享库的 COFF 信息。 IS_COMMON Section contains common symbols. 段包含通用的符号。 set trust-readonly-sections on Tell GDB that readonly sections in your object file really are read-only (i.e. that their contents will not change). In that case, GDB can fetch values from these sections out of the object file, rather than from the target program. For some targets (notably embedded ones), this can be a significant enhancement to debugging performance. 告诉 GDB 对象文件中的只读段确实是只读的(他们的内容将不会被改变)。在这种情况下,GDB 可以从对象文件之外的这些段获取变量值,而不是从目标程序。对一些目标(特别是嵌入的),这可能是对调试性能的一个有效的增强。 The default is off. 默认是关闭。 set trust-readonly-sections off Tell GDB not to trust readonly sections. This means that the contents

    注意事项

    本文(GDB使用手册.doc)为本站会员(文库蛋蛋多)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开