ubuntu24.04 gdb调试kernel4.4环境配置


前言

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


  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值