【转】探索 Gdb7.0 的新特性反向调试 (reverse debug) 使用和原理

感谢作者分享转自:https://www.ibm.com/developerworks/cn/linux/l-cn-gdb7rd/index.html

 

GDB官方Wiki  https://sourceware.org/gdb/wiki/ProcessRecord/Tutorial

引言

GDB7.0 是 2009 年 10 月份正式发布的。和多数程序员一样,那则消息并不曾引起我的注意,因为 gdb 为数不多的几个新版本都让人觉得非常平淡。没有让人振奋的新特性。

一晃几个月过去了,随意浏览 gdb 主页的时候,我突然发现一个叫做反向调试 (reverse debug) 的特性,默默地列在不引人注目的地方。”反向调试”?我们调试总是下一步,下一步,反向调试就是上一步,上一步了?

经过简单的试用,我发现这是一个非常有用的特性,值得我们去学习和掌握。利用该功能,您可以让被调试进程反向执行。您可能会问,这有什么用处呢?

嗯,我觉得软件调试往往是一个猜测的过程,一般的普通人似乎不太可能第一次就将断点设置在最正确的位置,所以我们经常会发现重要的代码执行路径已经错过。比如运行到断点之前,程序的某些状态就已经不正确了。以往,我们只好退出当前调试会话,从头再来。

每次错误的猜测都必须让一切从头再来,如果您的运气不佳,很快就会觉得非常抓狂吧。

假如有反向调试功能,在这种情况下,我们无须重新启动调试程序,只要简单地让被调试进程反向执行到我们怀疑的地方,如果这里没有问题,我们还可以继续正向执行调试,如此这般。如同我们在学习英语时使用复读机一样,来回将听不懂的部分重放,分析。这无疑将极大地提高工作效率。

反向调试的使用简介

反向调试的基本原理为 record/replay。将被调试进程的执行过程录制下来,然后便可以像 DVD 一样的任意反向或正向回放。因此,为了使用反向调试,您首先需要使用 record 命令进行录制。

此后的调试过程和您以前所熟悉的过程一样,不过您现在多了几个反向控制的命令:

表 1. 反向调试基本命令

Command namedescription
Reverse-continue ('rc')Continueprogram being debugged but run it in reverse
Reverse-finishExecute backward until just before the selected stack frame is called
Reverse-next ('rn')Step program backward, proceeding through subroutine calls.
Reverse-nexti ('rni')Step backward one instruction, but proceed through called subroutines.
Reverse-step ('rs')Step program backward until it reaches the beginning of a previousline
Reverse-stepiStep backward exactly one instruction
set exec-directionSet direction of execution.

让我们假设您已经使用”break 10”命令在程序的第 10 行设置断点。然后输入”run”让进程开始执行。不久,程序会暂停在第 10 行代码处,控制权返回 gdb,并等待您的命令。此时如果您使用 next 命令,那么程序会顺序执行第 11 行代码,如果您使用 reverse-next,那么程序将回退执行第 9 行代码。

使用反向调试命令之后,任何时候,您还可以自由地使用其他的 gdb 命令。比如 print 来打印变量的值等等。非常方便。

反向调试的实现原理

除了使用这项特性所带来的好处之外,或许更令人着迷的是该特性的实现原理吧。我们都不曾见过时光倒流,能够回头执行指令的处理器也貌似从未出现过,那么 gdb 是如何实现反向执行的呢?

为了说明这个问题,首先我们需要回顾一些 gdb 的基本概念。

GDB 的基本概念

Gdb 的一些重要术语以及 gdb 的整体结构

进入一个陌生的国家前先学几句他们的常用语会比较好。GDB 这个小世界中也经常使用一些特有的名词,我们最好首先熟悉他们。

Exec,指一个可执行文件,可以是 ELF 格式,也可以是古老的 a.out。

Inferior指一个正在运行的 exec,一般就是指被调试进程。

接下来最好我们能够对 gdb 有一个整体的,高度概括的了解。

Gdb 的设计目标是为各种平台上的人们提供一个通用的调试器,因此它必须有可扩展性,以便人们可以将它移植到不同的硬件和软件环境下。

为了实现这个目标,GDB 的体系结构采用分层和封装的设计思想,将那些依赖于特定软硬件环境的部分进行抽象和封装。最重要的两个封装概念便是 gdbarch 和 target。他们和 gdb core 之间的关系大致可以用下图来描述:

图 1. GDB 的体系结构

图 1. GDB 的体系结构

当需要在不同的 OS 上运行 GDB 时,只需提供相应的 target 便可;同样,当需要支持一种新的新的处理器时,也只需提供新的 gdbarch,而 gdb core 则无需任何修改。

关于 gdbarch

Gdbarch 是一个封装了所有关于处理器硬件细节的数据结构。在这个数据结构中,不仅包括一些描述处理器特性的变量,也包括一些函数(喜欢 OO 的人会自然地联想到类。)这些函数实现了对具体硬件的一些重要操作,比如分析 stack frame,等等。

完整的 gdbarch 数据结构非常庞大,无法一一列出,下表分类总结了 gdbarch 中的重要信息:

表 2. gdbarch 数据结构

分类说明
描述硬件体系结构和 ABI 细节的信息比如 :
endianism : 大端系统还是小端系统
比如 return_value:描述该处理器 ABI 中规定的处理函数返回值的方法
breakpoint_from_pc: 用于断点替换的机器指令 , 比如 i386 中为 int3
struct gdbarch_tdepadditional target specific data, beyond that which is
covered by the standard struct gdbarch.
描述标准数据结构的信息高级语言的 int, char 等标准数据结构的具体定义
访问和显示寄存器的函数read_pc: 返回指令指针寄存器
num_regs: 返回寄存器的个数
访问和分析 stack frame 的函数不同体系结构的 stack frame 都不尽相同。这些函数提供了如何分析和创建 stack frame 的具体实现函数。

可以看到 gdbarch 封装了所有 gdb 运行时所需要的硬件信息,以及如何访问和处理这些信息的具体函数。类似于面向对象设计中的类的设计,将关于处理器硬件细节的数据和方法都封装到 gdbarch 数据结构中。

关于 target

同 gdbarch 一样,target 也是一种封装。但 target 所封装的概念更复杂一些。它不仅封装某一种操作系统,也封装了不同的”调试方式”。

首先,不同的操作系统对应不同的 target。同样在 i386 处理器下工作,Linux 和 vxworks 对于 debug 的支持是不同的,比如如何创建进程,如何控制进程等。这些不同对于 gdb core 是透明的,由 target 来屏蔽。

此外,target 还封装了不同的”调试方式”。这个词比较抽象,最好是举例说明。

比如,同样是在 i386 Linux 下面,您即可以使用 native 方式调试 exec,也可以调试一个 core dump 文件,还可以 attach 一个正在运行的进程并调试它。打开一个可执行文件和一个 core dump 文件的方法是不同的,同样,将一个可执行文件 load 进内存执行和 attach 到一个正在执行的进程也是不同的。

对于这些不同,gdb 也采用 target 进行封装。对于 gdb core 来说,当它需要让一个调试目标开始运行时,便调用 target 相应的回调函数,而不必关心这个回调函数如何实现。启动进程的具体的细节由不同的 target 来具体实现。当 target 为 exec,即一个磁盘上的可执行文件时,可以使用 fork+exec 的方式;当 target 是一个远程调试目标时,可以通过 TCP/IP 发送一个命令给 gdb server 进行远程调试;当 target 是一个已经在运行的进程时,需要使用 ptrace 的 attach 命令挂载上去。诸如这些细节,gdb 统统由 target 这个概念来封装。

这便是 target 这个概念的主要意义,不过,还有一些事实让 target 更加复杂。

有时候,人们希望在同一个 gdb 会话中调试多个 target。最常见的例子是调试 core dump 文件时,往往需要同时打开产生 core dume 的可执行文件,以便读取符号。

比如程序 a.out 产生了 core dump 文件 core.2629,当用 gdb 打开 core dump 文件后,使用 bt 命令查看调用顺序时,人们不能看到函数名。

图 2. 没有符号信息的调用堆栈显示

图 2. 没有符号信息的调用堆栈显示

此时人们往往还需要用 file 命令打开 a.out 程序,即一个 exec。

图 3. 有了符号信息的调用堆栈显示

图 3. 有了符号信息的调用堆栈显示

除了 core dump 分析,还有其它一些情况要求 gdb 同时管理多个 target。为了应对这些需求,gdb 对 target 采用了分层、优先级管理的堆栈模式。堆栈中的每一层由一个形如 xyz_stratum 的古怪名字来标示,如下图所示:

图 4. GDB 的 target stratum

图 4. GDB 的 target stratum

这个堆栈的优先级从上到下递增,gdb 总是采用最高优先级 target 所提供的函数进行操作。

以图 2,3 中的命令为例,打开 core dump 文件时,core_stratum 层的 target 被 push 进入 target stack;当用户使用命令 file a.out 时,一个 file_stratum 层的 target 被 push 进入 target stack。他们依照自身的优先级归于不同的层,绝不会弄错。

当 target stack 中只有 core_stratum 的 target 时,假如用户希望执行 run 命令是不可能的,因为 core dump 文件无法运行,而当载入了 exec target 后,这个 file_stratum 层的 target 提供了和 run 命令相应的回调函数,从而使得 gdb 可以使用 run 命令启动一个 inferior。您在稍后的章节中可以看出,这种分层结构对反向调试的实现非常有帮助。

下表列出了 target 数据结构的重要内容:

表 3. Target 数据结构

分类说明
关于 target 的说明信息比如 :
to_name: target 的名字
to_stratum: 该 target 在 target stack 中的层数
控制调试目标的函数比如 :
to_open: 打开 target, 对于 exec 或 core dump 文件执行文件打开操作 ; 对于 remote target, 打开 socket 建立 TCP 连接等操作 .
访问调试目标寄存器和内存的函数比如 :
to_store_registers
处理断点的函数比如 :
Insert_break_point
控制调试进程的函数比如 :
to_resume. Function to tell the target to start running again (or for the first time).
等等。

GDB 运行时的基本流程

对一个目标进程进行调试,需要操作系统提供相应的调试功能。比如将一个正在运行的进程暂停并读写其地址空间等。在传统 Unix 中,一般由 ptrace 系统调用提供这些功能。本文不打算详细介绍 ptrace,读者可以通过参考资料 [5] 获得更详细的介绍。

但 ptrace 的编程模式极大地影响了 gdb 的设计,下面我们研究 gdb 如何使用 Ptrace。

首先,gdb 调用 ptrace 将一个目标进程暂停,然后,gdb 可以通过 ptrace 读写目标进程的地址空间,还可以通过 ptrace 让目标进程进入单步执行状态。Ptrace 函数返回之后,gdb 便开始等待目标进程发来的信号,以便进一步的工作。

以单步执行为例,gdb 调用 ptrace 将目标进程设置为单步执行模式之后,便开始等待 inferior 的消息。因为处于单步模式,inferior 每执行一条指令,Linux 便将该进程挂起,并发送一个信号给 ptrace 的调用者,即 gdb。Gdb 接受到这条信号 ( 通过 wait 系统调用 ) 后,便知道目标进程已经完成了一次单步,然后进行相应处理,比如判断这里是否有断点,或进入交互界面等待用户的命令等等。

这非常类似窗口系统中的消息循环模式。Ptrace 的这一工作模式影响了整个 gdb 的设计,无论具体的 target 是否支持 ptrace,gdb 都采用这种消息循环模式。

理解了以上的基础知识,您就可以开始探索反向调试的具体实现细节了。

反向调试原理和代码导读

原理概述

如前所述,反向调试的基本原理是录制回放。它将 inferior 运行过程中的每条指令的执行细节录制下来,存放到 log 中。当需要回退时,从 log 中读取前一条指令执行的细节,根据这些细节,执行 undo 操作,从而将 inferior 恢复到当时的状态,如此便实现了“上一步”。

undo 就是将某条指令所做的工作取消。比如指令 A 将寄存器 reg1 的值加了 1,那么 undo 就是将其减一。

原理很简单,然而要将此想法付诸实现,人们必须解决几个具体的问题:

如何录制,又如何回放呢?

首先,gdb7.0 引入了一个新的 target,叫做 record target。这个 target 提供了录制和回放的基本代码框架。

其次,当我们说到一条指令的执行细节时,究竟是指那些具体内容呢?或者说我们究竟应该录制些什么呢?这些记录如何组织?这便是 record list 的主要内容。下面我们一一来了解这些知识。

Record target

反向调试引入了一个新的 target,叫做”record”,它工作在 target stack 的第二层。Gdb target 的分层结构带来了这样一种好处:高层的 target 可以复用底层 target 的功能,并在其上添加额外的功能。我想我们可以这么说:低层 target 完成基本的低级功能,高层 target 完成更高级的功能。

Record target 就是一个带录制功能的高层 target,它依赖低层 target 完成诸如启动进程,插入断点,控制单步等基本功能。在此之上,它将 inferior 执行过程中的每条指令的细节记录下来。此外,它还处理几个反向调试特有的命令,reverse next 等。

当用户希望进行反向执行时,record target 并不需要低层 target 的帮助。因为 inferior 的执行过程都已经被记录在一个 log 中,反向执行时,record target 从 log 中读取记录,并 undo 这些记录的影响,比如恢复先前寄存器的值,恢复被指令修改的内存值等,从而达到了反向执行的效果。

下面我们详细分析几个重要的 record target 所提供的函数,从而对上述基本思想有更深入的理解。

首先看 record_open 操作。如前所述,Record target 可以看作对低层 target 的一个 wrapper。Record_open 时,首先将当前 target 的重要回调函数 ( 比如后续将说明的 to_resume, to_wait 等 ) 复制到一系列的 beneath function pointers 中。然后将”record target” push 到 target stack 的顶层。

第二个重要的操作是 record_resume。Record_resume 在 gdb 决定让目标进程开始运行之前被调用,因此这里是绝佳的录制点。该函数的实现比较简单:

清单 1. record_resume 函数

record_resume (struct target_ops *ops, ptid_t ptid, int step, 
              enum target_signal signal) 
{ 
 record_resume_step = step; 
 if (!RECORD_IS_REPLAY) 
   { 
     if (do_record_message (get_current_regcache (), signal)) 
       { 
         record_resume_error = 0; 
       } 
     else 
       { 
         record_resume_error = 1; 
         return; 
       } 
     record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1, 
                               signal); 
   } 
}

 

Record_resume 首先调用 do_record_message 进行录制,然后调用低层 target 的 to_resume 函数(已经保存在 beneath function pointer 中)完成基本的 resume 工作。

这里需要注意一点,在调用 record_beneath_to_resume时,第三个参数 step为 1,即单步执行。这是因为 record target需要录制目标进程的每条指令,因此假如用户命令为 continue或 next,而不是 step时 ,目标进程将继续执行下去直到遇到断点为止,在此期间的指令 gdb无法获知,便也无从记录。因此 record target强制目标进程进入单步执行状态。以便录制每一条指令。

第三个重要的操作是 record_wait。从函数的名字便可以猜得该函数是 gdb 等待目标进程信号的函数。

当 record target 执行了 record_resume 之后,inferior 恢复执行。而 gdb 自己则开始等待 inferior 的信号。前面已经看到,record_resume 强行让 inferior 进入单步状态,因此 inferior 在执行完一条指令后,便会被强制挂起,并向 gdb 发送一个 SIGCHLD 信号。此时 record_wait() 便开始执行。

该函数首先判断是否需要进行录制,如果需要,则进一步判断当前的 inferior 是否是单步执行状态,如果是,则不需要进行录制,因为马上 inferior 就会停下来,而 gdb 再次让 inferior 恢复执行时将调用 record_resume,那里会执行录制工作。

但如果当前的 inferior 不在单步状态,且下一条指令不是断点,那么如果让 inferior 继续执行则意味着 record target 将错过后续的指令执行而无法进行录制。因此,在这种情况下,record_wait 将进入一个循环,在每次循环迭代中执行录制,并让 inferior 进入单步执行状态,直到遇到断点或者 Inferior 执行 exit 为止。伪代码如下:

清单 2. 执行录制的伪代码

while(1) 
{ 
 waitForNextSignal(); 
 recordThisInst(); 
 resumeInferiorAndSingleStep(); 
 if(this is a breakpoint || this is end of inferior) 
   break; 
}

 

这样,通过 record_wait 的处理,inferior 的每条执行指令都将被录制下来。

Record_wait 的另外一半代码是处理 replay 的。假如当前用户希望反向执行,那么 record_wait 就从日志中读取 inferior 上一条执行指令的相关记录,恢复寄存器,内存等上下文,从而实现“上一步”的操作。

Record list

每次执行一条指令,record target 便将关于该指令的信息录制下来。这些信息可以完整地描述一条指令执行的效果。在目前的 record target 中,记录的信息只包括两类:寄存器和内存。

一条机器指令能够改变的就是寄存器或内存。因此每次执行一条指令,record target 对该指令进行分析,如果它修改了内存,那么便记录下被修改的内存的地址和值;如果它修改了寄存器,便记录下寄存器的序号和具体的值。

这些修改记录由 struct record_entry 表示和存储。

清单 3 单个记录的数据结构

struct record_entry
{
 struct record_entry *prev;
 struct record_entry *next;
 enum record_type type;
 
union
 {
   /* reg */
   struct record_reg_entry reg;

   /* mem */
   struct record_mem_entry mem;

   /* end */
   struct record_end_entry end;
 } u;

};

 

多个 record_entry 通过 prev 和 next 连接成 record_list 链表。一条机器指令可能既修改内存也修改寄存器,因此一条指令的执行效果由 record_list 中的多个 entry 组成。有三种 entry,表示寄存器的 entry,表示 memory 的 entry 和标志指令结束的 entry。顾名思义,register entry 用来记录寄存器的修改情况;memory entry 用来记录内存的修改;end entry 表示指令结束。

如下图所示:

图 5. 反向调试的 log 结构

图 5. 反向调试的 log 结构

图 5. 反向调试的 log 结构

 

第一条指令 inst1 由三个 entry 组成,一个 memory entry, 一个 reg entry 和一个 end entry。表明 inst1 修改了内存和寄存器;同理,inst2,3 等也使用了同样的数据结构。

函数 do_record_message

函数 do_record_message 具体完成指令执行的录制细节。抛开 gdb 代码的层层调用细节,该函数的具体工作是调用 gdbarch 所提供的 process_record 回调函数。

对于 i386,具体的 process_record 函数为

清单 4. 函数 process_record 定义

1

2

int i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,

CORE_ADDR addr)

这是一个 1000 多行的巨型函数,我建议大家不必精读其中的每一行代码。。。

大体说来,该函数首先反汇编正在执行的机器指令,根据反汇编的结果分析该指令是否修改了寄存器或者内存。如果有所修改,就分别分配新的 reg entry 或者 mem entry 并插入到 record_list,当对该指令的所有执行结果都分配了相应的 record_entry 之后,调用 record_arch_list_add_end 插入一个 end entry,然后返回。这样,do_record_message() 执行完后,关于当前指令的所有细节都被保存到 record_list 中了。

record target 执行录制的时序图

Record target 的录制过程用时序图来表示比较容易理解,因为将相关操作串起来的是事件而不是函数调用关系。假如您打算跟踪函数的调用关系,那么很快就会迷失到晕头转向。参考资料 [7] 是我看到的最好的关于 gdb 的文档,我觉得其中最棒的部分就是 gdb 命令执行时的时序图,这是一种非常好的表示方法。下面我打算用时序图来完整地描述前面罗罗嗦嗦几千字却依然描述不清的东西。

最简单的 record 命令序列为:

1

2

3

4

> b main

> run

> record

> continue

我们用图 6 来表示上述命令序列所对应的、gdb 内部执行过程的时序图。

图 6. 录制的时序图

图 6. 录制的时序图

 

当用户输入 run 命令后,gdb 会调用 target_insert_breakpoint 将目前 active 的断点设置到 inferior 中,对于 i386 的 arch 目标,会将 inferior 的断点处的指令替换为 int 3 指令。然后,gdb 调用 target_resume,恢复 Inferior 的运行。此时,target stack 顶端的 target 会执行正常的 target_resume 操作,比如 ptrace(CONTINUE)。

当 inferior 执行到断点地址时,此时的指令被替换为 int3,因此会产生一个 trap。该信号被 gdb 捕获进入 target_wait。此时 gdb 重新获得控制权,进入 current_interp_command_loop 等待用户输入命令。

接下来用户输入 record 命令,这将导致 gdb 调用 record_open 函数,将 record target 推入 target stack 的栈顶,并回到 gdb 的命令行等待用户输入新的命令。

下一条命令是 continue,gdb core 将调用当前 target 的 target_resume 函数来恢复 inferior 的运行。此时的 target_resume 函数已经变成 record_resume。通过前面的代码分析,我们可以知道,此时 record_resume 将调用 do_record_message 完成第一条指令的录制,target_resume 函数执行完将返回 process() 函数。Gdb core 此时将调用 target_wait() 函数来等待 inferior 的下一个消息。同样,此时的 target_wait 为 record_wait(),因此 gdb 进入 record_wait()。

Record_wait 将完成剩余的录制过程。因为当前的用户命令为 continue,因此 record_wait 将进入代码清单 2 所示的循环,循环执行下列操作:

  • 录制当前指令
  • 调用下一层的 resume 函数并将 step 参数设置为一,强制 inferior 进入单步执行。
  • 等待 inferior 的消息

由于单步执行,inferior 在执行完一条指令后又将 gdb 的 wait 操作唤醒,继续上述循环。如此循环往复,直到遇到断点或者执行到 exit 为止,从而完成录制过程。

Recored target 回放功能的实现比较简单,本文长度有限,读者可以自行分析。

GDB 反向调试的局限

Gdb 的反向调试是从 2006 年左右开始研发的,虽然目前已经正式发布。但还是不太稳定,且有一些局限。简述如下:

有 side effect 的语句虽然能够回退执行,但其所造成的 side effect 则无法撤销。比如打印到屏幕上的字符并不会因为打印语句的回退而自动消失。

因此,反向调试不适用于 IO 操作。

此外 , 支持反向调试的处理器体系结构还很有限 , 需要更多的研发人员参与进来 .

结束语

很多人都在问,反向调试究竟有多大的实际用处?我在本文的开头便简单介绍了一种使用它的场景,但我想这并不能令心存怀疑的人满意。实际上,以我的个人经验来看,50% 的程序员从来不使用调试器。对于很多实际工作,即使不使用调试器,通过不断的打印和代码分析最终也能够解决问题。但假如能正确地使用调试器,或许能够更加有效地解决问题,从而将人生的宝贵时间使用在其他更有意义的地方。正如 Norman Matloff 所说,调试是一种艺术。没有艺术,人类依然可以生存,然而远在 1 万多年前,拉科斯的史前人也要在岩洞的墙壁上涂抹出一头牛或者一匹马,那有什么实际用处呢?

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Table of Contents Summary of gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Free Software Needs Free Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Contributors to gdb. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1 A Sample gdb Session . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2 Getting In and Out of gdb . . . . . . . . . . . . . . . . . . . 11 2.1 Invoking gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Choosing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.2 Choosing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.3 What gdb Does During Startup . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Quitting gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Shell Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Logging Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 11 12 13 15 16 16 17 gdb Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.1 Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.2 Command Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.3 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4 Running Programs Under gdb . . . . . . . . . . . . . . . 25 4.1 Compiling for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Starting your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Your Program’s Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 Your Program’s Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5 Your Program’s Working Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6 Your Program’s Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7 Debugging an Already-running Process . . . . . . . . . . . . . . . . . . . . . . . . 4.8 Killing the Child Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.9 Debugging Multiple Inferiors and Programs. . . . . . . . . . . . . . . . . . . . 4.10 Debugging Programs with Multiple Threads . . . . . . . . . . . . . . . . . . 4.11 Debugging Forks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.12 Setting a Bookmark to Return to Later. . . . . . . . . . . . . . . . . . . . . . . 4.12.1 A Non-obvious Benefit of Using Checkpoints . . . . . . . . . . . . . 25 25 28 29 30 30 31 32 32 35 38 40 41 ii 5 Debugging with gdb Stopping and Continuing . . . . . . . . . . . . . . . . . . . . . 43 5.1 Breakpoints, Watchpoints, and Catchpoints . . . . . . . . . . . . . . . . . . . 5.1.1 Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.2 Setting Watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.3 Setting Catchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.4 Deleting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.5 Disabling Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.6 Break Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.7 Breakpoint Command Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.8 “Cannot insert breakpoints” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.9 “Breakpoint address adjusted...”. . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Continuing and Stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4 Stopping and Starting Multi-thread Programs . . . . . . . . . . . . . . . . . 5.4.1 All-Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.2 Non-Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.3 Background Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.4 Thread-Specific Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.5 Interrupted System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 44 49 51 55 55 56 58 59 59 60 63 65 65 67 68 69 69 6 Running programs backward . . . . . . . . . . . . . . . . . 71 7 Recording Inferior’s Execution and Replaying It . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 8 Examining the Stack . . . . . . . . . . . . . . . . . . . . . . . . . . 77 8.1 8.2 8.3 8.4 9 Stack Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Backtraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Selecting a Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Information About a Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 78 80 81 Examining Source Files . . . . . . . . . . . . . . . . . . . . . . . 83 9.1 Printing Source Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2 Specifying a Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3 Editing Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3.1 Choosing your Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.4 Searching Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.5 Specifying Source Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.6 Source and Machine Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 84 85 85 86 86 89 iii 10 Examining Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 10.1 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 10.2 Ambiguous Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 10.3 Program Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 10.4 Artificial Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 10.5 Output Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 10.6 Examining Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 10.7 Automatic Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 10.8 Print Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 10.9 Value History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 10.10 Convenience Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 10.11 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 10.12 Floating Point Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 10.13 Vector Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 10.14 Operating System Auxiliary Information . . . . . . . . . . . . . . . . . . . 112 10.15 Memory Region Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 10.15.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 10.15.1.1 Memory Access Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 10.15.1.2 Memory Access Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 10.15.1.3 Data Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 10.15.2 Memory Access Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 10.16 Copy Between Memory and a File . . . . . . . . . . . . . . . . . . . . . . . . . 115 10.17 How to Produce a Core File from Your Program . . . . . . . . . . . 116 10.18 Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 10.19 Caching Data of Remote Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 10.20 Search Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 11 Debugging Optimized Code . . . . . . . . . . . . . . . . 123 11.1 Inline Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 12 C Preprocessor Macros . . . . . . . . . . . . . . . . . . . . . 125 13 Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 13.1 Commands to Set Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.1 Create and Delete Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.2 Enable and Disable Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . 13.1.3 Tracepoint Passcounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.4 Tracepoint Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.5 Trace State Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.6 Tracepoint Action Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.7 Listing Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.8 Starting and Stopping Trace Experiments . . . . . . . . . . . . . . 13.2 Using the Collected Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.2.1 tfind n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.2.2 tdump. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13.2.3 save-tracepoints filename . . . . . . . . . . . . . . . . . . . . . . . . . . 13.3 Convenience Variables for Tracepoints . . . . . . . . . . . . . . . . . . . . . . . 13.4 Using Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 130 131 131 131 132 132 134 134 136 136 138 138 139 139 iv Debugging with gdb 14 Debugging Programs That Use Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 14.1 14.2 14.3 14.4 15 How Overlays Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Overlay Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Automatic Overlay Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Overlay Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 142 144 145 Using gdb with Different Languages . . . . . . 147 15.1 Switching Between Source Languages . . . . . . . . . . . . . . . . . . . . . . . 15.1.1 List of Filename Extensions and Languages . . . . . . . . . . . . . 15.1.2 Setting the Working Language . . . . . . . . . . . . . . . . . . . . . . . . . 15.1.3 Having gdb Infer the Source Language . . . . . . . . . . . . . . . . . 15.2 Displaying the Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.3 Type and Range Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.3.1 An Overview of Type Checking . . . . . . . . . . . . . . . . . . . . . . . . 15.3.2 An Overview of Range Checking . . . . . . . . . . . . . . . . . . . . . . . 15.4 Supported Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1 C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1.1 C and C++ Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1.2 C and C++ Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1.3 C++ Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1.4 C and C++ Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1.5 C and C++ Type and Range Checks . . . . . . . . . . . . . . . 15.4.1.6 gdb and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1.7 gdb Features for C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.1.8 Decimal Floating Point format . . . . . . . . . . . . . . . . . . . . 15.4.2 Objective-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.2.1 Method Names in Commands . . . . . . . . . . . . . . . . . . . . . 15.4.2.2 The Print Command With Objective-C . . . . . . . . . . . . 15.4.3 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.3.1 Fortran Operators and Expressions . . . . . . . . . . . . . . . . 15.4.3.2 Fortran Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.3.3 Special Fortran Commands . . . . . . . . . . . . . . . . . . . . . . . . 15.4.4 Pascal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.5 Modula-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.5.1 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.5.2 Built-in Functions and Procedures . . . . . . . . . . . . . . . . . 15.4.5.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.5.4 Modula-2 Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.5.5 Modula-2 Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.5.6 Deviations from Standard Modula-2 . . . . . . . . . . . . . . . 15.4.5.7 Modula-2 Type and Range Checks. . . . . . . . . . . . . . . . . 15.4.5.8 The Scope Operators :: and . . . . . . . . . . . . . . . . . . . . . 15.4.5.9 gdb and Modula-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.6 Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.6.2 Omissions from Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.6.3 Additions to Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 147 148 148 148 149 149 150 151 151 152 153 154 155 155 155 156 157 157 157 158 158 158 159 159 159 159 159 161 162 162 164 164 164 165 165 165 165 166 167 v 15.4.6.4 Stopping at the Very Beginning . . . . . . . . . . . . . . . . . . . 15.4.6.5 Extensions for Ada Tasks . . . . . . . . . . . . . . . . . . . . . . . . . 15.4.6.6 Tasking Support when Debugging Core Files . . . . . . 15.4.6.7 Known Peculiarities of Ada Mode . . . . . . . . . . . . . . . . . 15.5 Unsupported Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 169 172 172 173 16 Examining the Symbol Table . . . . . . . . . . . . . . 175 17 Altering Execution. . . . . . . . . . . . . . . . . . . . . . . . . . 181 17.1 17.2 17.3 17.4 17.5 17.6 18 Commands to Specify Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debugging Information in Separate Files . . . . . . . . . . . . . . . . . . . . Errors Reading Symbol Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . GDB Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 193 197 198 Specifying a Debugging Target . . . . . . . . . . . . 199 19.1 19.2 19.3 20 181 182 183 183 184 185 gdb Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 18.1 18.2 18.3 18.4 19 Assignment to Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Continuing at a Different Address . . . . . . . . . . . . . . . . . . . . . . . . . . . Giving your Program a Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Returning from a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Calling Program Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Patching Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Active Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Commands for Managing Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Choosing Target Byte Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Debugging Remote Programs . . . . . . . . . . . . . . 203 20.1 Connecting to a Remote Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.2 Sending files to a remote system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.3 Using the gdbserver Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.3.1 Running gdbserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.3.1.1 Attaching to a Running Program . . . . . . . . . . . . . . . . . . 20.3.1.2 Multi-Process Mode for gdbserver . . . . . . . . . . . . . . . . 20.3.1.3 Other Command-Line Arguments for gdbserver . . . 20.3.2 Connecting to gdbserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.3.3 Monitor Commands for gdbserver . . . . . . . . . . . . . . . . . . . . . 20.4 Remote Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.5 Implementing a Remote Stub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20.5.1 What the Stub Can Do for You . . . . . . . . . . . . . . . . . . . . . . . . 20.5.2 What You Must Do for the Stub . . . . . . . . . . . . . . . . . . . . . . . 20.5.3 Putting it All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 205 205 205 206 206 207 207 207 208 212 213 214 215 vi Debugging with gdb 21 Configuration-Specific Information . . . . . . . . 217 21.1 Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.1 HP-UX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.2 BSD libkvm Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.3 SVR4 Process Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.4 Features for Debugging djgpp Programs . . . . . . . . . . . . . . . 21.1.5 Features for Debugging MS Windows PE Executables . . 21.1.5.1 Support for DLLs without Debugging Symbols. . . . . 21.1.5.2 DLL Name Prefixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.5.3 Working with Minimal Symbols . . . . . . . . . . . . . . . . . . . 21.1.6 Commands Specific to gnu Hurd Systems . . . . . . . . . . . . . . 21.1.7 QNX Neutrino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.8 Darwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Embedded Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2.1 Using gdb with VxWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2.1.1 Connecting to VxWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2.1.2 VxWorks Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2.1.3 Running Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Embedded Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.1 ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.2 Renesas M32R/D and M32R/SDI . . . . . . . . . . . . . . . . . . . . . . 21.3.3 M68k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.4 MicroBlaze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.5 MIPS Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.6 OpenRISC 1000. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.7 PowerPC Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.8 HP PA Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.9 Tsqware Sparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.9.1 Setting File to Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.9.2 Connecting to Sparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.9.3 Sparclet Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.9.4 Running and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.10 Fujitsu Sparclite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.11 Zilog Z8000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.12 Atmel AVR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.13 CRIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.14 Renesas Super-H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4.1 x86 Architecture-specific Issues . . . . . . . . . . . . . . . . . . . . . . . . . 21.4.2 A29K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4.3 Alpha. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4.4 MIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4.5 HPPA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4.6 Cell Broadband Engine SPU architecture . . . . . . . . . . . . . . . 21.4.7 PowerPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 217 217 217 219 221 222 223 223 224 226 226 227 227 228 228 229 229 229 231 232 232 232 235 236 237 237 238 238 238 238 239 239 239 239 240 240 240 241 241 241 243 243 244 vii 22 Controlling gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23 Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Command Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Command History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Screen Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuring the Current ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Optional Warnings and Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . Optional Messages about Internal Happenings . . . . . . . . . . . . . . . Other Miscellaneous Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 245 245 247 248 248 249 251 253 Extending gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 23.1 Canned Sequences of Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.1.1 User-defined Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.1.2 User-defined Command Hooks. . . . . . . . . . . . . . . . . . . . . . . . . . 23.1.3 Command Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.1.4 Commands for Controlled Output . . . . . . . . . . . . . . . . . . . . . . 23.2 Scripting gdb using Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.1 Python Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2 Python API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.1 Basic Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.2 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.3 Auto-loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.4 Values From Inferior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.5 Types In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.6 Pretty Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.7 Selecting Pretty-Printers . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.8 Commands In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.9 Writing new convenience functions . . . . . . . . . . . . . . . . 23.2.2.10 Objfiles In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23.2.2.11 Acessing inferior stack frames from Python. . . . . . . 23.2.2.12 Python representation of lazy strings. . . . . . . . . . . . . 255 255 257 258 259 261 261 262 262 263 263 264 266 269 271 272 275 276 276 277 24 Command Interpreters . . . . . . . . . . . . . . . . . . . . . 279 25 gdb Text User Interface . . . . . . . . . . . . . . . . . . . . 281 25.1 25.2 25.3 25.4 25.5 26 TUI Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TUI Key Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TUI Single Key Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TUI-specific Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TUI Configuration Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 282 283 283 285 Using gdb under gnu Emacs . . . . . . . . . . . . . . . 287 viii Debugging with gdb 27 The gdb/mi Interface . . . . . . . . . . . . . . . . . . . . . . . 289 Function and Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Notation and Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.3 gdb/mi General Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.3.1 Context management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.3.2 Asynchronous command execution and non-stop mode . . 27.3.3 Thread groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.4 gdb/mi Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.4.1 gdb/mi Input Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.4.2 gdb/mi Output Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.5 gdb/mi Compatibility with CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.6 gdb/mi Development and Front Ends . . . . . . . . . . . . . . . . . . . . . . . 27.7 gdb/mi Output Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.7.1 gdb/mi Result Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.7.2 gdb/mi Stream Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.7.3 gdb/mi Async Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.7.4 gdb/mi Frame Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.7.5 gdb/mi Thread Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.8 Simple Examples of gdb/mi Interaction . . . . . . . . . . . . . . . . . . . . . 27.9 gdb/mi Command Description Format . . . . . . . . . . . . . . . . . . . . . . 27.10 gdb/mi Breakpoint Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.11 gdb/mi Program Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.12 gdb/mi Thread Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.13 gdb/mi Program Execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.14 gdb/mi Stack Manipulation Commands . . . . . . . . . . . . . . . . . . . . 27.15 gdb/mi Variable Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.16 gdb/mi Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.17 gdb/mi Tracepoint Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.18 gdb/mi Symbol Query Commands . . . . . . . . . . . . . . . . . . . . . . . . . 27.19 gdb/mi File Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27.20 gdb/mi Target Manipulation Commands. . . . . . . . . . . . . . . . . . . 27.21 gdb/mi File Transfer Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 27.22 Miscellaneous gdb/mi Commands . . . . . . . . . . . . . . . . . . . . . . . . . 28 gdb Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 28.1 28.2 28.3 28.4 28.5 28.6 28.7 29 289 289 289 290 291 291 292 292 293 294 294 295 295 295 296 298 298 298 299 300 308 311 312 319 324 334 340 341 341 343 346 347 What is an Annotation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Server Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Annotation for gdb Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Invalidation Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Displaying Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 356 356 357 357 357 358 JIT Compilation Interface . . . . . . . . . . . . . . . . . 359 29.1 29.2 29.3 JIT Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 Registering Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 Unregistering Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 ix 30 Reporting Bugs in gdb . . . . . . . . . . . . . . . . . . . . . 361 30.1 30.2 31 Have You Found a Bug? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 How to Report Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 Command Line Editing. . . . . . . . . . . . . . . . . . . . . 365 31.1 Introduction to Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Readline Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2.1 Readline Bare Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2.2 Readline Movement Commands . . . . . . . . . . . . . . . . . . . . . . . . 31.2.3 Readline Killing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2.4 Readline Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2.5 Searching for Commands in the History . . . . . . . . . . . . . . . . 31.3 Readline Init File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3.1 Readline Init File Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3.2 Conditional Init Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3.3 Sample Init File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Bindable Readline Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4.1 Commands For Moving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4.2 Commands For Manipulating The History . . . . . . . . . . . . . . 31.4.3 Commands For Changing Text . . . . . . . . . . . . . . . . . . . . . . . . . 31.4.4 Killing And Yanking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4.5 Specifying Numeric Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 31.4.6 Letting Readline Type For You. . . . . . . . . . . . . . . . . . . . . . . . . 31.4.7 Keyboard Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4.8 Some Miscellaneous Commands . . . . . . . . . . . . . . . . . . . . . . . . 31.5 Readline vi Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 365 365 365 366 366 367 367 368 368 373 374 377 377 377 379 380 381 381 381 382 383 Using History Interactively . . . . . . . . . . . . . . . . 385 32.1 History Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.1 Event Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.2 Word Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.3 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 385 385 386 Appendix A Formatting Documentation . . . . . 389 Appendix B Installing gdb . . . . . . . . . . . . . . . . . . . . 391 B.1 B.2 B.3 B.4 B.5 B.6 Requirements for Building gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Invoking the gdb ‘configure’ Script . . . . . . . . . . . . . . . . . . . . . . . . Compiling gdb in Another Directory . . . . . . . . . . . . . . . . . . . . . . . . Specifying Names for Hosts and Targets . . . . . . . . . . . . . . . . . . . . . ‘configure’ Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . System-wide configuration and settings . . . . . . . . . . . . . . . . . . . . . . Appendix C 391 392 393 394 395 395 Maintenance Commands. . . . . . . . 397 x Debugging with gdb Appendix D gdb Remote Serial Protocol . . . . 403 D.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.2 Standard Replies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.3 Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.4 Stop Reply Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.5 General Query Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.6 Architecture-Specific Protocol Details . . . . . . . . . . . . . . . . . . . . . . . . D.6.1 ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.6.1.1 Breakpoint Kinds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.6.2 MIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.6.2.1 Register Packet Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.6.2.2 Breakpoint Kinds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.7 Tracepoint Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.8 Host I/O Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.9 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.10 Notification Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.11 Remote Protocol Support for Non-Stop Mode . . . . . . . . . . . . . . . D.12 Packet Acknowledgment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.13 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14 File-I/O Remote Protocol Extension . . . . . . . . . . . . . . . . . . . . . . . . D.14.1 File-I/O Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.2 Protocol Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.3 The F Request Packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.4 The F Reply Packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.5 The ‘Ctrl-C’ Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.6 Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.7 List of Supported Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lseek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . unlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . stat/fstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . gettimeofday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . isatty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.8 Protocol-specific Representation of Datatypes . . . . . . . . . . Integral Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pointer Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Memory Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . struct stat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . struct timeval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.9 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Open Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . mode t Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Errno Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 404 405 413 415 428 428 428 428 428 428 429 432 433 434 434 436 436 437 437 437 438 438 439 439 439 440 441 441 441 442 442 443 443 444 444 445 445 445 445 446 446 447 447 447 447 447 xi Lseek Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.14.10 File-I/O Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.15 Library List Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.16 Memory Map Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.17 Thread List Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 448 448 449 450 451 Appendix E The GDB Agent Expression Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 E.1 E.2 E.3 E.4 E.5 General Bytecode Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bytecode Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Agent Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Varying Target Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rationale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453 455 459 460 460 Appendix F Trace File Format . . . . . . . . . . . . . . . 465 Appendix G Target Descriptions . . . . . . . . . . . . . 467 G.1 Retrieving Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2 Target Description Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2.1 Inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2.3 OS ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2.4 Compatible Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2.5 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2.6 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.2.7 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.3 Predefined Target Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.4 Standard Target Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.4.1 ARM Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.4.2 i386 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.4.3 MIPS Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.4.4 M68K Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.4.5 PowerPC Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 468 468 468 469 469 469 469 470 471 471 472 472 473 473 473 Appendix H Operating System Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 H.1 Process list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 Appendix I GNU GENERAL PUBLIC LICENSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477 Appendix J GNU Free Documentation License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 J.1 ADDENDUM: How to use this License for your documents . . . 495 xii Debugging

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值