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>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Enable-vector-register-visibility-in-core-file-for-AIX.patch
Date: Tue, 14 Mar 2023 07:43:32 +0000	[thread overview]
Message-ID: <CH2PR15MB3544FAA00A7D77D2CE1BE354D6BE9@CH2PR15MB3544.namprd15.prod.outlook.com> (raw)
In-Reply-To: <4b0c380215810ae9fa052544c6c3b9ed3ccf01d6.camel@de.ibm.com>


[-- Attachment #1.1: Type: text/plain, Size: 7778 bytes --]

Hi Ulrich and community,

Please find attached the patch.

>Sorry, this is wrong - it will enable those sections unconditionally
>across all platforms and operating systems.

>Instead, you need to implement a function
>rs6000_aix_core_read_description
>that will determine the correct tdesc to use for any particular
>core file depending on the sections that are actually present there.

>You can see e.g. ppc_linux_core_read_description for
>examples how to implement this routine.

Kindly check in this patch.. It is a simple check to see for aix-vmx or vsx presence in a bfd file. And then we return the required target desc.

---------------------------------------------------------
Output without patch:-

./gdb ~/gdb_tests/bll_core core.13828468
GNU gdb (GDB) 14.0.50.20230221-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-ibm-aix7.2.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
    http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/aditya/gdb_tests/bll_core...
Core was generated by `bll_core'.
#0  main () at /home/aditya/gdb_tests/bll_core.c:24
24          int length1 = 7;
(gdb) info reg
r0             0x2ff22b50          804399952
r1             0x2ff22b10          804399888
r2             0x20000448          536872008
r3             0x2ff22b50          804399952
r4             0x100010e0          268439776
r5             0x0                 0
r6             0x5                 5
r7             0x2b67              11111
r8             0x56ce              22222
r9             0x60                96
r10            0xad9c              44444
r11            0x0                 0
r12            0x22648680          577013376
r13            0xdeadbeef          -559038737
r14            0x1                 1
r15            0x2ff22c00          804400128
r16            0x2ff22c08          804400136
r17            0xdeadbeef          -559038737
r18            0xdeadbeef          -559038737
r19            0xf0806b50          -260019376
r20            0xdeadbeef          -559038737
r21            0xdeadbeef          -559038737
r22            0xdeadbeef          -559038737
r23            0xdeadbeef          -559038737
r24            0xdeadbeef          -559038737
r25            0xdeadbeef          -559038737
r26            0x96c2062c          -1765669332
r27            0x88                136
r28            0x200002ed          536871661
r29            0x10000000          268435456
r30            0x3                 3
r31            0x2ff22b10          804399888
pc             0x10000690          0x10000690 <main+144>
msr            0x200d032           33607730
cnd            0x24648244          610566724
lr             0x10000634          0x10000634 <main+52>
cnt            0x0                 0
xer            0x20040000          537133056
fpscr          0x0                 0
mq             0xdeadbeef          -559038737

------------------------------------------
Output with patch:-

./gdb ~/gdb_tests/bll_core core.13828468
GNU gdb (GDB) 14.0.50.20230221-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-ibm-aix7.2.0.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
    http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/aditya/gdb_tests/bll_core...
Core was generated by `bll_core'.
#0  main () at /home/aditya/gdb_tests/bll_core.c:24
24          int length1 = 7;
(gdb) info reg
r0             0x2ff22b50          804399952
r1             0x2ff22b10          804399888
r2             0x20000448          536872008
r3             0x2ff22b50          804399952
r4             0x100010e0          268439776
r5             0x0                 0
r6             0x5                 5
r7             0x2b67              11111
r8             0x56ce              22222
r9             0x60                96
r10            0xad9c              44444
r11            0x0                 0
r12            0x22648680          577013376
r13            0xdeadbeef          3735928559
r14            0x1                 1
r15            0x2ff22c00          804400128
r16            0x2ff22c08          804400136
r17            0xdeadbeef          3735928559
r18            0xdeadbeef          3735928559
r19            0xf0806b50          4034947920
r20            0xdeadbeef          3735928559
r21            0xdeadbeef          3735928559
r22            0xdeadbeef          3735928559
r23            0xdeadbeef          3735928559
r24            0xdeadbeef          3735928559
r25            0xdeadbeef          3735928559
r26            0x96c2062c          2529297964
r27            0x88                136
r28            0x200002ed          536871661
r29            0x10000000          268435456
r30            0x3                 3
r31            0x2ff22b10          804399888
pc             0x10000690          0x10000690 <main+144>
msr            0x200d032           33607730
cr             0x24648244          610566724
lr             0x10000634          0x10000634 <main+52>
ctr            0x0                 0
xer            0x20040000          537133056
fpscr          0x0                 0
vscr           0x0                 0
vrsave         0x1                 1
(gdb) info reg $vr0
vr0            {uint128 = 0x14de4f00a6f27802337255053793c0, v4_float = {0x14de4f, 0xa6f278, 0x2337255, 0x53793c0}, v4_int32 = {0x14de4f, 0xa6f278, 0x2337255, 0x53793c0}, v8_int16 = {0x14, 0xde4f, 0xa6, 0xf278, 0x233, 0x7255, 0x537, 0x93c0}, v16_int8 = {0x0, 0x14, 0xde, 0x4f, 0x0, 0xa6, 0xf2, 0x78, 0x2, 0x33, 0x72, 0x55, 0x5, 0x37, 0x93, 0xc0}}
(gdb)


From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Monday, 13 March 2023 at 6:36 PM
To: gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Enable-vector-register-visibility-in-core-file-for-AIX.patch
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:
>Since we now support vector register contents debugging, we have added the below architecture. That is all the change.
>-   bfd_mach_rs6k, &tdesc_rs6000},
>+   bfd_mach_rs6k, &tdesc_powerpc_vsx32},

Sorry, this is wrong - it will enable those sections unconditionally
across all platforms and operating systems.

Instead, you need to implement a function
rs6000_aix_core_read_description
that will determine the correct tdesc to use for any particular
core file depending on the sections that are actually present there.

You can see e.g. ppc_linux_core_read_description for
examples how to implement this routine.

Bye,
Ulrich

[-- Attachment #2: 0001-Enable-vector-register-visibility-in-core-for-AIX.patch --]
[-- Type: application/octet-stream, Size: 2029 bytes --]

From 1ab600eaf27504ed507c0320fc1edb67ffea1e58 Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Tue, 14 Mar 2023 02:27:22 -0500
Subject: [PATCH] Enable vector register visibility in core for AIX.

This patch enables AIX folks to see vector register contents while they
analyse the core file.
---
 gdb/rs6000-tdep.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 592b447948e..1689d668d54 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -7461,6 +7461,34 @@ rs6000_program_breakpoint_here_p (gdbarch *gdbarch, CORE_ADDR address)
   return false;
 }
 
+static const struct target_desc *
+ppc_aix_core_read_description (struct gdbarch *gdbarch,
+			       struct target_ops *target,
+			       bfd *abfd)
+{
+  asection *altivec = bfd_get_section_by_name (abfd, ".aix-vmx");
+  asection *vsx = bfd_get_section_by_name (abfd, ".aix-vsx");
+  asection *section = bfd_get_section_by_name (abfd, ".reg");
+
+  if (!section) 
+    return NULL;
+
+  int arch64 = 0;
+  if (bfd_section_size (section) == 48 * 8)
+    arch64 = 1;
+
+  if (vsx && arch64)
+    return tdesc_powerpc_vsx64; 
+  else if (vsx && !arch64)
+    return tdesc_powerpc_vsx32;
+  else if (altivec && arch64)
+    return tdesc_powerpc_altivec64;
+  else if (altivec && !arch64)
+    return tdesc_powerpc_altivec32;
+
+  return NULL;
+}
+
 /* Initialize the current architecture based on INFO.  If possible, re-use an
    architecture from ARCHES, which is a list of architectures already created
    during this debugging session.
@@ -8454,6 +8482,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   else
     register_ppc_ravenscar_ops (gdbarch);
 
+  set_gdbarch_core_read_description (gdbarch, ppc_aix_core_read_description);
   set_gdbarch_disassembler_options (gdbarch, &powerpc_disassembler_options);
   set_gdbarch_valid_disassembler_options (gdbarch,
 					  disassembler_options_powerpc ());
-- 
2.38.3


  reply	other threads:[~2023-03-14  7:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 12:23 Aditya Kamath1
2023-03-13 13:06 ` Ulrich Weigand
2023-03-14  7:43   ` Aditya Kamath1 [this message]
2023-03-14 17:58     ` Ulrich Weigand
2023-03-15  4:54       ` Aditya Kamath1
2023-03-15 18:32         ` Ulrich Weigand
2023-03-15 19:04           ` Simon Marchi
2023-03-16 12:50             ` Luis Machado
2023-03-16 13:51             ` Tom Tromey
2023-03-16 15:11               ` Ulrich Weigand

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=CH2PR15MB3544FAA00A7D77D2CE1BE354D6BE9@CH2PR15MB3544.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 \
    /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).