Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to let eclipse cdt show runtime error (e.g. segmentation fault)

I develop and run C++ program in Eclipse CDT on Linux.

The problem is that Eclipse CDT does't show any runtime error message (e.g. segmentation fault) in console, while I can get such error message when running program directly with command line.

like image 353
rnd_nr_gen Avatar asked Sep 21 '10 13:09

rnd_nr_gen


People also ask

Is segmentation fault a runtime error?

The segmentation error is one of the runtime error, that is caused because of the memory access violation, like accessing invalid array index, pointing some restricted address etc. In this article, we will see how to detect this type of error using the GDB tool.

How do you check for segmentation faults?

Use debuggers to diagnose segfaults Start your debugger with the command gdb core , and then use the backtrace command to see where the program was when it crashed. This simple trick will allow you to focus on that part of the code.


1 Answers

Hello
You could try to modify the run configuration like this

  • tab 'Main' > Application = /bin/sh
  • tab 'Arguments' > 'Program arguments' = -c "Debug/name_of_executable arg0 arg1 ... 2> /dev/stdout"

(replace "arg0 arg1 ..." with your program arguments, if any)
The eclipse console will output both stdout, stderr and the segmentation fault message (prefixed with "/bin/sh: line 1 ...")
note : I used this solution on an older release of eclipse for which the symptoms are the same.

like image 63
Francois Avatar answered Oct 08 '22 14:10

Francois