Skip to content

Priting colours when debugging C #291

@hturner

Description

@hturner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions