whereas I expect it to display the current line, for example
On many platforms, such as ELF , the compiler writes both the path to the source ( test/test.c in your case) and the compilation directory, allowing GDB to map the source no matter what directory it calls it to.
But many platforms are less flexible and do not have a place to write the compilation directory. On such platforms (for example, AIX), you must either run GDB in the compilation directory, or specify where to look for sources using the directory command.
source share