GDB setting a breakpoint in a strange file

I'm learning GDB, and trying to step through my singleton program.

Now, I would expect that break 6 would set the breakpoint in a file specified at gdb start (namely singleton.exe) but instead I get this:

1
2
3
$ gdb singleton.exe
(gdb) break 6
Breakpoint 1 at 0x4006e0: file ../sysdeps/x86_64/elf/start.S, line 6.


And I have no idea why is that so :(

Heres the file where I want to put the breakpoint in:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include "singleton.h"

int main()
{
    Singleton& SI = Singleton::GetInstance(); //6th line - desired beakpoint

    SI.SetValue(3);
    std::cout << SI.GetValue() << "\n";

    return 0;
}


The executable was created with:
 
g++ -g -o singleton.exe singleton.o singleton_main.o


singleton.o contains definitions of functions declared in a header file, and singleton_main.o was generated from the code I posted above

I'd really appreciate any help

Edit:
Seems like the problem lied in compilation of object files. They also had to have the -g option enabled, like
g++ -g -c -o singleton_main.o singleton_main.cpp
Last edited on
You are probably being bitten by compiler optimization -- add -O0 (that's capital 'O' followed by a zero) to your options.
Topic archived. No new replies allowed.