Setup apport
$ cd ~/.config && mkdir apport && cd apport && touch settings ~/.config/apport$ printf "[main]\nunpackaged=true\n" >> settings
Source code
class Player { public: enum PlayerState { STOPPED, PLAYING, PAUSED }; Player() : m_State(STOPPED) {} void play() { m_State = PLAYING; } void paused() { m_State = PAUSED; } void stop() { m_State = STOPPED; } private: PlayerState m_State; }; int main() { Player* player; player->play(); return 0; }
Coredump analysis
$ g++ main.cpp -g $ ./a.out Segmentation fault (core dumped) $ apport-unpack /var/crash/<core_dump> <dest_dir> $ gdb a.out <dest_dir>/CoreDump Core was generated by `./a.out'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00000000004004fe in Player::play (this=0x0) at main.cpp:9 9 void play() { m_State = PLAYING; } (gdb) bt #0 0x00000000004004fe in Player::play (this=0x0) at player.cpp:11 #1 0x00000000004004ea in main () at player.cpp:21 (gdb) up (gdb) info locals player = 0x0 (gdb) p player $1 = (Player *) 0x0 (gdb) p *player Cannot access memory at address 0x0
Issue: player hasn’t been initialized before calling play().