• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

编译gdb和gdbserver

武飞扬头像
SanShuiGeGe
帮助1

0、参考文章:

https://www.cnblogs.com/Dennis-mi/articles/5018745.html
https://blog.csdn.net/zhaoxd200808501/article/details/77838933

1、源码下载:http://ftp.gnu.org/gnu/gdb/

2、解压

tar.xz:tar xvJf ./gdb-7.8.tar.xz
tar.gz:tar -zxvf ./gdb-7.8.tar.gz

3、生成Makefile

./configure --host=arm-mol-linux-uclibcgnueabihf --target=arm-mol-linux-uclibcgnueabihf --program-prefix=arm-mol-linux-uclibcgnueabihf- --prefix=$PWD/__install
–host:表示主机使用的编译工具链,一般是arm-linux,也可以是芯片平台的编译工具链。
–target:表示芯片平台的编译工具链,如arm-mol-linux-uclibcgnueabihf
–program-prefix:表示目标生成的前缀名字。
–prefix:表示make install输出的目录。

4、编译make -j29

5、编译安装:make install,输出到前指定的目录中

6、gdb和gdbserver在./__install/bin目录下

7、其他:如果交叉编译工具链版本较老,第4步编译过程可能会遇到一些编译问题。如下:

7.1 编译7.8版本GDB时遇到的问题

Q1:undefined reference to `exp’
A1:修改makefile、增加-lm编译指令

7.2 编译10.2版本GDB时遇到问题

Q1:‘log2’ is not a member of ‘std’

dwarf2/index-write.c: In member function 'void debug_names::build()':
dwarf2/index-write.c:780:32: error: 'log2' is not a member of 'std'
       (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3))));
                                ^
dwarf2/index-write.c:780:32: note: suggested alternative:
In file included from /opt/molchip/arm-molchip-linux/arm-mol-linux-uclibcgnueabihf/sysroot/usr/include/features.h:416:0,
                 from /opt/molchip/arm-molchip-linux/arm-mol-linux-uclibcgnueabihf/sysroot/usr/include/stdio.h:28,
                 from ./../gnulib/import/stdio.h:43,
                 from ./../gdbsupport/common-defs.h:86,
                 from ./defs.h:28,
                 from dwarf2/index-write.c:20:
/opt/molchip/arm-molchip-linux/arm-mol-linux-uclibcgnueabihf/sysroot/usr/include/bits/mathcalls.h:158:1: note:   'log2'
 __MATHCALL (log2,, (_Mdouble_ __x))
 ^
  CXX    frame-base.o
  CXX    frame-unwind.o
  CXX    frame.o
  CXX    gcore.o
  CXX    gdb-demangle.o
  CXX    gdb_bfd.o
  CXX    gdb_obstack.o
  CXX    gdb_regex.o
make[2]: *** [dwarf2/index-write.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[2]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb'
make[1]: *** [all-gdb] 错误 2
make[1]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2'
make: *** [all] 错误 2
学新通

A1:使用log函数替换log2方法
将./gdb/dwarf2/index-write.c出错的行

m_bucket_table.resize
  (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3))));

使用log函数替换log2方法

m_bucket_table.resize
  (std::pow (2, std::ceil (std::log(name_count * 4 / 3) / std::log((float)2.0))));

Q2:undefined reference to ‘_obstack_free’

/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-exp.o: in function `ada_parse(parser_state*)':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/ada-exp.y:738: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-lang.o: in function `ada_clear_symbol_cache()':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/ada-lang.c:4568: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-lang.o: in function `~auto_obstack':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/gdb_obstack.h:126: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: /data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/gdb_obstack.h:126: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-lang.o: in function `ada_free_symbol_cache':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/ada-lang.c:4539: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: c-exp.o:/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/c-exp.y:2351: more undefined references to `_obstack_free' follow
collect2: error: ld returned 1 exit status
make[2]: *** [gdb] 错误 1
make[2]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb'
make[1]: *** [all-gdb] 错误 2
make[1]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2'
make: *** [all] 错误 2
学新通

A2:使用宏定义使用_obstack_free函数替换obstack_free
在./include/obstack.h中增加定义

#ifndef obstack_free
#define _obstack_free obstack_free
#endif

Q3:configure: error: no termcap library found
A3:https://www.codenong.com/cs109695462/

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhibjbaf
系列文章
更多 icon
同类精品
更多 icon
继续加载