- 目标
在X86虚拟机上,加载arm程序及崩溃。
最早我想的是编译一个arm版本的,在虚拟机上显然不能使用。
后来同事跟我说,可以编译一个在虚拟机上,分析arm的gdb,我觉得好神奇。事实证明确实可以。
- 首先不能使用已编译的,尤其是别人已经编译。
- 下载
linux编译gdb-CSDN博客
- 编译
指定输出目录,方便使用。
指定前缀,方便识别。
编译脚本:
CROSS_NAME=aarch64-mix210-linux
GDB_DIR=${HOME}/build_gdb
make clean
make diskclean
./configure \
--prefix=${GDB_DIR} \
--target=${CROSS_NAME} \
--host=x86_64-linux-gnu \
--program-prefix=${CROSS_NAME}- \
--without-x \
--disable-werror
make
make install
- 检查
cd ${BUILD_GDB}/bin
ls -l
-rwxr-xr-x 1 root root 77400424 5月 15 16:23 aarch64-mix210-linux-gdb*
-rwxr-xr-x 1 root root 3270 5月 15 16:23 aarch64-mix210-linux-gdb-add-index*
-rwxr-xr-x 1 root root 9668912 5月 15 16:23 aarch64-mix210-linux-run*
- 加载,显示配置
./aarch64-mix210-linux-gdb
GNU gdb (GDB) 8.3
Copyright (C) 2019 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=x86_64-linux-gnu --target=aarch64-mix210-linux".
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) show configuration
This GDB was configured as follows:
configure --host=x86_64-linux-gnu --target=aarch64-mix210-linux
--with-auto-load-dir=$debugdir:$datadir/auto-load
--with-auto-load-safe-path=$debugdir:$datadir/auto-load
--without-expat
--with-gdb-datadir=/home/weiyu/build_gdb/share/gdb (relocatable)
--with-jit-reader-dir=/home/weiyu/build_gdb/lib/gdb (relocatable)
--without-libunwind-ia64
--without-lzma
--without-babeltrace
--without-intel-pt
--disable-libmcheck
--without-mpfr
--without-python
--without-guile
--disable-source-highlight
--with-separate-debug-dir=/home/weiyu/build_gdb/lib/debug (relocatable)
("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)
(gdb)
- 分析
这个我也没有仔细用过。
./build_gdb/bin/aarch64-mix210-linux-gdb camera core-1277
GNU gdb (GDB) 8.3
Copyright (C) 2019 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=x86_64-linux-gnu --target=aarch64-mix210-linux".
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"...
Reading symbols from camera...
[New LWP 1316]
[New LWP 1277]
[New LWP 1281]
[New LWP 1282]
[New LWP 1284]
[New LWP 1302]
[New LWP 1289]
[New LWP 1295]
[New LWP 1304]
[New LWP 1285]
[New LWP 1314]
[New LWP 1299]
[New LWP 1297]
[New LWP 1293]
[New LWP 1305]
[New LWP 1309]
[New LWP 1301]
[New LWP 1286]
[New LWP 1294]
[New LWP 1298]
[New LWP 1307]
[New LWP 1311]
[New LWP 1306]
[New LWP 1292]
[New LWP 1290]
[New LWP 1308]
[New LWP 1312]
[New LWP 1296]
[New LWP 1313]
[New LWP 1300]
[New LWP 1287]
[New LWP 1303]
[New LWP 1315]
[New LWP 1310]
[New LWP 1283]
[New LWP 1291]
[New LWP 1288]
warning: Could not load shared library symbols for 9 libraries, e.g. /lib64/libzlog.so.2.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `./camera'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000000000058f83c in http_set_zoom_res (id=id@entry=1006,
p_root=p_root@entry=0x7f080021c0, pbody=0x7f26ffc148 "",
pbody@entry=0x7f26ffc168 "", pbody_len=0x7f26ffc94c,
pbody_len@entry=0x7f26ffc96c)
--Type <RET> for more, q to quit, c to continue without paging--
at /home/weiyu/d861t_app_src/app/web/http/http_proto_parse.cpp:933
933 }
[Current thread is 1 (LWP 1316)]
(gdb)