Gcc and Core dump

This is a discussion on Gcc and Core dump within the Linux General forums, part of the Linux Forums category; Hi all I am a C++ programmer, and very new in Linux and using gcc. When I am compiling my ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-11-2003
Sam
 
Posts: n/a
Default Gcc and Core dump

Hi all

I am a C++ programmer, and very new in Linux and using gcc. When I am
compiling my program, I am getting error and core dump. I was wondering if
there is any flag or some way in gcc that make it possible too see what the
error is, and where it is located. or some more information about the error.

Thanks in advance Sam




Reply With Quote
  #2 (permalink)  
Old 09-11-2003
Paul Black
 
Posts: n/a
Default Re: Gcc and Core dump

Sam wrote:
> Hi all
>
> I am a C++ programmer, and very new in Linux and using gcc. When I am
> compiling my program, I am getting error and core dump. I was wondering if
> there is any flag or some way in gcc that make it possible too see what the
> error is, and where it is located. or some more information about the error.


If you compile your code with the -g option (for debug), you can run the
program in a debugger (like ddd for example) and will show you where the
problem is. Alternatively, you can load the program into a debugger with
the core file and find out the state of the program at the point of failure.

Pual

Reply With Quote
  #3 (permalink)  
Old 09-11-2003
Dances With Crows
 
Posts: n/a
Default Re: Gcc and Core dump

On Thu, 11 Sep 2003 10:37:54 -0700, Sam staggered into the Black Sun and
said:
> I am a C++ programmer, and very new in Linux and using gcc. When I am
> compiling my program, I am getting error and core dump.


If you get an error and a core dump while you're *compiling* a program,
you've found a bug in gcc. You meant "I get an error and a core dump
when I *run* the program I've compiled," right?

> I was wondering if there is any flag or some way in gcc that make it
> possible too see what the error is, and where it is located. or some
> more information about the error.


gcc doesn't really deal with runtime errors. You need to pass gcc the
-g option to tell it to compile your program with additional debugging
information. Then when your program crashes and produces a core dump,
you need to load that core dump into a debugger. The "standard"
debugger is gdb, but you can also use xxgdb or something like kdevelop
(an interactive development environment similar to VC++.) You'd do
something like:

gcc -g -o myprogram myprogram.c
../myprogram
(Segmentation fault - core dumped)
gdb -s myprogram core
(gdb) list
(gdb) backtrace

....and you'll see a listing around the line where your program failed,
and a backtrace of all the previously called functions. There is
extensive online documentation for gdb; Google for "gdb tutorial". gdb
also integrates with Emacs rather well (hmm, if it integrates with vim
in similar ways, I'd be stylin' ....) HTH,

--
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin /
http://www.brainbench.com / "He is a rhythmic movement of the
-----------------------------/ penguins, is Tux." --MegaHAL
Reply With Quote
  #4 (permalink)  
Old 09-12-2003
Silviu Minut
 
Posts: n/a
Default Re: Gcc and Core dump

And, by the way, if you're writing C++ code, compile with g++.


On Thu, 11 Sep 2003 21:41:09 +0100, Paul Black wrote:

> Sam wrote:
>> Hi all
>>
>> I am a C++ programmer, and very new in Linux and using gcc. When I am
>> compiling my program, I am getting error and core dump. I was wondering if
>> there is any flag or some way in gcc that make it possible too see what the
>> error is, and where it is located. or some more information about the error.

>
> If you compile your code with the -g option (for debug), you can run the
> program in a debugger (like ddd for example) and will show you where the
> problem is. Alternatively, you can load the program into a debugger with
> the core file and find out the state of the program at the point of failure.
>
> Pual


Reply With Quote
  #5 (permalink)  
Old 09-12-2003
Vampire at Wicked Empire
 
Posts: n/a
Default Re: Gcc and Core dump

Dances With Crows wrote:
> On Thu, 11 Sep 2003 10:37:54 -0700, Sam staggered into the Black Sun and
> said:
>
>>I am a C++ programmer, and very new in Linux and using gcc. When I am
>>compiling my program, I am getting error and core dump.

>
>
> If you get an error and a core dump while you're *compiling* a program,
> you've found a bug in gcc.


That could also mean a hardware problem, especially DRAM.

You can find a DRAM tester here.
http://www.memtest86.com


--
My projects:
http://tcron.sourceforge.net
http://fftv.sourceforge.net
http://www.csie.nctu.edu.tw/~cp76/gcb

Reply With Quote
  #6 (permalink)  
Old 09-13-2003
Sam
 
Posts: n/a
Default Re: Gcc and Core dump

Thank you very much for your help every body

/Sam


"Vampire at Wicked Empire" <vampire001@localhost.localdomain> wrote in
message news:bjrisr$89o$1@news.seed.net.tw...
> Dances With Crows wrote:
> > On Thu, 11 Sep 2003 10:37:54 -0700, Sam staggered into the Black Sun and
> > said:
> >
> >>I am a C++ programmer, and very new in Linux and using gcc. When I am
> >>compiling my program, I am getting error and core dump.

> >
> >
> > If you get an error and a core dump while you're *compiling* a program,
> > you've found a bug in gcc.

>
> That could also mean a hardware problem, especially DRAM.
>
> You can find a DRAM tester here.
> http://www.memtest86.com
>
>
> --
> My projects:
> http://tcron.sourceforge.net
> http://fftv.sourceforge.net
> http://www.csie.nctu.edu.tw/~cp76/gcb
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:26 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0