📅 2014-Jul-16 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ eclipse, error, gdb ⬩ 📚 Archive
I was debugging C++ code using the Eclipse debugger. This uses the GDB debugger underneath. I had put a breakpoint inside a class method and was trying to step through that code. I was able to step over a few statements in the method, but on a particular statement that called
fgets, a standard C function, Eclipse threw up this error:
Can't find a source file at "/build/buildd/eglibc-2.19/libio/iofgets.c"
Using GDB directly to perform the above operations gave the same error, so it was the program actually throwing this error. I could understand this error if I wanted to step into
fgets. But, all I was doing was stepping over the call and yet it wanted the definition of this function!
In my haste, I had forgotten that the class method was defined in a header file. Many C++ projects these days include both the declaration and definition of a class in the header file itself. This was one such class.
Since I had to step through and debug this class, I manually pulled out the class method definitions into a C++ source file and separated it from the header file. After compiling these files, I was able to step through the code of the same class method without any mysterious errors.
Tried with: GDB 7.7, Eclipse 3.8.1 and Ubuntu 14.04