From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: jan.kratochvil@redhat.com
Cc: drow@false.org, gdb-patches@sourceware.org
Subject: Re: [patch] Fix `return' of long/long-long results with no debuginfo
Date: Sat, 21 Feb 2009 16:21:00 -0000 [thread overview]
Message-ID: <200902211343.n1LDhidm020789@brahms.sibelius.xs4all.nl> (raw)
In-Reply-To: <20090221124724.GA28905@host0.dyn.jankratochvil.net> (message from Jan Kratochvil on Sat, 21 Feb 2009 13:47:24 +0100)
> Date: Sat, 21 Feb 2009 13:47:24 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> On Wed, 11 Feb 2009 22:22:41 +0100, Mark Kettenis wrote:
> > would it be an idea to use the type of the return value expression given by
> > the user instead of int as a fallback?
> >
> > In the case at hand, "return -1" will still fail, but it would be
> > possible to do return (void *)-1 to do what the user wanted.
>
> It has been proven by the original bugreport even experienced
> programmers will make a mistake forgetting about the type cast.
And I' say it again. You're doing such users a far bigger favour by
distributing libraries with debug information. than with bloating gdb
with code to work around issues.
> Therefore GDB "will not work" from the user POV in the most common
> programming usecase of the `(gdb) return' command:
> * x86_64 as the current+future primary development architecture.
> * `void *' (pointer) as the most common return type in modern code.
You're pulling that one out of your arse for sure.
> * `(gdb) return 0' to simulate a failed function
> (`0' because `return NULL' may produce: No symbol "NULL" in current context.)
> Screenshot of the problem reproducer is at the bottom of this mail.
Ah, yes. Gieven the amd64 ISA zero-extends stores into the low 32
bits of a GPR, amd64_return_value() should do the same.
> While I do not have such machine at hand (could try UAE - m68k - for caller
> expecting `long long') I agree with your argument to my former unconditionally
> `long long'-casting patch:
> On Wed, 11 Feb 2009 23:44:21 +0100, Mark Kettenis wrote:
> > I'm not convinced casting to `long long' is safe in all cases, especially on
> > 32-bit big-endian machines. It really might do the wrong thing there,
> > exposing garbage or the wrong 32 bits of the 64-bit value.
>
> To find a way out of the both requirements this patch implements:
> > On Sat, 21 Feb 2009 01:04:09 +0100, Jan Kratochvil wrote:
> > > +/* Set RETURN_VALUE extended to the largest type width which will still be the
> > > + same value after reading it back using the RETURN_VALUE type. */
>
> So this patch tries as best as it can the original intention of a widest cast
> but still it verifies it has not broken the compatibility with the type
> specified by user. Specified either intentionally or unintentionally.
Well, I think your code violates the KISS principle.
> It has no regressions. The only imperfection I find is on the big endian
> 32bit arches one has to use an explicitely cast for callers expecting `long
> long'. But it cannot be guessed better and big endian arches are minority.
Perhaps that's true for the architectures that Red Hat ships products
for. It's certainly not true for the industry as a whole.
next prev parent reply other threads:[~2009-02-21 13:44 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-11 19:45 Jan Kratochvil
2009-02-11 20:40 ` Mark Kettenis
2009-02-11 20:50 ` Daniel Jacobowitz
2009-02-11 21:23 ` Mark Kettenis
2009-02-11 21:47 ` Jan Kratochvil
2009-02-11 21:58 ` Mark Kettenis
2009-02-11 22:08 ` Jan Kratochvil
2009-02-11 22:38 ` Mark Kettenis
2009-02-11 22:50 ` Jan Kratochvil
2009-03-03 18:10 ` Tom Tromey
2009-03-04 21:29 ` Mark Kettenis
2009-03-05 0:15 ` Tom Tromey
2009-03-09 1:55 ` Jan Kratochvil
2009-03-09 22:38 ` Mark Kettenis
2009-03-11 16:49 ` Joel Brobecker
2009-03-11 20:23 ` Tom Tromey
2009-03-11 21:48 ` Joel Brobecker
2009-03-13 19:50 ` Jan Kratochvil
2009-03-13 23:00 ` Joel Brobecker
2009-03-14 10:45 ` Eli Zaretskii
2009-03-14 22:09 ` Jan Kratochvil
2009-03-14 22:18 ` Eli Zaretskii
2009-03-15 9:22 ` Joel Brobecker
2009-03-15 18:15 ` Jan Kratochvil
2009-03-18 4:36 ` Pedro Alves
2009-03-18 14:44 ` Joel Brobecker
2009-03-18 15:39 ` Jan Kratochvil
2009-03-18 15:46 ` Pedro Alves
2009-02-11 22:44 ` Mark Kettenis
2009-02-12 9:41 ` Jan Kratochvil
2009-02-12 14:36 ` Pierre Muller
2009-02-12 14:44 ` Jan Kratochvil
2009-02-14 21:59 ` Mark Kettenis
2009-02-21 12:47 ` Jan Kratochvil
2009-02-21 13:44 ` Mark Kettenis
2009-02-21 15:58 ` Jan Kratochvil
2009-02-21 16:21 ` Mark Kettenis [this message]
2009-02-21 16:32 ` Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200902211343.n1LDhidm020789@brahms.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox