LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-17-2009, 04:50 AM   #1
saintiwara
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
debugging gcc


Hi,

I am new to using LINUX and am only dabbling to learn more.i have been trying to understand the working of gcc.However, I am finding it rather tough to understand it.I want to know if there is any way in which I can debug the gcc source files themselves and come to know of the flows in the compilation of a particular program.What i mean is when i compile any program, would it be possible to debug all the gcc source code that effectively execute to compile my program.If there is a way,Please be a little bit elaborate in the way to do that coz I am really new to this.

Thanks in advance,
Bye
--sandy
 
Old 12-17-2009, 05:25 AM   #2
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
gcc is a compiler it pretty much does whatever its told to do. When you compile a program normally you use make which will call gcc with different options to enable either building libraries or executable. As far as what programs that gcc uses its dependent on what type of source file you are attempting to compile. Gcc can compile alot of different languages. First place you may wanna start is the gcc webpage or maybe the man page.
 
Old 12-17-2009, 06:47 AM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Quote:
Originally Posted by saintiwara View Post
What i mean is when i compile any program, would it be possible to debug all the gcc source code that effectively execute to compile my program.If there is a way,Please be a little bit elaborate in the way to do that coz I am really new to this.
Sounds like you want to run gcc under a debugger and step though each line as gcc runs. Ouch, not my I idea of fun.

If you really want to do this you can, install gcc with debug symbols (perhaps your distro has it, or maybe you can compile it), install gdb (gnu debuger), write an "Hello, world!" program (start with c), set a break point at the first line of main() in gcc, and step through the compilation of helloworld.c

hmm, that was a long sentence.

Better still, just read the source of gcc. It shouldn't take too long ;-)

Cheers,

Evo2.
 
1 members found this post helpful.
Old 12-17-2009, 07:39 AM   #4
AngTheo789
Member
 
Registered: Sep 2009
Posts: 110

Rep: Reputation: 24
GCC is extremely complex by all means. If your new to Linux, UNIX or debugging in general, then please look for a much simpler target. If it has to be a compiler that you want to investigate, then rather start with some textbooks on compiler-building, or get some other opensource compiler (maybe some BASIC or Pascal compiler) to find out it's inner workings. Starting with GCC will probably lead to nowhere.
 
Old 12-17-2009, 11:52 PM   #5
saintiwara
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by evo2 View Post
Sounds like you want to run gcc under a debugger and step though each line as gcc runs. Ouch, not my I idea of fun.
Thats exactly What I want

Quote:
If you really want to do this you can, install gcc with debug symbols (perhaps your distro has it, or maybe you can compile it), install gdb (gnu debuger), write an "Hello, world!" program (start with c), set a break point at the first line of main() in gcc, and step through the compilation of helloworld.c
I have gcc installed(by that I mean the one that gets installed automatically when fedora is installed).And I have also got gdb installed.
However, even if I write a helloworld.c How would I be able to step into gcc's code?

Quote:
hmm, that was a long sentence.

Better still, just read the source of gcc. It shouldn't take too long ;-)

I think you are right.But I face a problem with this.Its hard to understand the source reading any random file from the gcc source coz there are too many dependencies of other files involved.And if i type in

gcc helloworld.c

i dont know which will be the first file that will be invoked in gcc.so where do i start reading and understanding the source from?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Effective debugging or improving ones debugging skills Ajit Gunge Programming 3 05-22-2009 09:29 AM
Live "Educational" Distro with coding & debugging tools wanted [GCC/DDD/valgrind] etc RipClaw Linux - Distributions 2 07-14-2008 01:37 PM
Difference between kernel - debugging and application debugging topworld Linux - Software 2 03-30-2006 12:50 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM
gcc macroses for automating debugging shy Programming 0 12-20-2004 02:35 PM


All times are GMT -5. The time now is 02:39 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration