Disclaimer: this is for GDB on GNU/Linux, working with ELF files. The GDB manual doesn't say that the commands I show here are Linux-specific, but I don't know whether they'll produce similar results on Windows.
GDB's info symbol command, given an address, will output the closest symbol (and offset), filename and section of the object file corresponding to that address.
Here's an example where the main program accesses the foo function from two different shared libraries. foo just calls lseek, which will be a convenient spot to place a breakpoint because it isn't used anywhere else in the program, including the dl functions.
$ nl -ba a.c
1 #include <sys/types.h>
2 #include <unistd.h>
3 void foo() {
4 lseek(0, 0, SEEK_CUR);
5 }
$ cc -fpic -shared -g a.c -o a.so
$ nl -ba b.c
1 #include <sys/types.h>
2 #include <unistd.h>
3 void foo() {
4 lseek(0, 0, SEEK_CUR);
5 }
$ cc -fpic -shared -g b.c -o b.so
$ nl -ba main.c
1 #include <dlfcn.h>
2 #include <unistd.h>
3 #include <stdio.h>
4 int main() {
5 void *a = dlopen("./a.so", RTLD_LAZY|RTLD_LOCAL);
6 void *b = dlopen("./b.so", RTLD_LAZY|RTLD_LOCAL);
7
8 void (*afoo)() = (void (*)()) dlsym(a, "foo");
9 void (*bfoo)() = (void (*)()) dlsym(b, "foo");
10
11 (*afoo)();
12 (*bfoo)();
13 }
$ cc main.c -g -ldl -o main
Here's the GDB session. The bt command will show the PC address of each frame, as well as the name of the source file, since everything was compiled with GCC's -g option. The info sym command will show the name of the executable or object file.
$ gdb -q ./main
(gdb) start
Temporary breakpoint 1, main () at main.c:5
5 void *a = dlopen("./a.so", RTLD_LAZY|RTLD_LOCAL);
(gdb) b lseek
Breakpoint 2 at 0x7ffffef38d30: file ../sysdeps/unix/syscall-template.S, line 84.
(gdb) c
Continuing.
Breakpoint 2, lseek64 () at ../sysdeps/unix/syscall-template.S:84
84 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) bt
#0 lseek64 () at ../sysdeps/unix/syscall-template.S:84
#1 0x00007ffffec40688 in foo () at a.c:4
#2 0x000000000800078b in main () at main.c:11
(gdb) info sym 0x00007ffffec40688
foo + 24 in section .text of ./a.so
(gdb) c
Continuing.
Breakpoint 2, lseek64 () at ../sysdeps/unix/syscall-template.S:84
84 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) bt
#0 lseek64 () at ../sysdeps/unix/syscall-template.S:84
#1 0x00007ffffea30688 in foo () at b.c:4
#2 0x0000000008000796 in main () at main.c:12
(gdb) info sym 0x00007ffffea30688
foo + 24 in section .text of ./b.so
btandwherebacktracethere are examples that show the source file likebuiltin.c:993. I am looking into options forbacktraceand can't find the one needed to show the binary file name