play$ cat info-line-var.c int foo; int main () { return 0; } play$ gcc -g info-line-var.c play$ gdb a.out (gdb) info line foo Line 1 of "info-line-var.c" is at address 0x4004c4 <main> but contains no code. The line number and file name are correct, but the address is wrong, and printing "but contains no code" is kinda lame.
Why do you think the address is wrong? (gdb) help info line Core addresses of the code for a source line.
Ok, let's first establish whether it is legit to pass a variable name to "info line".