GDB 調試出現:Couldn't find general-purpose registers in core file

現在平臺基本都是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-linux
configure: 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-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... aarch64-elf-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes

需要根據平臺config,如果不知道也可以打開平臺自帶的老版本gdb查看:

$ ./aarch64-linux-android-gdb -version
Python 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.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=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 --version
GNU gdb (GDB) 8.0
Copyright (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 rumdump
GNU gdb (GDB) 8.0
Copyright (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:1252
1252        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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章