There is no (obvious) documented way to get a symtab_and_line object given an arbitrary address. A function gdb.sal_for_pc() similar to gdb.block_for_pc() would be nice.
you can get a symtab_and_line object for an arbitrary address by using the decode_line function (see the Basic Python section of the manual) and passing in "*0xaddr" as the argument. e.g. (gdb) python print gdb.decode_line("*" + str(gdb.selected_frame().find_sal().pc)) (None, (<gdb.Symtab_and_line object at 0x7f55269cbe10>,)) (gdb) I've suggested adding a reference to decode_line from the gdb.symtab_and_line section. If you have any recommendations how to further clarify the manual please let us know.
I think a direct API would be good to have.
I was looking and found gdb.find_pc_line, which is exactly this.