Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

core dump

saridsarid Posts: 3Member
How do I get a core dump with the g++ compiler (linix)? I need a core dump to be able to continue with what I am working with. I want to be able to gdb the core file. Can you force a core dump on segmentation faults or can you make it happen automatically on Segmentation faults?

Thanks a million!

Comments

  • GiantGiant Posts: 225Member
    You are having problems creating a core, whereas when I program I seem to have problems not having one. How unfair.

    The easiest way to create cores si to use bad pointers.
    The following should work

    [code]
    #include

    struct temp {
    int value;
    };

    int main()
    {
    struct temp* one;
    one->value = 6;
    return 0;
    }
    [/code]

    Enjoy!!!


    The Giant
    Member of the Stupid Coders
    http://www.stupidcoders.cjb.net

    "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." --Albert Einstein

  • blitzblitz Posts: 620Member
    : How do I get a core dump with the g++ compiler (linix)? I need a core dump to be able to continue with what I am working with. I want to be able to gdb the core file. Can you force a core dump on segmentation faults or can you make it happen automatically on Segmentation faults?
    :
    : Thanks a million!
    :

    here's my favourite :D
    [code]
    *(int *)0 = 0;
    [/code]
  • Eric TetzEric Tetz Posts: 2,141Member
    : How do I get a core dump with the g++ compiler (linix)? I need a core dump to be able to continue with what I am working with. I want to be able to gdb the core file.

    Not sure what you're after.. but you can force an app to core dump by sending it an abort signal:

    kill -SIGABRT pid

    Of course, you can attach gdb to a process while it's running, so you don't need really need to kill it.

    Cheers,
    Eric
  • paladinpaladin Posts: 97Member
    [b][red]This message was edited by the paladin at 2002-2-12 10:35:49[/red][/b][hr]
    : How do I get a core dump with the g++ compiler (linix)? I need a core dump to be able to continue with what I am working with. I want to be able to gdb the core file. Can you force a core dump on segmentation faults or can you make it happen automatically on Segmentation faults?
    :
    : Thanks a million!
    :
    In order to get a core dump, you have to specifically compile your code using gdb options. Type man gcc for specifics if you're using LINUX/UNIX/BSD. I do not know about the g++ compiler. You need to use the GNU compiler (gcc) in order to use GNU gdb.


  • GiantGiant Posts: 225Member
    [b][red]This message was edited by the Giant at 2002-2-13 2:15:32[/red][/b][hr]
    >>In order to get a core dump, you have to specifically compile your code using >>gdb options. Type man gcc for specifics if you're using >>LINUX/UNIX/BSD. I do >>not know about the g++ compiler. You need to >>use the GNU compiler (gcc) >>in order to use GNU gdb.

    Thats not exactly right. You can always get a core dump if you do some stupid stuff in your code, like the stuff mentioned in the previous mails, however to read it correctly with gdb you have to compile it with an option. I think it is as simple as putting -g into the command line compile command.
    The Giant
    Member of the Stupid Coders
    http://www.stupidcoders.cjb.net

    "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." --Albert Einstein







  • paladinpaladin Posts: 97Member
    : [b][red]This message was edited by the Giant at 2002-2-13 2:15:32[/red][/b][hr]
    : >>In order to get a core dump, you have to specifically compile your code using >>gdb options. Type man gcc for specifics if you're using >>LINUX/UNIX/BSD. I do >>not know about the g++ compiler. You need to >>use the GNU compiler (gcc) >>in order to use GNU gdb.
    :
    : Thats not exactly right. You can always get a core dump if you do some stupid stuff in your code, like the stuff mentioned in the previous mails, however to read it correctly with gdb you have to compile it with an option. I think it is as simple as putting -g into the command line compile command.
    : The Giant
    : Member of the Stupid Coders
    : http://www.stupidcoders.cjb.net
    :
    : "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." --Albert Einstein
    :
    If you do not use the compile option in gcc (for GNU gdb), how can you otherwise use the core dump. There must be some other (i.e. non-GNU) methods of utilizing the data. Also, can you tell me what data is included in a core dump. I myself have not used gdb as of yet, although I do have the manual and have attempted to make sense of it. I could really use a good "How to...." for gdb. I have not taken assembler and it looks like a pre-requisite for gdb.

    Thanks......

    Paladin
  • Eric TetzEric Tetz Posts: 2,141Member
    : If you do not use the compile option in gcc (for GNU gdb), how can you otherwise use the core dump. There must be some other (i.e. non-GNU) methods of utilizing the data. Also, can you tell me what data is included in a core dump. I myself have not used gdb as of yet, although I do have the manual and have attempted to make sense of it. I could really use a good "How to...." for gdb. I have not taken assembler and it looks like a pre-requisite for gdb.

    -g means "include debugging information".

    When your code is compiled, the names of types, functions and variables are all stripped away; converted to memory addresses, stack offsets, register references, etc. When you use -g, the compiler stores information in the executable that tells the debugger the source file and line number associated with a block of machine code, the names of your functions and variables, etc. You [italic]can[/italic] debug without this stuff, but it's [italic]much[/italic] harder. You will, at the very least, need to know assembler.

    BTW: there are several graphical front-ends for gdb that are much easier to use. I used ddd (which I highly recommend). I've also used xxgdb, which I think comes with most Linux distributions.

    Cheers,
    Eric
Sign In or Register to comment.