see compiler generated code

Discussion in 'C++' started by mkorobko@yahoo.com, Apr 22, 2009.

  1. Guest

    I was wondering if there is a way to see the source code generated by
    compiler - anything that compiler inserts such as constructors,
    destructors, vptr, etc . Looking at this can help to learn.
    , Apr 22, 2009
    #1
    1. Advertising

  2. Phlip Guest

    > I was wondering if there is a way to see the source code generated by
    > compiler - anything that compiler inserts such as constructors,
    > destructors, vptr, etc . Looking at this can help to learn.


    This is one of those questions where you will also get good answers from the
    forum covering your own compiler.

    I would...

    - debug the code and step into each method
    - debug with the disassembly turned on, so you can see the opcodes
    - use cfront, IIRC, to turn the C++ into C, with all the C++ features
    hanging out
    - debug that!
    Phlip, Apr 22, 2009
    #2
    1. Advertising

  3. Guest

    On Apr 22, 12:51 pm, "Phlip" <> wrote:
    > > I was wondering if there is a way to see the source code generated by
    > > compiler - anything that compiler inserts such as constructors,
    > > destructors, vptr, etc . Looking at this can help to learn.

    >
    > This is one of those questions where you will also get good answers from the
    > forum covering your own compiler.
    >
    > I would...
    >
    >  - debug the code and step into each method
    >  - debug with the disassembly turned on, so you can see the opcodes
    >  - use cfront, IIRC, to turn the C++ into C, with all the C++ features
    > hanging out
    >  - debug that!


    Thank you.
    , Apr 22, 2009
    #3
  4. Phlip Guest

    >>>> - use cfront, IIRC

    >>> Where exactly would one obtain a copy of cfront?

    >>
    >> Google is your friend!

    >
    > It was a rhetorical question.


    http://www.google.com/search?q=IIRC
    Phlip, Apr 22, 2009
    #4
  5. On Apr 22, 6:41 pm, wrote:
    > I was wondering if there is a way to see the source code generated by
    > compiler - anything that compiler inserts such as constructors,
    > destructors, vptr, etc . Looking at this can help to learn.


    No, you can't obtain any source code for the compiler-generated parts
    of the program, because the compiler does not create source code for
    that.
    The best you can get is to ask the compiler to output (annotated)
    assembly code, but be aware that optimisations can make it very hard
    to recognise your own code in the produced assembly.

    Bart v Ingen Schenau
    Bart van Ingen Schenau, Apr 23, 2009
    #5
  6. Guest

    On Apr 23, 3:23 am, Bart van Ingen Schenau
    <> wrote:
    > On Apr 22, 6:41 pm, wrote:
    >
    > > I was wondering if there is a way to see the source code generated by
    > > compiler - anything that compiler inserts such as constructors,
    > > destructors, vptr, etc . Looking at this can help to learn.

    >
    > No, you can't obtain any source code for the compiler-generated parts
    > of the program, because the compiler does not create source code for
    > that.
    > The best you can get is to ask the compiler to output (annotated)
    > assembly code, but be aware that optimisations can make it very hard
    > to recognise your own code in the produced assembly.
    >
    > Bart v Ingen Schenau


    Thanks everyone for your replies. It was helpful.
    , Apr 23, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip
    Replies:
    3
    Views:
    958
    Tony Morris
    Feb 9, 2004
  2. David Wake
    Replies:
    5
    Views:
    647
    Chris Uppal
    Feb 11, 2005
  3. Steve Kershaw
    Replies:
    1
    Views:
    343
    Brennan Stehling
    Sep 26, 2006
  4. joshc
    Replies:
    14
    Views:
    775
    Keith Thompson
    Jan 14, 2005
  5. Michel Firholz
    Replies:
    3
    Views:
    76
    Michael Winter
    Aug 18, 2006
Loading...

Share This Page