GDB 调试出现:Couldn't find general-purpose registers in core file

来源:互联网 发布:nginx 多域名别名 编辑:程序博客网 时间:2024/06/05 03:26

现在平台基本都是64位的,用平台默认的gdb工具来加载vmlinux和ramdump会出现:

warning: Couldn't find general-purpose registers in core file.warning: Couldn't find general-purpose registers in core file.#0  <unavailable> in ?? ()

这是因为该gdb版本比较落后,并不能支持当前ARM平台的寄存器设置,无法识别;

解决方法:官网下载最新的gdb版本:http://www.gnu.org/software/gdb/download/

我下载的是最新的版本gdb 8.0,下载下来解压:

~$ cd gdb-8.0~/gdb-8.0$ ./configure --host=x86_64-linux-gnu --target=aarch64-elf-linuxconfigure: WARNING: If you wanted to set the --build type, don't use --host.    If a cross compiler is detected then cross compile mode will be used.checking build system type... x86_64-pc-linux-gnuchecking host system type... x86_64-pc-linux-gnuchecking target system type... aarch64-elf-linux-gnuchecking for a BSD-compatible install... /usr/bin/install -cchecking whether ln works... yeschecking whether ln -s works... yes

需要根据平台config,如果不知道也可以打开平台自带的老版本gdb查看:

$ ./aarch64-linux-android-gdb -versionPython Exception <type 'exceptions.ImportError'> No module named gdb: warning: Could not load the Python gdb module from `/tmp/ndk-mtk04092/build/toolchain/prefix/share/gdb/python'.Limited Python support is available from the _gdb module.Suggest passing --data-directory=/path/to/gdb/data-directory.GNU gdb (GDB) 7.6Copyright (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=x86_64-linux-gnu --target=aarch64-elf-linux".For bug reporting instructions, please see:<http://source.android.com/source/report-bugs.html>.

最后make一下,在gdb目录下就可以找到运行的gdb bin文件了:

~/gdb-8.0$ ./gdb/gdb --versionGNU gdb (GDB) 8.0Copyright (C) 2017 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-elf-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 加载vmlinux和rumdump:

$ ./gdb vmlinux rumdumpGNU gdb (GDB) 8.0Copyright (C) 2017 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-elf-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 vmlinux...done.[New LWP 107][New LWP 1][New LWP 2][New LWP 3][New LWP 4][New LWP 5][New LWP 6][New LWP 7][New LWP 8]Core was generated by `console=tty0 console=ttyMT0,921600n1 root=/dev/ram vmalloc=496M slub_max_order='.#0  0xffffffc0006bd034 in capture (image_window=<optimized out>, sensor_config_data=<optimized out>)    at xxx.c:12521252        BUG();(gdb) bt#0  0xffffffc0006bd034 in capture (image_window=<optimized out>, sensor_config_data=<optimized out>)    at xxx.c:1252#1  control (scenario_id=<optimized out>, image_window=<optimized out>, sensor_config_data=<optimized out>)    at xxx.c:1461