解决GDB的Python目录报错

主要步骤:

  1. 在GDK8中运行GDB时,可能会出现Python目录的报错。
geduer@gdk8:~$ gdb
Python Exception <class 'ModuleNotFoundError'> No module named 'gdb':
gdb: warning:
Could not load the Python gdb module from `/usr/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.

GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 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 "aarch64-linux-gnu".
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)
  1. 这个错误是由于GDB缺少Python组件导致的。
    只需执行下方的命令后即可恢复正常。
  • sudo rm -rf /usr/share/gdb/python
  • sudo apt update
    sudo apt install gdb
geduer@gdk8:/usr/share/gdb$ ls
auto-load  python
geduer@gdk8:/usr/share/gdb$ sudo rm -rf python
geduer@gdk8:/usr/share/gdb$ ls
auto-load
geduer@gdk8:/usr/share/gdb$ sudo apt install gdb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  gdbserver libbabeltrace1 libc-dev-bin libc6 libc6-dbg libc6-dev libdw1
Suggested packages:
  gdb-doc glibc-doc
The following NEW packages will be installed:
  gdb gdbserver libbabeltrace1 libc6-dbg libdw1
The following packages will be upgraded:
  libc-dev-bin libc6 libc6-dev
3 upgraded, 5 newly installed, 0 to remove and 329 not upgraded.
Need to get 16.1 MB of archives.
After this operation, 72.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu-ports bionic-updates/main arm64 libc6-dev arm64 2.27-3ubuntu1.4 [2046 kB]
Get:2 http://mirrors.aliyun.com/ubuntu-ports bionic-updates/main arm64 libc-dev-bin arm64 2.27-3ubuntu1.4 [58.7 kB]
Get:3 http://mirrors.aliyun.com/ubuntu-ports bionic-updates/main arm64 libc6 arm64 2.27-3ubuntu1.4 [2275 kB]
Get:4 http://mirrors.aliyun.com/ubuntu-ports bionic-updates/main arm64 libdw1 arm64 0.170-0.4ubuntu0.1 [179 kB]
Get:5 http://mirrors.aliyun.com/ubuntu-ports bionic/main arm64 libbabeltrace1 arm64 1.5.5-1 [128 kB]
Get:6 http://mirrors.aliyun.com/ubuntu-ports bionic-updates/main arm64 gdb arm64 8.1.1-0ubuntu1 [2912 kB]
Get:7 http://mirrors.aliyun.com/ubuntu-ports bionic-updates/main arm64 gdbserver arm64 8.1.1-0ubuntu1 [260 kB]
Get:8 http://mirrors.aliyun.com/ubuntu-ports bionic-updates/main arm64 libc6-dbg arm64 2.27-3ubuntu1.4 [8201 kB]
Fetched 16.1 MB in 13s (1283 kB/s)
Preconfiguring packages ...
dpkg: warning: files list file for package 'firefly-multi-rtsp' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'firefly-3399pronpu-driver' missing; assuming package has no files currently installed
(Reading database ... 93665 files and directories currently installed.)
Preparing to unpack .../libc6-dev_2.27-3ubuntu1.4_arm64.deb ...
Unpacking libc6-dev:arm64 (2.27-3ubuntu1.4) over (2.27-3ubuntu1) ...
Preparing to unpack .../libc-dev-bin_2.27-3ubuntu1.4_arm64.deb ...
Unpacking libc-dev-bin (2.27-3ubuntu1.4) over (2.27-3ubuntu1) ...
Preparing to unpack .../libc6_2.27-3ubuntu1.4_arm64.deb ...
Unpacking libc6:arm64 (2.27-3ubuntu1.4) over (2.27-3ubuntu1) ...
Setting up libc6:arm64 (2.27-3ubuntu1.4) ...
Selecting previously unselected package libdw1:arm64.
dpkg: warning: files list file for package 'firefly-multi-rtsp' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'firefly-3399pronpu-driver' missing; assuming package has no files currently installed
(Reading database ... 93665 files and directories currently installed.)
Preparing to unpack .../libdw1_0.170-0.4ubuntu0.1_arm64.deb ...
Unpacking libdw1:arm64 (0.170-0.4ubuntu0.1) ...
Selecting previously unselected package libbabeltrace1:arm64.
Preparing to unpack .../libbabeltrace1_1.5.5-1_arm64.deb ...
Unpacking libbabeltrace1:arm64 (1.5.5-1) ...
Selecting previously unselected package gdb.
Preparing to unpack .../gdb_8.1.1-0ubuntu1_arm64.deb ...
Unpacking gdb (8.1.1-0ubuntu1) ...
Selecting previously unselected package gdbserver.
Preparing to unpack .../gdbserver_8.1.1-0ubuntu1_arm64.deb ...
Unpacking gdbserver (8.1.1-0ubuntu1) ...
Selecting previously unselected package libc6-dbg:arm64.
Preparing to unpack .../libc6-dbg_2.27-3ubuntu1.4_arm64.deb ...
Unpacking libc6-dbg:arm64 (2.27-3ubuntu1.4) ...
Setting up libc6-dbg:arm64 (2.27-3ubuntu1.4) ...
Setting up libdw1:arm64 (0.170-0.4ubuntu0.1) ...
Setting up gdbserver (8.1.1-0ubuntu1) ...
Setting up libc-dev-bin (2.27-3ubuntu1.4) ...
Setting up libc6-dev:arm64 (2.27-3ubuntu1.4) ...
Setting up libbabeltrace1:arm64 (1.5.5-1) ...
Setting up gdb (8.1.1-0ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
/sbin/ldconfig.real: file /usr/lib/aarch64-linux-gnu/libff_vpu.so is truncated

Processing triggers for menu (2.1.47ubuntu2.1) ...
geduer@gdk8:/usr/share/gdb$ ls
auto-load  python  syscalls  system-gdbinit
  1. 此时我们再次执行GDB,就会发现GDB不再报错了。
geduer@gdk8:~$ gdb
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 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 "aarch64-linux-gnu".
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)
作者:admin  创建时间:2021-12-13 09:09
最后编辑:admin  更新时间:2024-07-05 11:40