使用定制的 Linux 内核在 beaglebone black 中安装 gdb

使用定制的 Linux 内核在 beaglebone black 中安装 gdb

我正在为 beaglebone black 开发一个应用程序,我使用 arm gcc 编译器进行交叉编译,然后使用scp命令将编译后的二进制文件移植到 beaglebone black 并在板上运行。

该应用程序在一段时间内完美运行,后来导致分段错误。经过一些研究后,我发现使用gdb我们可以对其进行调试,但我面临着如何将其安装gdb到板上或使用gdbserver主机进行调试的其他方法是什么的问题。

请帮我调试分段错误

答案1

首先,你需要一个交叉gdb。为此,请下载 gdb 源代码,解压它,运行./configure --target=arm-linux-gnueabi,然后进行通常的make; make install操作。您现在应该已经安装了gdb-linux-gnueabi。运行。在你的 beaglebone 上运行gdbserver 0.0.0.0:1234.在运行 cross-gdb 的机器上,输入命​​令target remote 192.168.12.34:1234,替换您的 BBB 的 IP 地址。您现在可以像往常一样使用 gdb 会话。

但有一些注意事项:

  1. 您不应该尝试启动该过程,而应该使用“继续”(或“c”)命令。
  2. 如果杀死被调试的进程,gdbserver将会退出。如果您想运行另一个会话,只需重新启动它即可; gdb 会记住断点等。但是,您确实需要target remote再次发出该命令。
  3. Gdbserver不会将被调试程序的镜像发送给gdb;你必须自己做。就我个人而言,我认为最简单的方法是使用 NFS。

答案2

我收到了目标 beaglebone black 的以下回复

Remote debugging from host 192.168.1.1                                          
[getpkt: discarding char '+']                                                   
getpkt ("qSupported:multiprocess+;xmlRegisters=i386;qRelocInsn+");  [sending ac 
[sent ack]                                                                      
putpkt ("$PacketSize=3fff;QPassSignals+;QProgramSignals+;qXfer:libraries-svr4:r]
[received '+' (0x2b)]                                                           
getpkt ("QStartNoAckMode");  [sending ack]                                      
[sent ack]                                                                      
[noack mode enabled]                                                            
putpkt ("$OK#9a"); [noack mode]                                                 
[getpkt: discarding char '+']                                                   
getpkt ("Hgp0.0");  [no ack sent]                                               
putpkt ("$OK#9a"); [noack mode]                                                 
getpkt ("qXfer:features:read:target.xml:0,fff");  [no ack sent]                 
putpkt ("$l<?xml version="1.0"?>                                                
<!-- Copyright (C) 2009-2012 Free Software Foundation, Inc.                     

 *!Copying and distribution of this file, with or without modification,         
 *!are permitted in any medium without royalty provided the copyright           
 *!notice and this notice are preserved.  -->                                   

<!DOCTYPE target SYSTEM "gdb-target.dtd">                                       
<target>                                                                        
  <xi:include href="arm-core.xml"/>                                             
  <xi:include href="arm-vfpv3.xml"/>                                            
  <feature name="org.gnu.gdb.arm.neon"/>                                        
</target>                                                                       
#b0"); [noack mode]                                                             
getpkt ("qXfer:features:read:arm-core.xml:0,fff");  [no ack sent]               
putpkt ("$l<?xml version="1.0"?>                                                
<!-- Copyright (C) 2007-2012 Free Software Foundation, Inc.                     

 *!Copying and distribution of this file, with or without modification,         
 *!are permitted in any medium without royalty provided the copyright           
 *!notice and this notice are preserved.  -->                                   

<!DOCTYPE feature SYSTEM "gdb-target.dtd">                                      
<feature name="org.gnu.gdb.arm.core">                                           
  <reg name="r0" bitsize="32" type="uint32"/>                                   
  <reg name="r1" bitsize="32" type="uint32"/>                                   
  <reg name="r2" bitsize="32" type="uint32"/>                                   
  <reg name="r3" bitsize="32" type="uint32"/>                                   
  <reg name="r4" bitsize="32" type="uint32"/>                                   
  <reg name="r5" bitsize="32" type="uint32"/>                                   
  <reg name="r6" bitsize="32" type="uint32"/>                                   
  <reg name="r7" bitsize="32" type="uint32"/>                                   
  <reg name="r8" bitsize="32" type="uint32"/>                                   
  <reg name="r9" bitsize="32" type="uint32"/>                                   
  <reg name="r10" bitsize="32" type="uint32"/>                                  
  <reg name="r11" bitsize="32" type="uint32"/>                                  
  <reg name="r12" bitsize="32" type="uint32"/>                                  
  <reg name="sp" bitsize="32" type="data_ptr"/>                                 
  <reg name="lr" bitsize="32"/>                                                 
  <reg name="pc" bitsize="32" type="code_ptr"/>                                 

  <!-- The CPSR is register 25, rather than register 16, because                
 *" the FPA registers historically were placed between the PC                   
 *" and the CPSR in the "g" packet.  -->                                        
  <reg name="cpsr" bitsize="32" regnum="25"/>                                   
</feature>                                                                      
#13"); [noack mode]                                                             
getpkt ("qXfer:features:read:arm-vfpv3.xml:0,fff");  [no ack sent]              
putpkt ("$l<?xml version="1.0"?>                                                
<!-- Copyright (C) 2009-2012 Free Software Foundation, Inc.                     

 *!Copying and distribution of this file, with or without modification,         
 *!are permitted in any medium without royalty provided the copyright           
 *!notice and this notice are preserved.  -->                                   

<!DOCTYPE feature SYSTEM "gdb-target.dtd">                                      
<feature name="org.gnu.gdb.arm.vfp">                                            
  <reg name="d0" bitsize="64" type="ieee_double"/>                              
  <reg name="d1" bitsize="64" type="ieee_double"/>                              
  <reg name="d2" bitsize="64" type="ieee_double"/>                              
  <reg name="d3" bitsize="64" type="ieee_double"/>                              
  <reg name="d4" bitsize="64" type="ieee_double"/>                              
  <reg name="d5" bitsize="64" type="ieee_double"/>                              
  <reg name="d6" bitsize="64" type="ieee_double"/>                              
  <reg name="d7" bitsize="64" type="ieee_double"/>                              
  <reg name="d8" bitsize="64" type="ieee_double"/>                              
  <reg name="d9" bitsize="64" type="ieee_double"/>                              
  <reg name="d10" bitsize="64" type="ieee_double"/>                             
  <reg name="d11" bitsize="64" type="ieee_double"/>                             
  <reg name="d12" bitsize="64" type="ieee_double"/>                             
  <reg name="d13" bitsize="64" type="ieee_double"/>                             
  <reg name="d14" bitsize="64" type="ieee_double"/>                             
  <reg name="d15" bitsize="64" type="ieee_double"/>                             
  <reg name="d16" bitsize="64" type="ieee_double"/>                             
  <reg name="d17" bitsize="64" type="ieee_double"/>                             
  <reg name="d18" bitsize="64" type="ieee_double"/>                             
  <reg name="d19" bitsize="64" type="ieee_double"/>                             
  <reg name="d20" bitsize="64" type="ieee_double"/>                             
  <reg name="d21" bitsize="64" type="ieee_double"/>                             
  <reg name="d22" bitsize="64" type="ieee_double"/>                             
  <reg name="d23" bitsize="64" type="ieee_double"/>                             
  <reg name="d24" bitsize="64" type="ieee_double"/>                             
  <reg name="d25" bitsize="64" type="ieee_double"/>                             
  <reg name="d26" bitsize="64" type="ieee_double"/>                             
  <reg name="d27" bitsize="64" type="ieee_double"/>                             
  <reg name="d28" bitsize="64" type="ieee_double"/>                             
  <reg name="d29" bitsize="64" type="ieee_double"/>                             
  <reg name="d30" bitsize="64" type="ieee_double"/>                             
  <reg name="d31" bitsize="64" type="ieee_double"/>                             

  <reg name="fpscr" bitsize="32" type="int" group="float"/>                     
</feature>                                                                      
#cf"); [noack mode]                                                             
getpkt ("QNonStop:0");  [no ack sent]                                           
[all-stop mode enabled]                                                         
putpkt ("$OK#9a"); [noack mode]                                                 
getpkt ("?");  [no ack sent]                                                    
putpkt ("$T050b:0*"00;0d:10feffbe;0f:800c4648;thread:p533.533;core:0;#4f"); [no]
getpkt ("Hc-1");  [no ack sent]                                                 
putpkt ("$E01#a6"); [noack mode]                                                
getpkt ("qC");  [no ack sent]                                                   
putpkt ("$QCp533.533#68"); [noack mode]                                         
getpkt ("qAttached:533");  [no ack sent]                                        
putpkt ("$0#30"); [noack mode]                                                  
getpkt ("g");  [no ack sent]                                                    
putpkt ("$0*}0*"010feffbe0*"00800c464830*}0*}0*}0*}0*}0*F#f5"); [noack mode]    
readchar: Got EOF                                                               
[getpkt: discarding char '�']                                                   
Remote side has terminated connection.  GDBserver will reopen the connection.   
Listening on port 1234                                                          

这是我正在使用的ubuntu系统的响应

(gdb) target remote 192.168.1.2:1234
Remote debugging using 192.168.1.2:1234
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010feffbe00000000800c4648300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
(gdb) 

相关内容