public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "tromey at sourceware dot org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug rust/30090] Using TUI on musl libc with Rust program, finish failed a bounds check
Date: Thu, 09 Feb 2023 18:39:31 +0000	[thread overview]
Message-ID: <bug-30090-4717-L42vyxXex2@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30090-4717@http.sourceware.org/bugzilla/>

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

--- Comment #14 from Tom Tromey <tromey at sourceware dot org> ---
Ok, I think I'll just have to xfail the actual result here.
Basically, gdb has to rely on programs using the platform ABI
to extract return values.  However, my test function doesn't
seem to be doing this.

amd64-tdep.c thinks my type should be returned entirely in $rax, but
really it's being returned in a combo of $eax and $edx.

(gdb) disassemble return_some
Dump of assembler code for function
_ZN6finish11return_some17hc6e727e1fe11047cE:
   0x000055555555c400 <+0>:     push   %rax
   0x000055555555c401 <+1>:     movl   $0x61,0x4(%rsp)
   0x000055555555c409 <+9>:     movl   $0x1,(%rsp)
   0x000055555555c410 <+16>:    mov    (%rsp),%eax
   0x000055555555c413 <+19>:    mov    0x4(%rsp),%edx
^^^ here you can see eax/edx being set.
   0x000055555555c417 <+23>:    pop    %rcx
   0x000055555555c418 <+24>:    ret

(gdb) info regist
rax            0x1                 1
rbx            0x1                 1
rcx            0x6100000001        416611827713
rdx            0x61                97

The caller does:

   0x000055555555c420 <+0>:     sub    $0x18,%rsp
   0x000055555555c424 <+4>:     call   0x55555555c400
<_ZN6finish11return_some17hc6e727e1fe11047cE>
=> 0x000055555555c429 <+9>:     mov    %eax,0x8(%rsp)
   0x000055555555c42d <+13>:    mov    %edx,0xc(%rsp)

.. i.e., you can see it moving out of edx.

Now, arguably this is maybe some reading of the ABI.
amd64-tdep knows that rdx is the second integer register.
But, it seems to me that since the entire structure is 8
bytes, it should probably all be stuffed into rax.

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

  parent reply	other threads:[~2023-02-09 18:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 22:29 [Bug rust/30090] New: " sourceware.897 at alm dot website
2023-02-06 22:31 ` [Bug rust/30090] " sourceware.897 at alm dot website
2023-02-07 18:12 ` tromey at sourceware dot org
2023-02-07 22:32 ` sourceware.897 at alm dot website
2023-02-07 22:48 ` sourceware.897 at alm dot website
2023-02-08  4:32 ` tromey at sourceware dot org
2023-02-08  4:41 ` sourceware.897 at alm dot website
2023-02-08 23:50 ` tromey at sourceware dot org
2023-02-09  1:32 ` sourceware.897 at alm dot website
2023-02-09  1:39 ` sourceware.897 at alm dot website
2023-02-09  1:40 ` sourceware.897 at alm dot website
2023-02-09  2:03 ` sourceware.897 at alm dot website
2023-02-09 17:22 ` tromey at sourceware dot org
2023-02-09 17:49 ` tromey at sourceware dot org
2023-02-09 18:39 ` tromey at sourceware dot org [this message]
2023-02-09 18:58 ` tromey at sourceware dot org
2023-02-09 19:29 ` tromey at sourceware dot org
2023-02-27 18:19 ` cvs-commit at gcc dot gnu.org
2023-02-27 18:20 ` tromey at sourceware dot org

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-30090-4717-L42vyxXex2@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).