Actually, it's not that difficult. Get GCC to generate DWARF [debugging] information, and then use that to provide the back-references. (Reference: DWARF 3.0 spec, available at http://dwarfstd.org/doc/Dwarf3.pdf. See page 92.) This is how GDB does the same.
The output is a little weird (I've had it execute line 56 before line 55, for example) and you do have to be careful, as not all lines translate directly. But it would be at least be a nice starting point. There are even some nice libraries out there that parse this information!
EDIT: Hmm, I just noticed that the source is on Github. If I get some time this weekend I'll try adding support for this.
The output is a little weird (I've had it execute line 56 before line 55, for example) and you do have to be careful, as not all lines translate directly. But it would be at least be a nice starting point. There are even some nice libraries out there that parse this information!
EDIT: Hmm, I just noticed that the source is on Github. If I get some time this weekend I'll try adding support for this.