I am on a Linux(Ubuntu 22) machine with gcc installed. We know that gcc comes with gdb as debugger. There are many commands in gdb and I want to change the behaviour of some inbuilt commands(disp). Can anyone tell me where can I access the source code of gdb in gcc libraries and change it to desired one?
-
Are you sure? I agree with Stephen's answer, you don't have to modify the source code of GDB to achieve that, and quite honestly, it would not be the project I'd recommend. Also, you already got the same information in the identical question, so working with what people comment before asking the same question again is also a bit appreciated :)Marcus Müller– Marcus Müller2023-09-06 12:45:00 +00:00Commented Sep 6, 2023 at 12:45
2 Answers
GDB isn’t part of GCC, it’s a separate project. On Ubuntu, you can access the source code of the version you have by running
apt source gdb
You can also use the upstream repository if you prefer that.
GDB is extensively customisable, so you might be able to achieve your goals using extensions instead of modifying its source code. GDB’s Python API in particular provides many ways of improving the GDB UI; see this dashboard for example:
Enable the source packages in your sources.list (The deb-src entries) manually or using sudo add-apt-repository:, then run sudo apt update:
sudo add-apt-repository "deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse"
sudo add-apt-repository "deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse"
sudo add-apt-repository "deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse"
sudo apt update
to download the source package:
apt source gdb
or
apt-get source gdb
Edit, then rebuild your package. Here is a complete tutorial in the Debian wiki
