<<gdb使用经验技巧>>

                    <<gdb使用经验技巧>>
                Tags: devel,linux,c,cpp

1. 用gcc编译须注意: .o文件必须放在.a文件前

用gcc/g++链接.o文件时, .o文件必须放在.a文件前, 否则出错: "找不到相关库函数的定义":

E:/desktop_item/tmp/0virtual/nehe2/LVHM/Chess/CGfxOpenGL.cpp:74: undefined reference to `glViewport@16'
E:/desktop_item/tmp/0virtual/nehe2/LVHM/Chess/CGfxOpenGL.cpp:75: undefined reference to `glMatrixMode@4'
E:/desktop_item/tmp/0virtual/nehe2/LVHM/Chess/CGfxOpenGL.cpp:77: undefined reference to `glLoadIdentity@0'
E:/desktop_item/tmp/0virtual/nehe2/LVHM/Chess/CGfxOpenGL.cpp:81: undefined reference to `glFrustum@48'
E:/desktop_item/tmp/0virtual/nehe2/LVHM/Chess/CGfxOpenGL.cpp:83: undefined reference to `glMatrixMode@4'

g++ file1.o file2.o file3.o lib1.a lib2.a -o a.out  // 正确写法
g++ lib1.a lib2.a file1.o file2.o file3.o -o a.out  // 错误写法


2. watch


You can force gdb to use only software watchpoints with the set
can-use-hw-watchpoints 0 command. With this variable set to zero, gdb will
never try to use hardware watchpoints, even if the underlying system supports
them. (Note that hardware-assisted watchpoints that were set before setting
can-use-hw-watchpoints to zero will still use the hardware mechanism of
watching expression values.)

set can-use-hw-watchpoints
    Set whether or not to use hardware watchpoints.
show can-use-hw-watchpoints
    Show the current mode of using hardware watchpoints.

(gdb)
// Use software watchpoints
(gdb) set can-use-hw-watchpoints 0
// Use hardware watchpoints
(gdb) set can-use-hw-watchpoints 1




100. FAQ

100.1 Target description specified unknown architecture "arm"

用gdb与gdbserver调试, gdb端有可能报如下的错误和警告, 原因一般是由于gdb与
gdbserver不匹配! 解决的办法是使用配套的gdb与gdbserver!

    (gdb) target remote 192.168.3.196:2345
      Remote debugging using 192.168.3.196:2345
      warning: while parsing target description (at line 1): Target description specified unknown architecture "arm"
      warning: Could not load XML target description; ignoring
      warning: Unable to find dynamic linker breakpoint function.
      GDB will be unable to debug shared library initializers
      and track explicitly loaded dynamic code.
      0x00000000 in ?? ()
    (gdb)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值