[RFC] Pretty printers for NPTL lock types
Tom Tromey
tom@tromey.com
Wed Mar 11 16:31:00 GMT 2015
>>>>> "Martin" == Martin Galvan <martin.galvan@tallertechnologies.com> writes:
Martin> if self.lock == PTHREAD_MUTEX_UNLOCKED:
Martin> print("* Status: Unlocked")
Martin> else: # Mutex is locked
Martin> if self.lock & FUTEX_WAITERS:
Martin> print("* Status: Locked, possibly with waiters")
Martin> else:
Martin> print("* Status: Locked, no waiters")
Despite their name, gdb pretty-printers shouldn't actually print
anything. Really they are value-transformers and should either return a
string value (for scalar-like objects) or an iterable of some kind (for
aggregate objects).
See
https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html
for a description of how it's supposed to work.
The reason this matters is that plain prints won't do the right thing
with GUIs using gdb. Also, I think even the CLI results will be weird
in some printing scenarios, like back-traces or nested structs.
Tom
More information about the Libc-alpha
mailing list