LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-17-2011, 08:59 AM   #1
chogall
LQ Newbie
 
Registered: Dec 2010
Posts: 5

Rep: Reputation: 0
GDB - How to set breakpoints in files located outside the current dir


Hi !

I'm using GDB to debug a program and the thing is, there are many files in many different folders.

So I did start gdb and then I wrote :

Code:
(gdb) break ../../a_folder/another_folder/my_file.h
And it says :

Quote:
No source file named ../../a_folder/another_folder/my_file.h.
The path is correct, I checked it a million of times. Then I tried with the absolute path which is from the home directory. So something like :

Code:
(gdb) break ~/project/blabla/a_folder/another_folder/my_file.h
And this time I got :

Quote:
Can't find member of namespace, class, struct, or union named "~/project/blabla/a_folder/another_folder/my_file.h"
Hint: try '~/project/blabla/a_folder/another_folder/my_file.h'<TAB> or '~/project/blabla/a_folder/another_folder/my_file.h'<ESC-?>
(Note leading single quote.)

Does anyone know the reason ? And how to solve this ?

The option -g is set in my compiling options.

Thanks!

Last edited by chogall; 02-17-2011 at 09:00 AM.
 
Old 02-17-2011, 10:10 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
So, to start Gdb you must have compiled a specific program something like this:
Code:
gcc -Wall -Wextra -g myProg.c
Then run gdb as follows:
Code:
gdb a.out
Now you can set the breakpoints pertaining to all functions in THIS executable.
So the files being in different folders is not a problem, but the function you
want to debug being in different executable IS.
 
Old 02-17-2011, 03:25 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
You can tell gdb where to find the source files: Source Path.

A break point needs to be set at a specific line, you only gave a file name: Specify Location.
 
  


Reply



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
breakpoints in gdb ashlesha Programming 3 06-05-2015 02:45 PM
how to create a driver makefile which uses header files outside current dir? netskink Linux - Kernel 5 05-21-2009 10:35 AM
GDB debugger breakpoints cleopard Programming 1 05-07-2008 03:15 PM
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM
gdb breakpoints cant find source file AM1SHFURN1TURE Programming 4 01-14-2006 01:10 PM

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

All times are GMT -5. The time now is 10:36 PM.

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