La depuración remota
de Alice y Bob deben utilizar la depuración remota. Bob inicia gdbserver:
[email protected]:/home/bob$ gdbserver :2345 ./helloworld
Y Alice se conecta a él:
[email protected]:/home/alice$ gdb
[...]
(gdb) file helloworld
Reading symbols from /home/alice/helloworld...done.
(gdb) target remote :2345
Remote debugging using :2345
[...]
0x00007fbdc6329af0 in _start() from /lib64/ld-linux-x86-64.so.2
depuración remota con rutas absolutas
Esto funciona en este caso sencillo. Sin embargo, un poco más de sofisticación se requried cuando Bob utiliza rutas absolutas para sus bibliotecas compartidas:
[email protected]:/home/bob$ ls
helloworld libmylib.so
[email protected]:/home/bob$ LD_LIBRARY_PATH=/home/bob gdbserver :2345 ./helloworld
Ahora, Alice no puede encontrar la biblioteca compartida:
[email protected]:/home/alice$ gdb
[...]
(gdb) file helloworld
Reading symbols from /home/alice/helloworld...done.
(gdb) target remote :2345
Remote debugging using :2345
[...]
(gdb) break helloWorld()
Breakpoint 1 at 0x400480
(gdb) c
Continuing.
Error while mapping shared library sections:
/home/bob/libmylib.so: No such file or directory.
Para solucionar esto, Alice crea un Portal carpeta raíz con enlaces a su encendido binarios:
[email protected]:/home/alice$ mkdir -p gdb-symbols/home/
[email protected]:/home/alice$ ln -s /home/alice gdb-symbols/home/bob
[email protected]:/home/alice$ ln -s /lib gdb-symbols/lib
[email protected]:/home/alice$ ln -s /lib64 gdb-symbols/lib64
[and so forth for every shared library that cannot be found...]
Y es ahora capaz de depurar con todos los símbolos cargados:
[email protected]:/home/alice$ gdb
[...]
(gdb) file helloworld
Reading symbols from /home/alice/helloworld...done.
(gdb) target remote :2345
Remote debugging using :2345
[...]
Reading symbols from /home/alice/gdb-symbols/home/bob/libmylib.so...done.
Loaded symbols from /home/alice/gdb-symbols/home/bob/libmylib.so
(gdb)
Felicitaciones por formular esta pregunta utilizando el meme Alice-Bob, lo hace muy comprensible y extremadamente fácil de responder bien. – parasietje