public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Aditya Kamath1 <Aditya.Kamath1@ibm.com>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"simon.marchi@efficios.com" <simon.marchi@efficios.com>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>,
	Sanket Rathi <sanrathi@in.ibm.com>
Subject: Re: [PATCH] Fix call functions command bug in 64-bit programs for AIX
Date: Mon, 14 Nov 2022 18:52:41 +0000	[thread overview]
Message-ID: <BY5PR15MB35402C24EC55CAE8F9BDA79FD6059@BY5PR15MB3540.namprd15.prod.outlook.com> (raw)
In-Reply-To: <f730baa8a381c573653fd7309a2e91b77dbe23a0.camel@de.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 10532 bytes --]

Hi Ulrich,

Sure. This is done..

The code is

  if (register_size (gdbarch, regno) == 8)

            memcpy (&buf, addr, 8);

          else

            buf = *addr;

          printf ("val in regno = %d via buf is %lld and *addr is %d, regsize =

%d\n", regno, buf, *addr, register_size (gdbarch, regno));

          rs6000_ptrace64 (PT_WRITE_GPR, pid, nr, 0, &buf);

        }


in store_register (struct regcache *regcache, int regno)...


The output is as shown below:-


Reading symbols from /home/XYZ/gdb_tests...

(gdb) b main

Breakpoint 1 at 0x100007dc: file /home/XYZ/gdb_tests.c, line 22.

(gdb) r

Starting program: /home/XYZ/gdb_tests

BFD: /usr/lib/libc.a(/usr/lib/libc.a(shr_64.o)): wrong auxtype 0xff for storage class 0x2

BFD: /usr/lib/libc.a(/usr/lib/libc.a(shr_64.o)): wrong auxtype 0xff for storage class 0x6b


Breakpoint 1, main (argc=1, argv=0xffffffffffffad0)

    at /home/aditya/gdb_tests.c:22

warning: Source file is more recent than executable.

22        printf("Hi Bangalore %x\n",num2print(27, 16, 13, 9.9));

(gdb) call num2print

$1 = {int (long, float, int, int)} 0x1000006a0 <num2print>

(gdb) call num2print (2, 3, 4, 6)

val in regno = 3 via buf is 2 and *addr is 0, regsize = 8

val in regno = 4 via buf is 4629700416936869888 and *addr is 1077936128, regsize = 8

val in regno = 5 via buf is 17179869184 and *addr is 4, regsize = 8

val in regno = 6 via buf is 25769803776 and *addr is 6, regsize = 8....

R2

R3.000000

R0

R0.000000

$2 = 2


I have cut short those print statements.. Full output is below

Have a nice day ahead..

Thanks,
Aditya..

--------------------


22        printf("Hi Bangalore %x\n",num2print(27, 16, 13, 9.9));

(gdb) call num2print

$1 = {int (long, float, int, int)} 0x1000006a0 <num2print>

(gdb) call num2print (2, 3, 4, 6)

val in regno = 3 via buf is 2 and *addr is 0, regsize = 8

val in regno = 4 via buf is 4629700416936869888 and *addr is 1077936128, regsize = 8

val in regno = 5 via buf is 17179869184 and *addr is 4, regsize = 8

val in regno = 6 via buf is 25769803776 and *addr is 6, regsize = 8

val in regno = 1 via buf is 1152921504606845280 and *addr is 268435455, regsize = 8

val in regno = 67 via buf is 4294968448 and *addr is 1, regsize = 8

val in regno = 0 via buf is 4294968564 and *addr is 1, regsize = 8

val in regno = 1 via buf is 1152921504606845280 and *addr is 268435455, regsize = 8

val in regno = 2 via buf is 4563403472 and *addr is 1, regsize = 8

val in regno = 3 via buf is 2 and *addr is 0, regsize = 8

val in regno = 4 via buf is 4629700416936869888 and *addr is 1077936128, regsize = 8

val in regno = 5 via buf is 17179869184 and *addr is 4, regsize = 8

val in regno = 6 via buf is 25769803776 and *addr is 6, regsize = 8

val in regno = 7 via buf is 1152921504606846944 and *addr is 268435455, regsize = 8

val in regno = 8 via buf is 0 and *addr is 0, regsize = 8

val in regno = 9 via buf is 1 and *addr is 0, regsize = 8

val in regno = 10 via buf is 0 and *addr is 0, regsize = 8

val in regno = 11 via buf is 4144 and *addr is 0, regsize = 8

val in regno = 12 via buf is -1080857313497259912 and *addr is -251656704, regsize = 8

val in regno = 13 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 14 via buf is 1 and *addr is 0, regsize = 8

val in regno = 15 via buf is 1152921504606845648 and *addr is 268435455, regsize = 8

val in regno = 16 via buf is 1152921504606845664 and *addr is 268435455, regsize = 8

val in regno = 17 via buf is 576495942044221440 and *addr is 134225921, regsize = 8

val in regno = 18 via buf is 1152921504606846672 and *addr is 268435455, regsize = 8

val in regno = 19 via buf is 720575940110904384 and *addr is 167772159, regsize = 8

val in regno = 20 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 21 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 22 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 23 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 24 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 25 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 26 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 27 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 28 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 29 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 30 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 31 via buf is 1152921504606845408 and *addr is 268435455, regsize = 8

val in regno = 64 via buf is 4294969308 and *addr is 1, regsize = 8

val in regno = 65 via buf is -6917529027640897486 and *addr is -1610612736, regsize = 8

val in regno = 66 via buf is 1109656104 and *addr is 1109656104, regsize = 4

val in regno = 67 via buf is 4294968448 and *addr is 1, regsize = 8

val in regno = 68 via buf is 0 and *addr is 0, regsize = 8

val in regno = 69 via buf is 0 and *addr is 0, regsize = 4

val in regno = 70 via buf is 0 and *addr is 0, regsize = 4

val in regno = 64 via buf is 4294968992 and *addr is 1, regsize = 8

R2

R3.000000

R0

R0.000000

val in regno = 0 via buf is 4294968564 and *addr is 1, regsize = 8

val in regno = 1 via buf is 1152921504606845408 and *addr is 268435455, regsize = 8

val in regno = 2 via buf is 4563403472 and *addr is 1, regsize = 8

val in regno = 3 via buf is 1 and *addr is 0, regsize = 8

val in regno = 4 via buf is 1152921504606845648 and *addr is 268435455, regsize = 8

val in regno = 5 via buf is 1152921504606845664 and *addr is 268435455, regsize = 8

val in regno = 6 via buf is -9223372036854722510 and *addr is -2147483648, regsize = 8

val in regno = 7 via buf is 1152921504606846944 and *addr is 268435455, regsize = 8

val in regno = 8 via buf is 0 and *addr is 0, regsize = 8

val in regno = 9 via buf is 1 and *addr is 0, regsize = 8

val in regno = 10 via buf is 0 and *addr is 0, regsize = 8

val in regno = 11 via buf is 4144 and *addr is 0, regsize = 8

val in regno = 12 via buf is -1080857313497259912 and *addr is -251656704, regsize = 8

val in regno = 13 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 14 via buf is 1 and *addr is 0, regsize = 8

val in regno = 15 via buf is 1152921504606845648 and *addr is 268435455, regsize = 8

val in regno = 16 via buf is 1152921504606845664 and *addr is 268435455, regsize = 8

val in regno = 17 via buf is 576495942044221440 and *addr is 134225921, regsize = 8

val in regno = 18 via buf is 1152921504606846672 and *addr is 268435455, regsize = 8

val in regno = 19 via buf is 720575940110904384 and *addr is 167772159, regsize = 8

val in regno = 20 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 21 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 22 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 23 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 24 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 25 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 26 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 27 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 28 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 29 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 30 via buf is -4982089500409860083 and *addr is -1159983106, regsize = 8

val in regno = 31 via buf is 1152921504606845408 and *addr is 268435455, regsize = 8

val in regno = 64 via buf is 4294969308 and *addr is 1, regsize = 8

val in regno = 65 via buf is -6917529027640897486 and *addr is -1610612736, regsize = 8

val in regno = 66 via buf is 1109656104 and *addr is 1109656104, regsize = 4

val in regno = 67 via buf is 4294968564 and *addr is 1, regsize = 8

val in regno = 68 via buf is 0 and *addr is 0, regsize = 8

val in regno = 69 via buf is 0 and *addr is 0, regsize = 4

val in regno = 70 via buf is 0 and *addr is 0, regsize = 4

$2 = 2

(gdb)

val = 0 in regno 51

val = 0 in regno 52

val = 0 in regno 52

val = 0 in regno 53

val = 0 in regno 53

val = 0 in regno 54

val = 0 in regno 54

val = 0 in regno 55

val = 0 in regno 55

val = 0 in regno 56

val = 0 in regno 56

val = 0 in regno 57

val = 0 in regno 57

val = 0 in regno 58

val = 0 in regno 58

val = 0 in regno 59

val = 0 in regno 59

val = 0 in regno 60

val = 0 in regno 60

val = 0 in regno 61

val = 0 in regno 61

val = 0 in regno 62

val = 0 in regno 62


(gdb)

(gdb)




________________________________
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Sent: 15 November 2022 00:13
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>; Sanket Rathi <sanrathi@in.ibm.com>
Subject: Re: [PATCH] Fix call functions command bug in 64-bit programs for AIX

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

>        {
>          /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
>             area, even if the register is really only 32 bits.  */
>          long long buf;
>          if (register_size (gdbarch, regno) == 8)
>            memcpy (&buf, addr, 8);
>          else
>            buf = *addr;
>          printf ("val in regno = %d via buf is %d and *addr is %d\n", regno, bu
f, *addr);

This doesn't work - buf is a "long long", so you need to use "%lld" to print
it, not just "%d".  That's why the output for "buf" was wrong.

Also, please print the result of "register_size (gdbarch, regno)" as well,
so we know for sure which part of the if condition is actually taken.

Bye,
Ulrich


  reply	other threads:[~2022-11-14 18:52 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
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 [this message]
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=BY5PR15MB35402C24EC55CAE8F9BDA79FD6059@BY5PR15MB3540.namprd15.prod.outlook.com \
    --to=aditya.kamath1@ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=sanrathi@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).