Search code examples
eclipsegdbcross-compilinggdbserver

GDB crashes when trying to attach


I am trying to setup the gdb debugger in eclipse to attach to a remote program. Here is the setup that I am using:

For the development PC (dev), I am using Eclipse Mars on a Windows 7 PC. Eclipse is set to use the GCC/G++ cross compiler and gdb as the remote debugger. I am using Sourcery CodeBench Lite as the development tool in windows.

  dev> gdb --version
  dev> GNU gdb (Sourcery CodeBench Lite 2014.05-25) 7.7.50.20140217-cvs

The target PC is a RHEL 7, where I use gdbserver so that I can debug my application remotely.

  target> gdbserver --version
  target> GNU gdbserver (GDB) Red Hat Enterprise Linux 7.6.1-64.el7
       Copyright (C) 2013 Free Software Foundation, Inc.

I have two debug configuration in eclipse, one for remote debug and another for attaching to a remote program that is running in target PC. I have no problem debugging my program using the remote debug configuration, however, when I try to attach to the remote program, I get the following error: enter image description here

Here is how I set up my debugger to attach to a remote application:

enter image description here

enter image description here

I use the following gdbinit script:

 handle SIG34 nostop noprint pass
 set verbose on
 set sysroot 

I have also tried using the same GDB versions on both sides and got the same result. At this point, I am open to any suggestion!


Solution

  • Ok, So I think I got it working. The problem seems to be because of the old GDB version that I was using on the target PC. As I mentioned in my question, I was using GDB 7.6.1-64.el7. To update the GDB, I downloaded the latest source code from http://ftp.gnu.org/gnu/gdb/ . Remember to update both gdb and gdbserver. The gdbserver is provided in the download package. Here are the steps that I took after I put gdb archive in target/tmp :

    target_pc/tmp> gtar -xvf gdb-7.11.tar.gz
    target_pc/tmp> cd gdb-7.11 
    target_pc/tmp/gdb-7.11> ./configure
    target_pc/tmp/gdb-7.11> make 
    target_pc/tmpgdb-7.11> cd gdb/gdbserver 
    target_pc/tmpgdb-7.11/gdb/gdbserver> ./configure
    target_pc/tmpgdb-7.11/gdb/gdbserver> make
    

    after a successful built you can either use make install or copy the gdb and gdbserver binary and put it to the /usr/bin or /bin directory. Also you need to restart the gdbserver:

     /usr/bin/gdbserver --remote-debug --multi :8000 
    

    you can add this line to /etc/rc.local so that you start the gdbserver upon the linux boot.