Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

tracking down Segmentation Faults

user20090419
Beginner
387 Views
Is there an icpc compiler flag (maybe -d or -g?) that would enable the debugger, so that if the code seg faults, it would print out the line / class where it happened? I don't need anything complicated like being able to step through the code, look up variable values in ddd, look for memory leaks etc. Having the debugger track all that makes the code run much slower. So I just want it to get to the seg fault as quickly as possible and print out where it happened.
0 Kudos
3 Replies
dpeterc
Beginner
387 Views

I don't know of any such switch.

In my experience, ddd does that quite sasisfactory without running much slower, just at the speed of normal debug code.

Just do Status > Backtrace

in DDD after the crash, if it does not position you automatically to the line after the crash.

In some complicated cases, valgrind also helps pinpoint the error, as the error may be caused by trashing of memory prior to actual core dump. This indeed runs many times slower.

0 Kudos
user20090419
Beginner
387 Views

Thank you. Can I use ddd with icpc, or I need to go back to g++? How do I use ddd with icpc?

0 Kudos
dpeterc
Beginner
387 Views

Same way as you would with any other compiler. Compile your program with switch

-g

and then run it with ddd by

ddd executable_name

Intel compiler also comes wiht idb, which can be used in the same way.

idb exectuable_name

I perfer ddd, since it can nicely graphically display the data structures.

0 Kudos
Reply