public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	Aditya Kamath1 <Aditya.Kamath1@ibm.com>,
	"simon.marchi@efficios.com" <simon.marchi@efficios.com>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Fix call functions command bug in 64-bit programs for AIX
Date: Tue, 8 Nov 2022 13:30:48 +0000	[thread overview]
Message-ID: <cd6f52b3394d83dc552e91ba7e2c99000c5f49d2.camel@de.ibm.com> (raw)
In-Reply-To: <CH2PR15MB3544D542ED323A24D731DF8BD63C9@CH2PR15MB3544.namprd15.prod.outlook.com>

Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:

>The issue is that when a user attempts to test the return type or print
>statements via the call "FUNC_NAME (parameter A, parameter B)" command,
any input be it parameter A or B is taken in little endian format from
>the GDB cache. But AIX is using Big endian format. 

>For example, if we have a value 21 as type long then the higher 32 bits
>[ which is 0 in number 21] were stored in lower 32 bits and lower 32 bits
>[ represent 21 in the number 21] is stored in higher 32 bits.

This is not how the GDB register cache is working.  Can you explain in
more detail what exactly you're refering to here?

The register cache holds a sequence of bytes for each register.  The
number of bytes in the cache depends on the size of that register as
defined by the architecture.  The contents of those bytes are *always*
assumed to be in big-endian byte order on AIX.

For 64-bit inferior processes, GDB assumes that the ptrace call
always uses a 64-bit buffer, even if the register size is only 4.
To handle these cases, the current code will convert between the
two formats, which looks correct to me: in the fetch_register
case, it will retrieve an 8-byte value from ptrace, convert that
value (correctly, also for big-endian) to an 4-byte value, and
pass that 4-byte value to raw_supply, which should expect 4 bytes
in this case because the register_size is 4.

To understand what's going on exactly I need more details:
- what does ARCH64() return?
- what does register_size(...) return for those registers?
  (for GPRs with a 64-bit inferior it should return 8, if
  it doesn't that's probably the root cause of the problem)
- what value does ptrace return in your case?


In any case, explicitly listing specific register numbers by ABI
is definitely wrong here.  This routine must correctly handle
any register, it does not matter what the ABI usage is.


Bye,
Ulrich


  reply	other threads:[~2022-11-08 13:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 11:00 Aditya Kamath1
2022-11-08 13:30 ` Ulrich Weigand [this message]
2022-11-11 17:53   ` Aditya Kamath1
2022-11-14 15:54     ` Ulrich Weigand
2022-11-14 17:32       ` Aditya Kamath1
2022-11-14 18:19         ` Ulrich Weigand
2022-11-14 18:28           ` Aditya Kamath1
2022-11-14 18:43             ` Ulrich Weigand
2022-11-14 18:52               ` Aditya Kamath1
2022-11-14 19:10                 ` Ulrich Weigand
2022-11-16 11:27                   ` Aditya Kamath1
2022-11-16 15:15                     ` Ulrich Weigand
2022-11-16 18:07                       ` Aditya Kamath1
2022-11-16 18:30                         ` Tom Tromey
2022-11-17 12:54                         ` Ulrich Weigand
2022-11-24 17:56                           ` Aditya Kamath1
2022-11-24 18:15                             ` Tom Tromey
2023-04-14  7:38                               ` [PATCH] Fix call functions command bug in 64-bit programs for AIX and PC read in psymtab-symtab warning Aditya Kamath1
2023-04-14 14:45                                 ` Tom Tromey
2023-04-17 13:08                                   ` Aditya Kamath1
2023-04-17 13:16                                     ` Aditya Kamath1
2023-04-18 10:12                                       ` Ulrich Weigand
2023-04-21 13:00                                         ` Aditya Kamath1
2023-04-24 15:44                                           ` Ulrich Weigand
2023-04-27 10:13                                             ` Aditya Kamath1
2023-04-27 12:23                                               ` Ulrich Weigand
2023-04-27 10:14                                   ` Aditya Kamath1

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=cd6f52b3394d83dc552e91ba7e2c99000c5f49d2.camel@de.ibm.com \
    --to=ulrich.weigand@de.ibm.com \
    --cc=Aditya.Kamath1@ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simon.marchi@efficios.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).