记一次gdb编译安装

本文最后更新于 2025年7月9日 晚上

记一次 gdb for loongarch 编译安装

首先是下载gdb的源码,以下是官方网址

http://ftp.gnu.org/gnu/gdb/

也可通过命令行直接用wget下载

1
wget http://ftp.gnu.org/gnu/gdb/gdb-15.2.tar.xz

然后解压源码

1
tar xvf gdb-15.2.tar.xz 

配置编译选项

1
2
3
4
cd gdb-15.2
mkdir build
cd build
../configure --prefix=/opt/loongarch64-unknown-linux-gnu-15.2 --target=loongarch64-unknown-linux-gnu

注意/opt/loongarch64-unknown-linux-gnu-15.2 可以更改为你想要的位置

编译

1
make -j16

安装

1
sudo make install -j16

安装完成目录结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/opt/loongarch64-unknown-linux-gnu-15.2
├── bin
├── include
│ ├── gdb
│ └── sim
├── lib
└── share
├── gdb
│ ├── guile
│ │ └── gdb
│ ├── python
│ │ └── gdb
│ │ ├── command
│ │ ├── dap
│ │ ├── function
│ │ └── printer
│ ├── syscalls
│ └── system-gdbinit
├── info
├── locale
│ ├── da
│ │ └── LC_MESSAGES
│ ├── de
│ │ └── LC_MESSAGES
│ ├── es
│ │ └── LC_MESSAGES
│ ├── fi
│ │ └── LC_MESSAGES
│ ├── fr
│ │ └── LC_MESSAGES
│ ├── ga
│ │ └── LC_MESSAGES
│ ├── hr
│ │ └── LC_MESSAGES
│ ├── id
│ │ └── LC_MESSAGES
│ ├── it
│ │ └── LC_MESSAGES
│ ├── ja
│ │ └── LC_MESSAGES
│ ├── ka
│ │ └── LC_MESSAGES
│ ├── nl
│ │ └── LC_MESSAGES
│ ├── pt
│ │ └── LC_MESSAGES
│ ├── pt_BR
│ │ └── LC_MESSAGES
│ ├── ro
│ │ └── LC_MESSAGES
│ ├── ru
│ │ └── LC_MESSAGES
│ ├── rw
│ │ └── LC_MESSAGES
│ ├── sr
│ │ └── LC_MESSAGES
│ ├── sv
│ │ └── LC_MESSAGES
│ ├── tr
│ │ └── LC_MESSAGES
│ ├── uk
│ │ └── LC_MESSAGES
│ ├── vi
│ │ └── LC_MESSAGES
│ └── zh_CN
│ └── LC_MESSAGES
└── man
├── man1
└── man5

给bash或者zsh添加PATH:

1
2
# add LoongArch gdb
export PATH=/opt/loongarch64-unknown-linux-gnu-15.2/bin:$PATH

然后重启终端或者source一下配置文件,再执行

1
loongarch64-unknown-linux-gnu-gdb

可以看到有如下提示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
GNU gdb (GDB) 15.2
Copyright (C) 2024 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-pc-linux-gnu --target=loongarch64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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)

记一次gdb编译安装
http://xjimlinx.github.io/2024/12/08/操作系统/记一次gdb编译安装/
作者
Xein
发布于
2024年12月8日
许可协议