This is the mail archive of the
mailing list for the glibc project.
Re: [RFC] Pretty printers for NPTL lock types
- From: Tom Tromey <tom at tromey dot com>
- To: Martin Galvan <martin dot galvan at tallertechnologies dot com>
- Cc: libc-alpha at sourceware dot org, "Carlos O'Donell" <carlos at redhat dot com>, Daniel Gutson <daniel dot gutson at tallertechnologies dot com>, Torvald Riegel <triegel at redhat dot com>
- Date: Wed, 11 Mar 2015 10:31:32 -0600
- Subject: Re: [RFC] Pretty printers for NPTL lock types
- Authentication-results: sourceware.org; auth=none
- References: <CAOKbPbbVud=gru917mXYfnOnQ9nCCY1vR4fvyU8JpRVzaGe5bw at mail dot gmail dot com>
>>>>> "Martin" == Martin Galvan <firstname.lastname@example.org> 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> 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
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.