public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/31563] Problems with accessing errno
Date: Fri, 10 May 2024 07:00:24 +0000	[thread overview]
Message-ID: <bug-31563-4717-k6hRg2vqVP@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31563-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31563

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vries at gcc dot gnu.org

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
FWIW, this:
...
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 23d5652dd21..bf836c93152 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1092,9 +1092,13 @@ call_function_by_hand_dummy (struct value *function,
     {
       const char *name = get_function_name (funaddr,
                                            name_buf, sizeof (name_buf));
-      error (_("'%s' has unknown return type; "
-              "cast the call to its declared return type"),
-            name);
+      if (gdbarch_osabi (gdbarch) == GDB_OSABI_LINUX
+         && strcmp (name, "__errno_location") == 0)
+       values_type = lookup_pointer_type (builtin_type
(gdbarch)->builtin_int);
+      else
+       error (_("'%s' has unknown return type; "
+                "cast the call to its declared return type"),
+              name);
     }

   values_type = check_typedef (values_type);
...
gives a few xpasses on the new test-case:
...
XPASS: gdb.base/check-errno.exp: macros: print errno
XPASS: gdb.base/check-errno.exp: macros: print (int) errno
XPASS: gdb.base/check-errno.exp: pthreads-macros: print errno
XPASS: gdb.base/check-errno.exp: pthreads-macros: print (int) errno
...

But it's still a bit hacky, in the sense that it doesn't fix ptype
__errno_location, in other words, it only has effect when doing an inferior
call.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-05-10  7:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27  2:10 [Bug gdb/31563] New: " kevinb at redhat dot com
2024-03-27  2:10 ` [Bug gdb/31563] " kevinb at redhat dot com
2024-05-10  7:00 ` vries at gcc dot gnu.org [this message]
2024-05-10 10:56 ` pedro at palves dot net
2024-05-10 20:10 ` kevinb at redhat dot com
2024-05-13 15:05 ` pedro at palves dot net
2024-05-14  3:00 ` kevinb at redhat dot com

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=bug-31563-4717-k6hRg2vqVP@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).