0

Say I have a tiny C++ or C application which allocates some memory. I'd like to instruct the program to use the GCC source code which I have manually downloaded, so that I can step in to new() and malloc().

I understand it'd be terribly difficult to step in to the actual OS copy of the code, but after doing some digging around I believe it is possible if I download a copy of the GCC source code (which I have done) and something regarding installing "symbols"???

Would somebody be able to advise me what I need to do once I have downloaded a copy of the GCC source code so that my C++/C application uses the downloaded copy of the GCC code, so that I can debug/step in to the C code?

UPDATE: I think this is what I require:

http://ubuntuforums.org/showthread.php?t=1374829&p=8831200#post8831200

**One question, how would I complete the "compile the source code" stage, mentioned in the above link?

intrigued_66
  • 16,082
  • 51
  • 118
  • 189
  • 11
    `malloc` is not in `gcc` code but in the `libc` code. – ouah Dec 15 '13 at 22:53
  • 1
    As ouah says, `gcc` code isn't relevant. But maybe this question will help?http://stackoverflow.com/questions/10000335/how-to-use-debug-version-of-libc – Roddy Dec 15 '13 at 22:56
  • 1
    the "actual OS copy" of the memory allocation functions are system calls called either brk(), sbrk(), or mmap() in Linux or the VirtualAlloc() or HeapAlloc(). malloc()/new exists only as part of the C/C++ standard library, which if you use gcc is usually in glibc or in Windows it's usually msvcrt. These system calls have very different semantics than malloc/new calls. – Lie Ryan Dec 15 '13 at 23:22
  • Ok guys, if we take Linux- is there any way I could so that I can step-in to the libc code when called from a C++ application? – intrigued_66 Dec 16 '13 at 02:47
  • @Roddy ok so on Linux I can use sudo apt-get install libc6-dbg to install the debug symbols for libc. What else would I need to do? Assuming I was debugging in Eclipse is there anything I would need to tell Eclipse about? – intrigued_66 Dec 16 '13 at 02:54
  • @Roddy forgot to include I will also need to set LD_LIBRARY_PATH – intrigued_66 Dec 16 '13 at 02:57
  • Now that you know what you need to be debugging (glibc) - have you tried following online instructions, e.g. http://sourceware.org/glibc/wiki/Debugging/Development_Debugging ? – Tony Delroy Dec 16 '13 at 07:26

0 Answers0