I figured out what was wrong. No debug information was generated. This is because the optimizer realizes that int foo(); is never called and has no declaration, and as such does not need debug info. Changing the function to
int foo(){
int x=5;
}
is enough to generate debug info.