2

I'd like to call print('somestr') in a python script called in GDB ((gdb) source my_script.py), and style the output in console colors. I tried the python colorama package which works in terminal, but not when invoking from GDB. Is there a way to print in colors in GDB python script? Haven't got any clue from the Python API below.

https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html

2
  • 1
    Have you tried it with the ANSI escape codes? Like print("normal \x1b[31;1mred\x1b[m normal"). Commented Dec 21, 2022 at 14:38
  • @ssbssa thanks for reminding on that. Seems print the ANSI escape codes works in python script even it is invoked from GDB. Commented Dec 21, 2022 at 23:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.