Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在zynq zc702上使用gdbserver进行GDB远程调试:未列出正确的源代码_C++_Linux_Gdb_Remote Debugging_Gdbserver - Fatal编程技术网

C++ 在zynq zc702上使用gdbserver进行GDB远程调试:未列出正确的源代码

C++ 在zynq zc702上使用gdbserver进行GDB远程调试:未列出正确的源代码,c++,linux,gdb,remote-debugging,gdbserver,C++,Linux,Gdb,Remote Debugging,Gdbserver,我试图使用gdbserver进行GDB远程调试,但无法使调试器在处中断并列出正确的源代码。我不确定我可能做错了什么,所以我写下了我所做的一切。两周前我刚刚开始使用linux和所有这些东西 GDB的主机系统正在我基于windows 7的笔记本电脑上使用virtualbox运行Debian 运行gdbserver的远程目标是使用Debian的xilinx zynq zc702 目标代码是使用CodeSoucery编译器arm none linux gnueabi gcc编译的,相应地,我使用的GDB

我试图使用gdbserver进行GDB远程调试,但无法使调试器在处中断并列出正确的源代码。我不确定我可能做错了什么,所以我写下了我所做的一切。两周前我刚刚开始使用linux和所有这些东西

  • GDB的主机系统正在我基于windows 7的笔记本电脑上使用virtualbox运行Debian
  • 运行gdbserver的远程目标是使用Debian的xilinx zynq zc702
  • 目标代码是使用CodeSoucery编译器arm none linux gnueabi gcc编译的,相应地,我使用的GDB是arm none linux gnueabi GDB

  • 首先,我使用ssh登录到目标上,并通过在终端中键入以下命令来启动gdbserver:

    root@zynq:/path/on/target# gdbserver localhost:3278 my_app.elf
    
    Process my_app.elf created; pid = 2083
    
    Listening on port 3278
    
    b51957@B51957debian:~$ arm-none-linux-gnueabi-gdb /path/on/host/my_app.elf
    
    target remote *target IP address*:3278
    
    (gdb) break main.cpp:23
    
  • 接下来,我通过键入主机终端来启动GDB:

    root@zynq:/path/on/target# gdbserver localhost:3278 my_app.elf
    
    Process my_app.elf created; pid = 2083
    
    Listening on port 3278
    
    b51957@B51957debian:~$ arm-none-linux-gnueabi-gdb /path/on/host/my_app.elf
    
    target remote *target IP address*:3278
    
    (gdb) break main.cpp:23
    
    GDB在没有任何警告的情况下正常启动,并显示此行:

    This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi". 在主机终端中,我得到以下响应:

    Remote debugging using *target IP address*:3278    
    Reading symbols from remote:/lib/ld-linux.so.3...(no debugging symbols found)...done.
    Loaded symbols for remote:/lib/ld-linux.so.3
    
    Remote debugging from host *host IP address*
    
    在目标终端,我得到以下响应:

    Remote debugging using *target IP address*:3278    
    Reading symbols from remote:/lib/ld-linux.so.3...(no debugging symbols found)...done.
    Loaded symbols for remote:/lib/ld-linux.so.3
    
    Remote debugging from host *host IP address*
    
  • 现在,我要求它在main.cpp的第23行输入一个断点,方法是在主机终端中键入:

    root@zynq:/path/on/target# gdbserver localhost:3278 my_app.elf
    
    Process my_app.elf created; pid = 2083
    
    Listening on port 3278
    
    b51957@B51957debian:~$ arm-none-linux-gnueabi-gdb /path/on/host/my_app.elf
    
    target remote *target IP address*:3278
    
    (gdb) break main.cpp:23
    
  • 然后让它继续,然后在断点处停止,然后尝试列出源代码。但是,不进入我的MIN .CPP文件,它总是进入一些标准的C++库头(也许是IoSt流)。这是终端的外观:

    (gdb) c
    
    Continuing.
    
    Breakpoint 1, 0x00009bdc in main ()
    
    (gdb) l
    
    11  // This library is distributed in the hope that it will be useful,
    
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    等等

  • 请注意,我正在使用
    -g
    -o0
    选项进行编译,也在使用链接器的
    -g
    选项。我还尝试使用“directory”命令将包含源文件的文件夹添加到GDB源路径。源路径已包含
    $cwd
    $cdir
    。我不明白为什么我仍然无法看到我的源代码。

    使用backtrace“bt”命令查看当前执行的位置。另外,将telnet/ssh导入目标并检查/proc/pid/maps和相关文件,以查看在您所在的地址上实际加载了什么-是程序中的代码,还是库中的代码?