0

I am developing an application for the beaglebone black which I cross compile using arm gcc compiler then port on the compiled binary file to the beaglebone black using scp command and run there on the board.

This application runs perfectly for some period of time and later results into segmentation fault. After doing some research I found that using gdb we can debug it, but I am facing problem of how to install the gdb into the board or what are the other ways to debug it using gdbserver from the host machine.

Kindly help me to debug the segmentation fault

1

First, you need a cross gdb. To do this, download the gdb source, unpack it, run ./configure --target=arm-linux-gnueabi, and then the usual make; make install dance. You should now have a gdb-linux-gnueabi installed. Run it. On your beaglebone, run gdbserver 0.0.0.0:1234. On the machine where you have your cross-gdb running, give it the command target remote 192.168.12.34:1234, substituting the IP address of your BBB. you can now use the gdb session as usual.

Some notes though:

  1. You shouldn't try to start the process, you should use the 'continue' (or 'c') command instead.
  2. If you kill the debugged process, gdbserver will exit. If you want to run another session, just restart it; gdb will remember breakpoints etc. You do need to issue the target remote command again, however.
  3. Gdbserver does not send an image of the debugged program to gdb; you have to do that yourself. Personally, I think the easiest way to do that is to use NFS.
  • Hi Wouter thanks for your help i will do this and let you know if i face any problems further – Gangadhar Sep 30 '15 at 5:48
  • Hi Wouter can i use gdb-multiarch compared to gdb-linux-gnueabi? – Gangadhar Oct 5 '15 at 5:31
0

I have Got the below response from the target 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                                                          

This is the response from the ubuntu system i am using

(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) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.