This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC PATCH 0/3] Pretty-printing for errno
- From: Pedro Alves <palves at redhat dot com>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: Phil Muldoon <pmuldoon at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, gdb at sourceware dot org, Joseph Myers <joseph at codesourcery dot com>, Florian Weimer <fweimer at redhat dot com>, Tom Tromey <tom at tromey dot com>, Siddhesh Poyarekar <siddhesh at gotplt dot org>
- Date: Sat, 1 Jul 2017 12:56:26 +0100
- Subject: Re: [RFC PATCH 0/3] Pretty-printing for errno
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 338EBD5540
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 338EBD5540
- References: <20170622224456.1358-1-zackw@panix.com> <b2e7bc3b-d914-37ec-0215-2937949a848c@redhat.com> <3a7946e9-d178-f878-9774-64ff44bcf5df@redhat.com> <9490d183-a57b-b336-3131-6580e4773818@redhat.com> <be8d9730-96c5-79fa-b9bc-2afc02a17ddf@redhat.com> <CAKCAbMgAwZOG95hpAAAVYJd4SP6j3aAahOf=WWedjNJkj7_JsA@mail.gmail.com> <2f28f69b-406f-65e5-40e1-ae65632ea4f0@redhat.com> <CAKCAbMj8Rf374bss0ct+H+XMOu_o+_WWR2mQ-s8fb4-3_d7GjA@mail.gmail.com> <1d38297f-f430-ca73-6d3f-a67144d08eea@redhat.com>
On 06/30/2017 07:11 PM, Pedro Alves wrote:
> On 06/30/2017 06:27 PM, Zack Weinberg wrote:
>
>>> One dirty way around it would be for the printer to
>>> re-define the errno macro (using to cast __errno_location to
>>> the correct type before calling it, I guess:
>>>
>>> (gdb) macro define errno *(*(__error_t *(*) (void)) __errno_location) ()
>>>
>>> That's make "errno" available when you compile with levels
>>> lower than -g3, too.
>>
>> Hmm. How would one do that from inside Python?
>
> There's no direct Python API, I believe. You'd just call the CLI
> command directly, with gdb.execute.
>
> xmethods sounds like something that maybe might be useful here:
> https://sourceware.org/gdb/onlinedocs/gdb/Xmethods-In-Python.html
> though from the docs it sounds like you can only replace class
> methods, not free functions, currently. Not sure, have never written any.
BTW, it'd be very nice if the printer could replace
the "#define errno *__errno_location()" with an alternative
implementation that would avoid the function call, so that
"print errno":
#1 - would also work when debugging core dumps
#2 - is just plain safer. Having gdb call functions in
the inferior always carries the risk of corrupting an
already corrupt inferior even more.
Thanks,
Pedro Alves