前言
kernel4.4配置kgdb选项,ubuntu需要安装gdb7.7版本,高版本会报错无法使用,
ubuntu24.04默认安装的python版本为3.12,需要配置为3.4环境
一、gdb安装
sudo apt policy gdb
gdb:
已安装:7.7.1-0ubuntu5~14.04.3
候选: 15.0.50.20240403-0ubuntu1
版本列表:
15.0.50.20240403-0ubuntu1 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages
9.2-0ubuntu1~20.04.2 500
500 https://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages
500 https://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages
9.1-0ubuntu1 500
500 https://mirrors.aliyun.com/ubuntu focal/main amd64 Packages
8.3-0ubuntu1 500
500 https://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu eoan/main amd64 Packages
8.1.1-0ubuntu1 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 Packages
8.1-0ubuntu3 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 Packages
7.11.1-0ubuntu1~16.5 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
7.11-0ubuntu1 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial/main amd64 Packages
*** 7.7.1-0ubuntu5~14.04.3 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu trusty-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu trusty-security/main amd64 Packages
100 /var/lib/dpkg/status
7.7-0ubuntu3 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu trusty/main amd64 Packages
sudo aptitude install gdb=7.7.1-0ubuntu5~14.04.3
二、gdb使用
1.gdb错误
Error processing line 1 of /usr/lib/python3/dist-packages/distutils-precedence.pth:
Traceback (most recent call last):
File "/usr/lib/python3.4/site.py", line 173, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/_distutils_hack/__init__.py", line 194
f'spec_for_{name}',
^
SyntaxError: invalid syntax
Remainder of file ignored
Error in sitecustomize; set PYTHONVERBOSE for traceback:
SyntaxError: invalid syntax (apport_python_hook.py, line 116)
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 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 "x86_64-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".
python3.4环境使用了python3.6的语法导致错误
2.gdb错误修正
使用conda创建python3.4环境
添加python3.4镜像源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
查看conda支持的python版本:
conda search "^python$"
创建python3.4环境:
conda create -n py34 python=3.4
配置python环境:
export PYTHONPATH=/home/hgc/anaconda3/envs/python3.4/lib/python3.4/
export PYTHONHOME=/home/hgc/anaconda3/envs/python3.4/lib/python3.4/
export PATH=$PATH:$PYTHONHOME:$PYTHONPATH
3.gdb使用
gdb-multiarch
file vmlinux
set architecture aarch64
set serial baud 115200
target remote /dev/ttyUSB0
break rest_init
continue