在远程调试期间,当第二次调用调试会话时,gdbserver无法连接到gdb客户端

时间:2017-11-14 09:44:52

标签: debugging gdb gnu gdbserver linaro

为了调试已在远程目标上运行的应用程序(架构:arm-linux-gnueabihf),我使用的是Linaro工具链中的gdb:GNU gdb(Linaro_GDB-2017.05)7.12.1.20170417-git和目标,gdbserver (GNU gdbserver(GDB)7.12.1.20170417-git)。我在多模式下在远程目标端运行了gdbserver:'gdbserver --multi :.用于远程调试应用程序(myApp)的命令(已在远程目标上运行)在下面的gdb跟踪中突出显示。 调试完成后,我想从gdb中分离我的应用程序(myApp),因为我的应用程序(myApp)应该无限期地运行。我尝试了命令:detach,detach inferior id,但得到的响应是“在目标运行时无法执行此命令。使用”interrupt“命令停止目标,然后再次尝试”。然后我试着给出中断命令,键盘中断。在此之后,我找回了gdb控件,然后我尝试使用“q”命令退出gdb会话。我得到的回应是:“调试会话处于活动状态。下层1 [进程12910]将被分离。无论如何退出?(y或n)”。我输入“y”作为我的响应,其响应为:“在目标运行时无法执行此命令。使用”interrupt“命令停止目标,然后再次尝试”。这完成了我的gdb客户端会话。在远程目标端,gdbserver响应此退出:“客户端连接已关闭”。 此调试会话成功。但是当我的gdbserver处于多模式时,当我尝试启动一个新的调试会话并将我正在运行的应用程序(myApp)再次连接到已在同一端口号上以多模式运行的gdbserver时,我的主机上的gdb客户端无法连接到目标端的gdbserver。此命令未执行:“target extended-remote 192.168.2.2:5000” 早期使用gdb 7.8和gdbserver 7.8,我能够成功分离正在运行的应用程序(myApp)。以上将流程再次附加到同一个gdbserver的方案。但是gdbserver 7.8不支持调试子进程,因此我需要转移到gdb客户端和服务器7.12,它支持子进程调试。 详细的gdb跟踪如下:

> C:\Users\abc>arm-linux-gnueabihf-gdb
> GNU gdb (Linaro_GDB-2017.05) 7.12.1.20170417-git
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target extended-remote 192.168.2.2:5000
Remote debugging using 192.168.2.2:5000
(gdb) set detach-on-fork off
(gdb) set follow-fork-mode child
(gdb) attach 12910
Attaching to process 12910
Reading /home/root/myApp from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /home/root/myApp from remote target...
Reading symbols from target:/home/root/myApp...done.
Reading /lib/libdl.so.2 from remote target...
Reading /usr/lib/libffi.so.6 from remote target...
Reading /lib/libpthread.so.0 from remote target...
Reading /usr/lib/libstdc++.so.6 from remote target...
Reading /lib/libm.so.6 from remote target...
Reading /lib/libgcc_s.so.1 from remote target...
Reading /lib/libc.so.6 from remote target...
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading symbols from target:/lib/libdl.so.2...Reading /lib/libdl-2.22.so from remote target...
Reading /lib/.debug/libdl-2.22.so from remote target...
(no debugging symbols found)...done.
Reading symbols from target:/usr/lib/libffi.so.6...Reading /usr/lib/libffi.so.6.0.4 from remote target...
Reading /usr/lib/.debug/libffi.so.6.0.4 from remote target...
(no debugging symbols found)...done.
Reading symbols from target:/lib/libpthread.so.0...Reading /lib/libpthread-2.22.so from remote target...
Reading /lib/.debug/libpthread-2.22.so from remote target...
(no debugging symbols found)...done.
Reading symbols from target:/usr/lib/libstdc++.so.6...Reading /usr/lib/libstdc++.so.6.0.21 from remote target...
Reading /usr/lib/.debug/libstdc++.so.6.0.21 from remote target...
(no debugging symbols found)...done.
Reading symbols from target:/lib/libm.so.6...Reading /lib/libm-2.22.so from remote target...
Reading /lib/.debug/libm-2.22.so from remote target...
(no debugging symbols found)...done.
Reading symbols from target:/lib/libgcc_s.so.1...Reading /lib/.debug/libgcc_s.so.1 from remote target...
(no debugging symbols found)...done.
Reading symbols from target:/lib/libc.so.6...Reading /lib/libc-2.22.so from remote target...
Reading /lib/.debug/libc-2.22.so from remote target...
(no debugging symbols found)...done.
Reading symbols from target:/lib/ld-linux-armhf.so.3...Reading /lib/ld-2.22.so from remote target...
Reading /lib/.debug/ld-2.22.so from remote target...
(no debugging symbols found)...done.
Reading /lib/ld-linux-armhf.so.3 from remote target...
[New Thread 12910.12912]
[New Thread 12910.12913]
[New Thread 12910.12914]
[New Thread 12910.12915]
[New Thread 12910.12916]
[New Thread 12910.12917]
[New Thread 12910.12919]
[New Thread 12910.12920]
[New Thread 12910.12921]
[New Thread 12910.12922]
[New Thread 12910.12923]
[New Thread 12910.12924]
[New Thread 12910.12925]
[New Thread 12910.12926]
[New Thread 12910.12927]
[New Thread 12910.12928]
[New Thread 12910.13024]
[New Thread 12910.13025]
[New Thread 12910.13026]
[New Thread 12910.13027]
[New Thread 12910.13028]
[New Thread 12910.13029]
[New Thread 12910.13030]
[New Thread 12910.13031]
[New Thread 12910.13032]
[New Thread 12910.13033]
[New Thread 12910.13034]
[New Thread 12910.13041]
0x76885924 in nanosleep () from target:/lib/libc.so.6
(gdb) b printWithArgs1
Function "printWithArgs1" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (printWithArgs1) pending.
(gdb) c
Continuing.
Reading /home/root/libdebugTest.so from remote target...
[Switching to Thread 12910.13041]

Thread 29 "myApp" hit Breakpoint 1, printWithArgs1 (a=0x621011b0 " esha", b=12, c=45.6699982) at ..\debugTest.c:9
9               printf("\n\n a: %s, b: %d, c: %f\n\n", a, b, c);
(gdb) c
Continuing.
warning: Temporarily disabling breakpoints for unloaded shared library "target:/home/root/libdebugTest.so"
The target is not responding to interrupt requests.
Stop debugging it? (y or n) deQuit (expect signal SIGINT when the program is resumed)
(gdb) detach
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.
(gdb) i inferiors
  Num  Description       Executable
* 1    process 12910     target:/home/root/myApp
(gdb) detach inferior 1
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.
(gdb) help detach inferior
Detach from inferior ID (or list of IDS).
(gdb) detach inferior 1
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.
(gdb) Quit (expect signal SIGINT when the program is resumed)
(gdb) detach inferior 1
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.
(gdb) detach
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.
(gdb) q
A debugging session is active.

        Inferior 1 [process 12910] will be detached.

Quit anyway? (y or n) y
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.

在gdbserver端(远程目标),显示以下消息:

 root@user:~# gdbserver --multi :5000
Listening on port 5000
Remote debugging from host 192.168.2.23
Attached; pid = 12910
client connection closed

0 个答案:

没有答案