LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-20-2016, 11:51 AM   #1
jessCPP
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Rep: Reputation: Disabled
gdb debug program compiled in another machine


Hi there!

I want to apologize if this question is very stupid.

I want to debug a program with 'gdb' and the program has been compiled using this instruction in 'gcc':

Code:
gcc -g test.c -o test
Then I copied the executable file to another machine, but gdb can not find the sources. This is the output when I try to set a break point:

Code:
Reading symbols from test...done.
(gdb) break test.c:7
Breakpoint 1 at 0x8048426: file test.c, line 7.
(gdb) start 
Temporary breakpoint 2 at 0x8048426: file test.c, line 7.
Starting program: /home/user/test 

Breakpoint 1, main () at test.c:7
7	test.c: No such file or directory.
Is there a way to see the source code of a program that has been compiled from another machine in gdb?

Or is it mandatory to have the source code in the same machine as gdb?

Thank you very much!
 
Old 03-20-2016, 03:43 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Use FTP, NFS, SMB, sftp or scp to transfer the source.

Last edited by NevemTeve; 03-20-2016 at 03:45 PM.
 
Old 03-20-2016, 07:23 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
In this case I'd put the source file on the same machine where you are trying to debug.

There are options for remote debugging using GDBServer, however if you are capable of running GDB directly on your test machine, then do so and also have the sources available right there versus leave them on the compile machine.

I'm not totally sure, but the argument I used is -ggdb versus just -g.
 
Old 03-21-2016, 02:16 AM   #4
jessCPP
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Hi!

Thank you very much for your response!

I think I will debug using gdb server, because I am not allowed to copy all the sources to the destination machine.

By the way, what is the difference between -ggdb and -g?
 
  


Reply

Tags
debug, debugging, gdb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gdb, debug with separate debug file and different source dir problem a4z Programming 5 10-17-2014 01:55 AM
LXer: How to debug a C/C++ program with GDB command-line debugger LXer Syndicated Linux News 0 09-30-2014 10:42 AM
[SOLVED] Not able to debug a library compiled with debug information gregorian Programming 6 10-29-2011 09:53 AM
cannot debug with gdb ufmale Programming 9 04-27-2009 05:21 PM
how can I debug the interactinve program with GDB bigapple Programming 1 08-03-2005 09:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration