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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-17-2009, 04:50 AM
|
#1
|
LQ Newbie
Registered: Oct 2009
Posts: 2
Rep:
|
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
|
|
|
12-17-2009, 05:25 AM
|
#2
|
Senior Member
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537
Rep:
|
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.
|
|
|
12-17-2009, 06:47 AM
|
#3
|
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726
|
Quote:
Originally Posted by saintiwara
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.
|
12-17-2009, 07:39 AM
|
#4
|
Member
Registered: Sep 2009
Posts: 110
Rep:
|
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.
|
|
|
12-17-2009, 11:52 PM
|
#5
|
LQ Newbie
Registered: Oct 2009
Posts: 2
Original Poster
Rep:
|
Quote:
Originally Posted by evo2
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?
|
|
|
All times are GMT -5. The time now is 06:10 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|