-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Notes from Paul Murrell on printing colours when debugging C:
The issue is that colours are stored internally in R as C integers. This means that, when debugging, it is difficult to know what colour we have, for example, we might just see ...
( gdb) print gc->fill -16776961
Fortunately, it is easy to get gdb to print an integer in hexadecimal ...
(gdb) print/x gc->fill 0xff0000ff
... which is very much easier to interpret because each pair of hex digits is now R, G, B, A, so this is (opaque) red.
This also works in LLDB (we can also do p/x gc->fill for short but less intuitive). More generally, /x is a format specifier and we can do also do print/d expr and print/f expr to format as desimal or float.
We could add a bit on this to the new debugging chapter.