0

为了调试已经在远程目标上运行的应用程序(架构: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)应该无限期地运行。我尝试了命令:分离,分离劣质ID,但得到的响应是“目标运行时无法执行此命令。使用“中断” 命令停止目标,然后重试”。然后我尝试发出中断命令,键盘中断。在此之后,我取回了 gdb 控制,然后我尝试使用“q”命令退出 gdb 会话。我得到了回应在此之后是:“调试会话处于活动状态。下级 1 [进程 12910] 将被分离。还是放弃吧?(y 或 n)”。我输入“y”作为我的响应,响应为:“目标运行时无法执行此命令。使用“中断”命令停止目标,然后重试”。这完成了我的 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 跟踪如下:我在主机上的 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 跟踪如下:我在主机上的 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 跟踪如下:8 不支持调试子进程,因此我需要移动到支持子进程调试的 gdb 客户端和服务器 7.12。详细的 gdb 跟踪如下: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
4

0 回答 0