GDB【5】-嵌入式平台xxx-linux-gdb远程调试动态库

1.下位机准备工作

下位机调试启动脚本

   #!/bin/bash 
   
   version='01.00.0005'
   NAND_PATH='/nandflash'
   LIB_PATH=$NAND_PATH/lib
   BIN_PATH=$NAND_PATH/bin
   CFG_PATH=$NAND_PATH/config
   DB_PATH=$NAND_PATH/database
   LOG_PATH=$NAND_PATH/log
   SH_PATH=$NAND_PATH/script
   WEB_PATH=$NAND_PATH/webserver/thttpd
   SRC_PATH=$NAND_PATH/src
   TMP_DB_PATH=/tmp/db
  
  
   tftp -g -r libxxx_prtl_k3.so 192.168.20.156
   rm -f /usr/lib/libxxx_prtl_k3.so
   ln -s $LIB_PATH/libxxx_prtl_k3.so /usr/lib/libxxx_prtl_k3.so
   gdbserver 192.168.20.156:7000 $BIN_PATH/xxx_udp -p 50001

line4:硬件平台上存放动态库的绝对路径/nandflash/lib
line16:利用tftp将需要的调试的动态库下载进入/nandflash/lib中
line18:下位机建立软连接到系统动态中,以便程序运行时能找到动态库
line19:启动gdbsever远程调试

root@lig-ppc:/nandflash/lib# sh 34FDstartdebug.sh 
Process /nandflash/bin/lig_udp created; pid = 5602
Listening on port 7000

2 回到 PC 端,远程连接下位机gdbserver

1.启动gdb

(develp)>>> powerpc-linux-gdb 
GNU gdb (GDB) 7.6
Copyright (C) 2013 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-eldk-linux --target=powerpc-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) target remote 192.168.20.208:7000
Remote debugging using 192.168.20.208:7000
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0x0ffd7b50 in ?? ()
(gdb) file lig_udp
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /home/sheldon/lig_pro/CPMS-34/APP/lig_udp/lig_udp...done.
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0xb7ef3bd8 in ?? ()

关键步骤:
1 因为动态库运行时才会被加载,所以一定要先运行将需要的动态库加载完毕
2.Ctrl+c 将正在运行的程序打断暂时挂起
3.info sharedlibrary 查看已经加载的动态库

(gdb) 
(gdb) info sharedlibrary
warning: Could not load shared library symbols for 10 libraries, e.g. linux-vdso32.so.1.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
From        To          Syms Read   Shared Object Library
                        No          linux-vdso32.so.1
                        No          /lib/preloadable_libiconv.so
                        No          /usr/lib/libsqlite3.so.0
                        No          /lib/libpthread.so.0
                        No          /lib/librt.so.1
                        No          /usr/lib/libxxx_prtl_k3.so
                        No          /usr/lib/libxxx_matrix.so
                        No          /lib/libc.so.6
                        No          /lib/libdl.so.2
                        No          /lib/ld.so.1
(gdb) set solib-search-path /tftpboot                               
Reading symbols from /tftpboot/libxxx_prtl_k3.so...done.
Loaded symbols for /tftpboot/libxxx_prtl_k3.so
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
  1. set solib-search-path设置动态库的搜索路径,该命令可设置多个搜索路径
    路径之间使用“:”隔开(在linux中为冒号,DOS和Win32中为分号)
    /tftpboot 我已经把自己生成的动态库拷贝到这个文件下面,方便tftp上传下载使用
    (可以根据自己喜好设置不同路径)
    5.再次查看加载的动态库,要调试的目标动态库已经有了地址,标识号已经全部读到
    7.设置断点
    8.继续运行
    8.发送数据
(gdb) info sharedlibrary
From        To          Syms Read   Shared Object Library
                        No          linux-vdso32.so.1
                        No          /lib/preloadable_libiconv.so
                        No          /usr/lib/libsqlite3.so.0
                        No          /lib/libpthread.so.0
                        No          /lib/librt.so.1
0x0fd960e0  0x0fdbc44c  Yes         /tftpboot/libxxx_prtl_k3.so
                        No          /usr/lib/libxxx_matrix.so
                        No          /lib/libc.so.6
                        No          /lib/libdl.so.2
                        No          /lib/ld.so.1
(gdb) b xxx_prtl_k3_set_cpedid
Breakpoint 1 at 0xfdb3b98: file /home/sheldon/xxx_pro/CPMS-34/APP/pk3000/src/xxx_k3_matrix_edid.c, line 123. 
(gdb) c
Continuing.

Breakpoint 1, xxx_prtl_k3_set_cpedid (handle=0x10030420) at /home/sheldon/xxx_pro/CPMS-34/APP/pk3000/src/xxx_k3_matrix_edid.c:123
123		char  dest_bitmap[32]={0};

网上还有用
set solib-absolute-prefix ,set sysroot,以及设置环境变量 LD_LIBRARY_PATH,但是我并没有成功
还请不吝赐教

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值