I have to debug a segfault in my C++ program using Code::Blocks.
Unfortunately, the stack trace isn't showing correctly, instead I see ?? ()
Here is a minimal example:
#include <iostream>
using namespace std;
int main()
{
int *plop;
cout << *plop << endl;
return 0;
}
The debugger says:
Program received signal SIGSEGV, Segmentation fault. In ?? () ()
But I was expecting something more useful like "In main ()"
EDIT: here is the build log, if it helps
-------------- Build: Debug in tests (compiler: GNU GCC Compiler)---------------
g++.exe -Wall -fexceptions -g -O -pedantic -Wextra -std=c++0x -std=c++14 -c D:\C\tests\main.cpp -o obj\Debug\main.o
D:\C\tests\main.cpp: In function 'int main()':
D:\C\tests\main.cpp:8:14: warning: 'plop' is used uninitialized in this function [-Wuninitialized]
cout << *plop << endl;
^
g++.exe -o bin\tests.exe obj\Debug\main.o -s
Output file is bin\tests.exe with size 542.00 KB
2nd EDIT: finally solved :)
For those who came here by google : strip symbols -s
and Optimizer -O
compiler options were checked in my case, theses options conflicts with -g
as they removes debug symbols in compiled code.
Thanks for everyone for answering