-1

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?

1
  • 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 :) Commented Sep 6, 2023 at 12:45

2 Answers 2

3

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:

screenshot of the GDB dashboard showing disassembly, breakpoints, expressions, command history, memory dumps, register contents, source code, the stack, and watched variables

2

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.