2

I am checking assembly code of a program and would like to highlight a specific value:

gdb a.out
b main
run
s ...                   until where I want to focus my attention
x/32 0x555555554b80     display nicely the bytes

Now, is there a way to ask gdb to display the output AND highlight if a byte is equal to the desired value (here 0x27) ?

x/32 0x555555554b80  |   0x27

By highlighting I mean put this byte in bold or green, or whatever that makes it stands out!

PS: I am aware about this question but 1/ it does not answer my question, 2/ I would like to use gdb

Antonin GAVREL
  • 9,682
  • 8
  • 54
  • 81

1 Answers1

1

There's no built-in way to do this. However, it can still be done with some scripting.

A relatively simple way, with a new-enough gdb, is to use the pipe command to pipe the output of x through a program that will do the highlighting you want. For example, GNU grep can colorize the match this way.

Other approaches are possible. For example you could write a new x-like command in Python, using gdb's Python API.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63