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.
Asked
Active
Viewed 78 times
1

Thomson
- 20,586
- 28
- 90
- 134
-
1Have you tried it with the [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)? Like `print("normal \x1b[31;1mred\x1b[m normal")`. – ssbssa Dec 21 '22 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. – Thomson Dec 21 '22 at 23:05