* [RFC] Add support for PPC Altivec registers in gcore
@ 2007-10-26 22:14 Carlos Eduardo Seo
2007-10-29 19:24 ` Ulrich Weigand
0 siblings, 1 reply; 37+ messages in thread
From: Carlos Eduardo Seo @ 2007-10-26 22:14 UTC (permalink / raw)
To: GDB Patches Mailing List
[-- Attachment #1: Type: text/plain, Size: 706 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The attached patch makes gcore dump the contents of PPC Altivec registers.
However, I'm not happy with declaring a bunch of PPC-specific stuff in
gregset.h. But since FPXREGSET was there, I put everything in that file
as well.
I'm open to comments about how to make this better, so please give me
some thoughts.
Thanks and regards,
- --
Carlos Eduardo Seo
Software Engineer
IBM Linux Technology Center
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHIj9Qqvq7Aov/qQARAqynAJ4yaW/b7X0jloBCvIluJmZZWP8jpQCff44Z
suYd5ULIiP5pXvSnhyjX/T0=
=qmI6
-----END PGP SIGNATURE-----
[-- Attachment #2: gcore-altivec.diff --]
[-- Type: text/x-patch, Size: 4806 bytes --]
2007-10-26 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
* linux-nat.c (linux_nat_do_thread_registers): Added
support for PPC Altivec registers.
* ppc-linux-nat.c: Removed definitions of SIZEOF_VRREGS
and gdb_vrregset_t.
* gregset.h: Added definitions of SIZEOF_VRREGS and
gdb_vrregset_t.
(fill_vrregset): Declare.
Index: src/gdb/linux-nat.c
===================================================================
--- src.orig/gdb/linux-nat.c
+++ src/gdb/linux-nat.c
@@ -2616,6 +2616,7 @@ linux_nat_do_thread_registers (bfd *obfd
{
gdb_gregset_t gregs;
gdb_fpregset_t fpregs;
+ gdb_vrregset_t vrregs;
#ifdef FILL_FPXREGSET
gdb_fpxregset_t fpxregs;
#endif
@@ -2676,6 +2677,21 @@ linux_nat_do_thread_registers (bfd *obfd
note_size,
&fpxregs, sizeof (fpxregs));
#endif
+
+ if (core_regset_p
+ && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-ppc-vmx",
+ sizeof (vrregs))) != NULL
+ && regset->collect_regset != NULL)
+ regset->collect_regset (regset, regcache, -1,
+ &vrregs, sizeof (vrregs));
+ else
+ fill_vrregset (regcache, &vrregs);
+
+ note_data = (char *) elfcore_write_ppc_vmx (obfd,
+ note_data,
+ note_size,
+ &vrregs, sizeof (vrregs));
+
return note_data;
}
Index: src/gdb/ppc-linux-nat.c
===================================================================
--- src.orig/gdb/ppc-linux-nat.c
+++ src/gdb/ppc-linux-nat.c
@@ -79,38 +79,6 @@
#define PTRACE_GETSIGINFO 0x4202
#endif
-/* This oddity is because the Linux kernel defines elf_vrregset_t as
- an array of 33 16 bytes long elements. I.e. it leaves out vrsave.
- However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return
- the vrsave as an extra 4 bytes at the end. I opted for creating a
- flat array of chars, so that it is easier to manipulate for gdb.
-
- There are 32 vector registers 16 bytes longs, plus a VSCR register
- which is only 4 bytes long, but is fetched as a 16 bytes
- quantity. Up to here we have the elf_vrregset_t structure.
- Appended to this there is space for the VRSAVE register: 4 bytes.
- Even though this vrsave register is not included in the regset
- typedef, it is handled by the ptrace requests.
-
- Note that GNU/Linux doesn't support little endian PPC hardware,
- therefore the offset at which the real value of the VSCR register
- is located will be always 12 bytes.
-
- The layout is like this (where x is the actual value of the vscr reg): */
-
-/* *INDENT-OFF* */
-/*
- |.|.|.|.|.....|.|.|.|.||.|.|.|x||.|
- <-------> <-------><-------><->
- VR0 VR31 VSCR VRSAVE
-*/
-/* *INDENT-ON* */
-
-#define SIZEOF_VRREGS 33*16+4
-
-typedef char gdb_vrregset_t[SIZEOF_VRREGS];
-
-
/* On PPC processors that support the the Signal Processing Extension
(SPE) APU, the general-purpose registers are 64 bits long.
However, the ordinary Linux kernel PTRACE_PEEKUSER / PTRACE_POKEUSER
@@ -687,7 +655,7 @@ store_register (const struct regcache *r
}
}
-static void
+void
fill_vrregset (const struct regcache *regcache, gdb_vrregset_t *vrregsetp)
{
int i;
Index: src/gdb/gregset.h
===================================================================
--- src.orig/gdb/gregset.h
+++ src/gdb/gregset.h
@@ -72,4 +72,40 @@ extern void fill_fpxregset (const struct
gdb_fpxregset_t *fpxregs, int regno);
#endif
+/* For PPC Altivec support */
+
+/* This oddity is because the Linux kernel defines elf_vrregset_t as
+ an array of 33 16 bytes long elements. I.e. it leaves out vrsave.
+ However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return
+ the vrsave as an extra 4 bytes at the end. I opted for creating a
+ flat array of chars, so that it is easier to manipulate for gdb.
+
+ There are 32 vector registers 16 bytes longs, plus a VSCR register
+ which is only 4 bytes long, but is fetched as a 16 bytes
+ quantity. Up to here we have the elf_vrregset_t structure.
+ Appended to this there is space for the VRSAVE register: 4 bytes.
+ Even though this vrsave register is not included in the regset
+ typedef, it is handled by the ptrace requests.
+
+ Note that GNU/Linux doesn't support little endian PPC hardware,
+ therefore the offset at which the real value of the VSCR register
+ is located will be always 12 bytes.
+
+ The layout is like this (where x is the actual value of the vscr reg): */
+
+/* *INDENT-OFF* */
+/*
+ |.|.|.|.|.....|.|.|.|.||.|.|.|x||.|
+ <-------> <-------><-------><->
+ VR0 VR31 VSCR VRSAVE
+*/
+/* *INDENT-ON* */
+
+#define SIZEOF_VRREGS 33*16+4
+
+typedef char gdb_vrregset_t[SIZEOF_VRREGS];
+
+extern void
+fill_vrregset (const struct regcache *regcache, gdb_vrregset_t *vrregsetp);
+
#endif
[-- Attachment #3: gcore-altivec.diff.sig --]
[-- Type: application/octet-stream, Size: 64 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-26 22:14 [RFC] Add support for PPC Altivec registers in gcore Carlos Eduardo Seo @ 2007-10-29 19:24 ` Ulrich Weigand 2007-10-30 21:02 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2007-10-29 19:24 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > The attached patch makes gcore dump the contents of PPC Altivec registers. > > However, I'm not happy with declaring a bunch of PPC-specific stuff in > gregset.h. But since FPXREGSET was there, I put everything in that file > as well. > > I'm open to comments about how to make this better, so please give me > some thoughts. > + if (core_regset_p > + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-ppc-vmx", > + sizeof (vrregs))) != NULL > + && regset->collect_regset != NULL) > + regset->collect_regset (regset, regcache, -1, > + &vrregs, sizeof (vrregs)); > + else > + fill_vrregset (regcache, &vrregs); First of all, you certainly do not need the global fill_vrregset fallback. In fact, the existing uses of the global "fill_..." functions should be removed and targets switched over to use the collect_regset method. For *new* support like this, you should simply require the collect_regset method to be used, and not provide any fallback. Also, the current patch as it stands will cause build failures on any native Linux target but PowerPC, as that function is not defined. > Index: src/gdb/gregset.h > +/* For PPC Altivec support */ > + > +#define SIZEOF_VRREGS 33*16+4 > + > +typedef char gdb_vrregset_t[SIZEOF_VRREGS]; Now, the only reason this currently needs to be in common code is that common code allocates a local variable on the stack, and needs to know the size required for it. Everything else is actually not necessary in common code. So maybe be should add a new gdbarch variable that points to a list of supported register notes, each specified via name and size: { { ".reg", sizeof gdb_gregset_t }, { ".reg2", sizeof gdb_fpregset_t }, { ".reg-ppx-vmx", sizeof gdb_vrregset_t }, { NULL } } Common linux-nat code would walk through the list, instead of having to handle each note separately. (Note that corelow.c could also walk that list instead of hard-coding note names.) Probably at least for now the "main" .reg / .reg2 will have to remain special-cased due to the fill_ fallbacks. But the "special" note types, .reg-xfp for Intel and .reg-ppc-vmx for PPC, could certainly be switched to the new method. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-29 19:24 ` Ulrich Weigand @ 2007-10-30 21:02 ` Carlos Eduardo Seo 2007-10-30 21:18 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2007-10-30 21:02 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 729 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks for the comments Ulrich. So, does this one look like a good start? About the new gdbarch variable, do you think it's a good idea to introduce it now, only with .reg-ppc-vmx and .reg-xfp on the list, or you'd rather do a full rework later in GDB in order to remove all fill_ fallbacks make linux-nat/corelow code get everything from there? Regards, - -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHJ5jvqvq7Aov/qQARAg2BAJ9i261fLd9mkPcRhrA5gQW2CdN7BQCeJm7+ y1ku/vUr6wYBdlzfCXCZEXM= =vhiU -----END PGP SIGNATURE----- [-- Attachment #2: gcore-altivec.diff --] [-- Type: text/x-patch, Size: 4639 bytes --] 2007-10-30 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * linux-nat.c (linux_nat_do_thread_registers): Added support for PPC Altivec registers. * ppc-linux-nat.c: Removed definitions of SIZEOF_VRREGS and gdb_vrregset_t. * gregset.h: Added definitions of SIZEOF_VRREGS and gdb_vrregset_t. Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -2616,6 +2616,7 @@ linux_nat_do_thread_registers (bfd *obfd { gdb_gregset_t gregs; gdb_fpregset_t fpregs; + gdb_vrregset_t vrregs; #ifdef FILL_FPXREGSET gdb_fpxregset_t fpxregs; #endif @@ -2676,6 +2677,19 @@ linux_nat_do_thread_registers (bfd *obfd note_size, &fpxregs, sizeof (fpxregs)); #endif + + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-ppc-vmx", + sizeof (vrregs))) != NULL + && regset->collect_regset != NULL) + regset->collect_regset (regset, regcache, -1, + &vrregs, sizeof (vrregs)); + + note_data = (char *) elfcore_write_ppc_vmx (obfd, + note_data, + note_size, + &vrregs, sizeof (vrregs)); + return note_data; } Index: src/gdb/ppc-linux-nat.c =================================================================== --- src.orig/gdb/ppc-linux-nat.c +++ src/gdb/ppc-linux-nat.c @@ -79,38 +79,6 @@ #define PTRACE_GETSIGINFO 0x4202 #endif -/* This oddity is because the Linux kernel defines elf_vrregset_t as - an array of 33 16 bytes long elements. I.e. it leaves out vrsave. - However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return - the vrsave as an extra 4 bytes at the end. I opted for creating a - flat array of chars, so that it is easier to manipulate for gdb. - - There are 32 vector registers 16 bytes longs, plus a VSCR register - which is only 4 bytes long, but is fetched as a 16 bytes - quantity. Up to here we have the elf_vrregset_t structure. - Appended to this there is space for the VRSAVE register: 4 bytes. - Even though this vrsave register is not included in the regset - typedef, it is handled by the ptrace requests. - - Note that GNU/Linux doesn't support little endian PPC hardware, - therefore the offset at which the real value of the VSCR register - is located will be always 12 bytes. - - The layout is like this (where x is the actual value of the vscr reg): */ - -/* *INDENT-OFF* */ -/* - |.|.|.|.|.....|.|.|.|.||.|.|.|x||.| - <-------> <-------><-------><-> - VR0 VR31 VSCR VRSAVE -*/ -/* *INDENT-ON* */ - -#define SIZEOF_VRREGS 33*16+4 - -typedef char gdb_vrregset_t[SIZEOF_VRREGS]; - - /* On PPC processors that support the the Signal Processing Extension (SPE) APU, the general-purpose registers are 64 bits long. However, the ordinary Linux kernel PTRACE_PEEKUSER / PTRACE_POKEUSER @@ -687,7 +655,7 @@ store_register (const struct regcache *r } } -static void +void fill_vrregset (const struct regcache *regcache, gdb_vrregset_t *vrregsetp) { int i; Index: src/gdb/gregset.h =================================================================== --- src.orig/gdb/gregset.h +++ src/gdb/gregset.h @@ -72,4 +72,37 @@ extern void fill_fpxregset (const struct gdb_fpxregset_t *fpxregs, int regno); #endif +/* For PPC Altivec support */ + +/* This oddity is because the Linux kernel defines elf_vrregset_t as + an array of 33 16 bytes long elements. I.e. it leaves out vrsave. + However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return + the vrsave as an extra 4 bytes at the end. I opted for creating a + flat array of chars, so that it is easier to manipulate for gdb. + + There are 32 vector registers 16 bytes longs, plus a VSCR register + which is only 4 bytes long, but is fetched as a 16 bytes + quantity. Up to here we have the elf_vrregset_t structure. + Appended to this there is space for the VRSAVE register: 4 bytes. + Even though this vrsave register is not included in the regset + typedef, it is handled by the ptrace requests. + + Note that GNU/Linux doesn't support little endian PPC hardware, + therefore the offset at which the real value of the VSCR register + is located will be always 12 bytes. + + The layout is like this (where x is the actual value of the vscr reg): */ + +/* *INDENT-OFF* */ +/* + |.|.|.|.|.....|.|.|.|.||.|.|.|x||.| + <-------> <-------><-------><-> + VR0 VR31 VSCR VRSAVE +*/ +/* *INDENT-ON* */ + +#define SIZEOF_VRREGS 33*16+4 + +typedef char gdb_vrregset_t[SIZEOF_VRREGS]; + #endif [-- Attachment #3: gcore-altivec.diff.sig --] [-- Type: application/octet-stream, Size: 65 bytes --] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-30 21:02 ` Carlos Eduardo Seo @ 2007-10-30 21:18 ` Ulrich Weigand 2007-10-30 21:30 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2007-10-30 21:18 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > About the new gdbarch variable, do you think it's a good idea to > introduce it now, only with .reg-ppc-vmx and .reg-xfp on the list, or > you'd rather do a full rework later in GDB in order to remove all > fill_ fallbacks make linux-nat/corelow code get everything from there? Completely removing all the fallbacks seems quite a bit of work; if you want to work on it that would certainly be welcome. However, I think it would be OK to start with having the gdbarch variable only contain the *extra* register sets, beyond the core and floating-point sets. > + if (core_regset_p > + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-ppc-vmx", > + sizeof (vrregs))) != NULL > + && regset->collect_regset != NULL) > + regset->collect_regset (regset, regcache, -1, > + &vrregs, sizeof (vrregs)); > + > + note_data = (char *) elfcore_write_ppc_vmx (obfd, > + note_data, > + note_size, > + &vrregs, sizeof (vrregs)); If we do not have a collect_regset, we certainly do not want to write an note section containing uninitialized data. The elfcore_write_ppc_vmx call needs to be inside the "if" block ... > -static void > +void > fill_vrregset (const struct regcache *regcache, gdb_vrregset_t *vrregsetp) This is no longer necessary now. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-30 21:18 ` Ulrich Weigand @ 2007-10-30 21:30 ` Carlos Eduardo Seo 2007-10-30 21:31 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2007-10-30 21:30 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 1061 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ulrich Weigand wrote: > > Completely removing all the fallbacks seems quite a bit of work; > if you want to work on it that would certainly be welcome. > > However, I think it would be OK to start with having the gdbarch > variable only contain the *extra* register sets, beyond the core > and floating-point sets. > Ok. So, this would require removing the FILL_FPXREGSET ifdefs and all the fill_fpxregset fallbacks. I think this is OK, but won't it break anything in x86? > > If we do not have a collect_regset, we certainly do not want to > write an note section containing uninitialized data. The > elfcore_write_ppc_vmx call needs to be inside the "if" block ... Corrected. Thanks, - -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHJ54hqvq7Aov/qQARArXXAJ4z8a5f0YMzM2QxKX2QkuiJLTcGhgCbBsnS NrH8jrngJzujytVbM/7wlXI= =kR1E -----END PGP SIGNATURE----- [-- Attachment #2: gcore-altivec.diff --] [-- Type: text/x-patch, Size: 4467 bytes --] 2007-10-30 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * linux-nat.c (linux_nat_do_thread_registers): Added support for PPC Altivec registers. * ppc-linux-nat.c: Removed definitions of SIZEOF_VRREGS and gdb_vrregset_t. * gregset.h: Added definitions of SIZEOF_VRREGS and gdb_vrregset_t. Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -2616,6 +2616,7 @@ linux_nat_do_thread_registers (bfd *obfd { gdb_gregset_t gregs; gdb_fpregset_t fpregs; + gdb_vrregset_t vrregs; #ifdef FILL_FPXREGSET gdb_fpxregset_t fpxregs; #endif @@ -2676,6 +2677,19 @@ linux_nat_do_thread_registers (bfd *obfd note_size, &fpxregs, sizeof (fpxregs)); #endif + + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-ppc-vmx", + sizeof (vrregs))) != NULL + && regset->collect_regset != NULL) + { + regset->collect_regset (regset, regcache, -1, + &vrregs, sizeof (vrregs)); + note_data = (char *) elfcore_write_ppc_vmx (obfd, + note_data, + note_size, + &vrregs, sizeof (vrregs)); + } return note_data; } Index: src/gdb/ppc-linux-nat.c =================================================================== --- src.orig/gdb/ppc-linux-nat.c +++ src/gdb/ppc-linux-nat.c @@ -79,38 +79,6 @@ #define PTRACE_GETSIGINFO 0x4202 #endif -/* This oddity is because the Linux kernel defines elf_vrregset_t as - an array of 33 16 bytes long elements. I.e. it leaves out vrsave. - However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return - the vrsave as an extra 4 bytes at the end. I opted for creating a - flat array of chars, so that it is easier to manipulate for gdb. - - There are 32 vector registers 16 bytes longs, plus a VSCR register - which is only 4 bytes long, but is fetched as a 16 bytes - quantity. Up to here we have the elf_vrregset_t structure. - Appended to this there is space for the VRSAVE register: 4 bytes. - Even though this vrsave register is not included in the regset - typedef, it is handled by the ptrace requests. - - Note that GNU/Linux doesn't support little endian PPC hardware, - therefore the offset at which the real value of the VSCR register - is located will be always 12 bytes. - - The layout is like this (where x is the actual value of the vscr reg): */ - -/* *INDENT-OFF* */ -/* - |.|.|.|.|.....|.|.|.|.||.|.|.|x||.| - <-------> <-------><-------><-> - VR0 VR31 VSCR VRSAVE -*/ -/* *INDENT-ON* */ - -#define SIZEOF_VRREGS 33*16+4 - -typedef char gdb_vrregset_t[SIZEOF_VRREGS]; - - /* On PPC processors that support the the Signal Processing Extension (SPE) APU, the general-purpose registers are 64 bits long. However, the ordinary Linux kernel PTRACE_PEEKUSER / PTRACE_POKEUSER Index: src/gdb/gregset.h =================================================================== --- src.orig/gdb/gregset.h +++ src/gdb/gregset.h @@ -72,4 +72,37 @@ extern void fill_fpxregset (const struct gdb_fpxregset_t *fpxregs, int regno); #endif +/* For PPC Altivec support */ + +/* This oddity is because the Linux kernel defines elf_vrregset_t as + an array of 33 16 bytes long elements. I.e. it leaves out vrsave. + However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return + the vrsave as an extra 4 bytes at the end. I opted for creating a + flat array of chars, so that it is easier to manipulate for gdb. + + There are 32 vector registers 16 bytes longs, plus a VSCR register + which is only 4 bytes long, but is fetched as a 16 bytes + quantity. Up to here we have the elf_vrregset_t structure. + Appended to this there is space for the VRSAVE register: 4 bytes. + Even though this vrsave register is not included in the regset + typedef, it is handled by the ptrace requests. + + Note that GNU/Linux doesn't support little endian PPC hardware, + therefore the offset at which the real value of the VSCR register + is located will be always 12 bytes. + + The layout is like this (where x is the actual value of the vscr reg): */ + +/* *INDENT-OFF* */ +/* + |.|.|.|.|.....|.|.|.|.||.|.|.|x||.| + <-------> <-------><-------><-> + VR0 VR31 VSCR VRSAVE +*/ +/* *INDENT-ON* */ + +#define SIZEOF_VRREGS 33*16+4 + +typedef char gdb_vrregset_t[SIZEOF_VRREGS]; + #endif [-- Attachment #3: gcore-altivec.diff.sig --] [-- Type: application/octet-stream, Size: 65 bytes --] ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-30 21:30 ` Carlos Eduardo Seo @ 2007-10-30 21:31 ` Ulrich Weigand 2007-10-31 21:14 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2007-10-30 21:31 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo: > Ok. So, this would require removing the FILL_FPXREGSET ifdefs and all > the fill_fpxregset fallbacks. I think this is OK, but won't it break > anything in x86? Well, it's of course the goal to not break anything in x86 ;-) You'll need to test on x86 as well to make sure this is the case ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-30 21:31 ` Ulrich Weigand @ 2007-10-31 21:14 ` Carlos Eduardo Seo 2007-10-31 21:43 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2007-10-31 21:14 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ulrich Weigand wrote: > Carlos Eduardo Seo: > >> Ok. So, this would require removing the FILL_FPXREGSET ifdefs and all >> the fill_fpxregset fallbacks. I think this is OK, but won't it break >> anything in x86? > > Well, it's of course the goal to not break anything in x86 ;-) > You'll need to test on x86 as well to make sure this is the case ... > > Bye, > Ulrich > Just one thing... when you say 'a new gdbarch variable', you mean an additional field in the gdbarch struct, right? Regards, - -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHKNmHqvq7Aov/qQARApG0AJ9c9zUhQDpvnE256go4F10bEDssXwCcDs4Q JUpYEW5vTtGdsOHHl9HvE90= =QZa5 -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-31 21:14 ` Carlos Eduardo Seo @ 2007-10-31 21:43 ` Ulrich Weigand 2008-02-08 21:42 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2007-10-31 21:43 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > Just one thing... when you say 'a new gdbarch variable', you mean an > additional field in the gdbarch struct, right? Yes, exactly. You'll have to update the list in gdbarch.sh, and run the script to regenerate gdbarch.c and gdbarch.h. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-10-31 21:43 ` Ulrich Weigand @ 2008-02-08 21:42 ` Carlos Eduardo Seo 2008-02-18 18:42 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-02-08 21:42 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 898 bytes --] Ulrich Weigand wrote: > Yes, exactly. You'll have to update the list in gdbarch.sh, > and run the script to regenerate gdbarch.c and gdbarch.h. > Ok, here's my first shot at this new approach for writing core files. I had to add a new BFD function (binutils patch is attached as well - I'll submit this to the binutils mailing list later) and I didn't include the fill_register fallbacks in the new implementation. I believe a similar loop could also be used in -tdep.c files to read the core files as well, right? Only wrote the code for ppc, but this could be easily expanded to other archs, adding modifications similar to those I did in ppc-linux-tdep.c. I think this first code is very raw, but I believe we can improve it and use this approach for all archs in the future. Opinions / suggestions? Regards, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center [-- Attachment #2: gdbarch-core-regset.diff --] [-- Type: text/x-patch, Size: 9845 bytes --] 2008-02-08 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * gdbarch.c: Refreshed. * gdbarch.h: Refreshed. * gdbarch.sh: Added new gdbarch struct core_regset_sections. * regset.h (core_regset_section): Declare. * ppc-linux-tdep.c: (ppc_regset_sections): Declare. (ppc_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * linux-nat.c (linux_nat_do_thread_registers): Added support to the new gdbarch struct core_regset_sections. Index: src/gdb/gdbarch.c =================================================================== --- src.orig/gdb/gdbarch.c +++ src/gdb/gdbarch.c @@ -222,6 +222,7 @@ struct gdbarch gdbarch_register_reggroup_p_ftype *register_reggroup_p; gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument; gdbarch_regset_from_core_section_ftype *regset_from_core_section; + struct core_regset_section * core_regset_sections; gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries; int vtable_function_descriptors; int vbit_in_delta; @@ -344,6 +345,7 @@ struct gdbarch startup_gdbarch = default_register_reggroup_p, /* register_reggroup_p */ 0, /* fetch_pointer_argument */ 0, /* regset_from_core_section */ + 0, /* core_regset_sections */ 0, /* core_xfer_shared_libraries */ 0, /* vtable_function_descriptors */ 0, /* vbit_in_delta */ @@ -694,6 +696,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s "gdbarch_dump: core_read_description = <0x%lx>\n", (long) gdbarch->core_read_description); fprintf_unfiltered (file, + "gdbarch_dump: core_regset_sections = %s\n", + (char *) gdbarch->core_regset_sections); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n", gdbarch_core_xfer_shared_libraries_p (gdbarch)); fprintf_unfiltered (file, @@ -2810,6 +2815,22 @@ set_gdbarch_regset_from_core_section (st gdbarch->regset_from_core_section = regset_from_core_section; } +struct core_regset_section * +gdbarch_core_regset_sections (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_core_regset_sections called\n"); + return gdbarch->core_regset_sections; +} + +void +set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, + struct core_regset_section * core_regset_sections) +{ + gdbarch->core_regset_sections = core_regset_sections; +} + int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch) { Index: src/gdb/gdbarch.h =================================================================== --- src.orig/gdb/gdbarch.h +++ src/gdb/gdbarch.h @@ -50,6 +50,7 @@ struct target_ops; struct obstack; struct bp_target_info; struct target_desc; +struct core_regset_section; extern struct gdbarch *current_gdbarch; @@ -626,6 +627,11 @@ typedef const struct regset * (gdbarch_r extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size); extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section); +/* Supported register notes in core files */ + +extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch); +extern void set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, struct core_regset_section * core_regset_sections); + /* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from core file into buffer READBUF with length LEN. */ Index: src/gdb/gdbarch.sh =================================================================== --- src.orig/gdb/gdbarch.sh +++ src/gdb/gdbarch.sh @@ -594,6 +594,9 @@ F:CORE_ADDR:fetch_pointer_argument:struc # name SECT_NAME and size SECT_SIZE. M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size +# Supported register notes in core files +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::(char *) gdbarch->core_regset_sections + # Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from # core file into buffer READBUF with length LEN. M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len @@ -729,6 +732,7 @@ struct target_ops; struct obstack; struct bp_target_info; struct target_desc; +struct core_regset_section; extern struct gdbarch *current_gdbarch; EOF Index: src/gdb/regset.h =================================================================== --- src.orig/gdb/regset.h +++ src/gdb/regset.h @@ -20,6 +20,12 @@ #ifndef REGSET_H #define REGSET_H 1 +struct core_regset_section +{ + const char *sect_name; + int size; +}; + struct gdbarch; struct regcache; Index: src/gdb/ppc-linux-tdep.c =================================================================== --- src.orig/gdb/ppc-linux-tdep.c +++ src/gdb/ppc-linux-tdep.c @@ -38,6 +38,13 @@ #include "frame-unwind.h" #include "tramp-frame.h" +static struct core_regset_section ppc_regset_sections[] = +{ + {".reg2", 264}, + {".reg-ppc-vmx", 544}, + {NULL, 0} +}; + static CORE_ADDR ppc_linux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) { @@ -945,6 +952,10 @@ ppc_linux_init_abi (struct gdbarch_info tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sigaction_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sighandler_tramp_frame); } + + /* Register sections. */ + set_gdbarch_core_regset_sections (gdbarch, ppc_regset_sections); + set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section); /* Enable TLS support. */ Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -2631,6 +2631,9 @@ linux_nat_do_thread_registers (bfd *obfd const struct regset *regset; int core_regset_p; struct cleanup *old_chain; + struct core_regset_section *sect_list; + char *gdb_regset; + int i = 0; old_chain = save_inferior_ptid (); inferior_ptid = ptid; @@ -2638,6 +2641,8 @@ linux_nat_do_thread_registers (bfd *obfd do_cleanups (old_chain); core_regset_p = gdbarch_regset_from_core_section_p (gdbarch); + sect_list = gdbarch_core_regset_sections (gdbarch); + if (core_regset_p && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg", sizeof (gregs))) != NULL @@ -2653,35 +2658,69 @@ linux_nat_do_thread_registers (bfd *obfd lwp, stop_signal, &gregs); - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", - sizeof (fpregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpregs, sizeof (fpregs)); + /* The loop below uses the new struct core_regset_section, which stores + the supported section names and sizes for the core file. Note that + note PRSTATUS needs to be treated specially. But the other notes are + structurally the same, so they can benefit from the new struct. */ + + if (core_regset_p && sect_list != NULL) + while ((sect_list + i)->sect_name != NULL) + { + if ((regset = gdbarch_regset_from_core_section (gdbarch, + (sect_list + i)->sect_name, + (*(sect_list + i)).size)) + != NULL && regset->collect_regset != NULL) + { + gdb_regset = xmalloc ((*(sect_list + i)).size); + regset->collect_regset (regset, regcache, -1, + gdb_regset, (*(sect_list + i)).size); + note_data = (char *) elfcore_write_register_note (obfd, + note_data, + note_size, + (sect_list + i)->sect_name, + gdb_regset, + (*(sect_list + i)).size); + xfree (gdb_regset); + } + i++; + } + + /* For architectures that does not have the struct core_regset_section implemented, + we use the old method. When all the architectures have the new support, the code + below should be deprecated. */ + else - fill_fpregset (regcache, &fpregs, -1); + { + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", + sizeof (fpregs))) != NULL + && regset->collect_regset != NULL) + regset->collect_regset (regset, regcache, -1, + &fpregs, sizeof (fpregs)); + else + fill_fpregset (regcache, &fpregs, -1); - note_data = (char *) elfcore_write_prfpreg (obfd, - note_data, - note_size, - &fpregs, sizeof (fpregs)); + note_data = (char *) elfcore_write_prfpreg (obfd, + note_data, + note_size, + &fpregs, sizeof (fpregs)); #ifdef FILL_FPXREGSET - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", - sizeof (fpxregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpxregs, sizeof (fpxregs)); - else - fill_fpxregset (regcache, &fpxregs, -1); + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", + sizeof (fpxregs))) != NULL + && regset->collect_regset != NULL) + regset->collect_regset (regset, regcache, -1, + &fpxregs, sizeof (fpxregs)); + else + fill_fpxregset (regcache, &fpxregs, -1); - note_data = (char *) elfcore_write_prxfpreg (obfd, - note_data, - note_size, - &fpxregs, sizeof (fpxregs)); + note_data = (char *) elfcore_write_prxfpreg (obfd, + note_data, + note_size, + &fpxregs, sizeof (fpxregs)); #endif + } return note_data; } [-- Attachment #3: write-register-note.patch --] [-- Type: text/x-patch, Size: 1566 bytes --] 2008-02-03 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * elf.c (elfcore_write_register_note): New function. * elf-bfd.h (elfcore_write_register_note): New prototype. Index: src/bfd/elf.c =================================================================== --- src.orig/bfd/elf.c +++ src/bfd/elf.c @@ -8438,6 +8438,23 @@ elfcore_write_ppc_vmx (bfd *abfd, note_name, NT_PPC_VMX, ppc_vmx, size); } +char * +elfcore_write_register_note (bfd *abfd, + char *buf, + int *bufsiz, + const char *section, + const void *data, + int size) +{ + if (strcmp (section, ".reg2") == 0) + return elfcore_write_prfpreg (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-xfp") == 0) + return elfcore_write_prxfpreg (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-ppc-vmx") == 0) + return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size); + return NULL; +} + static bfd_boolean elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset) { Index: src/bfd/elf-bfd.h =================================================================== --- src.orig/bfd/elf-bfd.h +++ src/bfd/elf-bfd.h @@ -2109,6 +2109,8 @@ extern char *elfcore_write_ppc_vmx (bfd *, char *, int *, const void *, int); extern char *elfcore_write_lwpstatus (bfd *, char *, int *, long, int, const void *); +extern char *elfcore_write_register_note + (bfd *, char *, int *, const char *, const void *, int); extern bfd *_bfd_elf32_bfd_from_remote_memory (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-02-08 21:42 ` Carlos Eduardo Seo @ 2008-02-18 18:42 ` Ulrich Weigand 2008-02-27 17:07 ` Carlos Eduardo Seo 2008-03-10 14:22 ` Carlos Eduardo Seo 0 siblings, 2 replies; 37+ messages in thread From: Ulrich Weigand @ 2008-02-18 18:42 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > Ok, here's my first shot at this new approach for writing core files. I > had to add a new BFD function (binutils patch is attached as well - I'll > submit this to the binutils mailing list later) and I didn't include the > fill_register fallbacks in the new implementation. OK. > I believe a similar loop could also be used in -tdep.c files to read the > core files as well, right? Yes, a similar loop should be used to read core files, but this doesn't go into -tdep.c files, but rather into corelow.c:get_core_registers. > Only wrote the code for ppc, but this could be easily expanded to other > archs, adding modifications similar to those I did in ppc-linux-tdep.c. > > I think this first code is very raw, but I believe we can improve it and > use this approach for all archs in the future. I'd very much prefer if we could just switch over all archs at the same time -- we already have enough partial transitions in GDB as is :-/ This should in fact be quite easy to achieve, as the only other arch that supports any non-standard reg section today is i386 with its .reg-xfp. We'd only need to implement this, and a default fallback for all other archs that only supports ".reg" and ".reg2". > fprintf_unfiltered (file, > + "gdbarch_dump: core_regset_sections = %s\n", > + (char *) gdbarch->core_regset_sections); This doesn't work -- core_regset_sections is not a string. > +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::(char *) gdbarch->core_regset_sections You should either use some routine that formats the (host) pointer properly (similar to gdb_print_host_address) or else maybe just disable debug output for this field. > +static struct core_regset_section ppc_regset_sections[] = > +{ > + {".reg2", 264}, > + {".reg-ppc-vmx", 544}, > + {NULL, 0} > +}; Formatting: space after { and before }. I'm wondering if it wouldn't be better to include ".reg" in the table, and just treat it separately where necessary. > + if (core_regset_p && sect_list != NULL) > + while ((sect_list + i)->sect_name != NULL) > + { > + if ((regset = gdbarch_regset_from_core_section (gdbarch, > + (sect_list + i)->sect_name, > + (*(sect_list + i)).size)) > + != NULL && regset->collect_regset != NULL) > + { > + gdb_regset = xmalloc ((*(sect_list + i)).size); > + regset->collect_regset (regset, regcache, -1, > + gdb_regset, (*(sect_list + i)).size); > + note_data = (char *) elfcore_write_register_note (obfd, > + note_data, > + note_size, > + (sect_list + i)->sect_name, > + gdb_regset, > + (*(sect_list + i)).size); > + xfree (gdb_regset); > + } > + i++; > + } If you'd just use sect_list++, all those *(sect_list + i) could go away. > + /* For architectures that does not have the struct core_regset_section implemented, > + we use the old method. When all the architectures have the new support, the code > + below should be deprecated. */ As mentioned above, please just convert everything in one go. > 2008-02-03 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> > > * elf.c (elfcore_write_register_note): New function. > * elf-bfd.h (elfcore_write_register_note): New prototype. These look fine to me, but need to be posted to the binutils list. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-02-18 18:42 ` Ulrich Weigand @ 2008-02-27 17:07 ` Carlos Eduardo Seo 2008-03-05 18:27 ` Ulrich Weigand 2008-03-10 14:22 ` Carlos Eduardo Seo 1 sibling, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-02-27 17:07 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List Ulrich Weigand wrote: > > You should either use some routine that formats the (host) pointer > properly (similar to gdb_print_host_address) or else maybe just > disable debug output for this field. How do I disable printing? I think you said previously that '0' would disable it, but that didn't work. Thanks, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-02-27 17:07 ` Carlos Eduardo Seo @ 2008-03-05 18:27 ` Ulrich Weigand 0 siblings, 0 replies; 37+ messages in thread From: Ulrich Weigand @ 2008-03-05 18:27 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > Ulrich Weigand wrote: > > > > You should either use some routine that formats the (host) pointer > > properly (similar to gdb_print_host_address) or else maybe just > > disable debug output for this field. > > How do I disable printing? I think you said previously that '0' would > disable it, but that didn't work. Well, '0' (should really be something like (char *)0) will not *disable* debug output, strictly speaking, but the output will simply always be <nil>, which should be fine ... As I said above, the cleaner solution would be to define a routine like "host_address_to_string" along the lines of core_addr_to_string but using the method in gdb_print_host_address. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-02-18 18:42 ` Ulrich Weigand 2008-02-27 17:07 ` Carlos Eduardo Seo @ 2008-03-10 14:22 ` Carlos Eduardo Seo 2008-03-17 19:07 ` Ulrich Weigand 1 sibling, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-03-10 14:22 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 110 bytes --] Corrected, as you suggested. Regards, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center [-- Attachment #2: gdbarch-core-regset.diff --] [-- Type: text/x-patch, Size: 11799 bytes --] 2008-03-10 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * gdbarch.c: Refreshed. * gdbarch.h: Refreshed. * gdbarch.sh: Added new gdbarch struct core_regset_sections. * regset.h (core_regset_section): Declare. * ppc-linux-tdep.c: (ppc_regset_sections): Register sections list for ppc. (ppc_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * linux-nat.c (linux_nat_do_thread_registers): Added support to the new gdbarch struct core_regset_sections. * i386-linux-tdep.c (i386_regset_sections): Register sections list for i386. (i386_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * arch-utils.c (default_regset_sections): Declare. * arch-utils.h (default_regset_sections): Declare. Index: src/gdb/gdbarch.c =================================================================== --- src.orig/gdb/gdbarch.c +++ src/gdb/gdbarch.c @@ -222,6 +222,7 @@ struct gdbarch gdbarch_register_reggroup_p_ftype *register_reggroup_p; gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument; gdbarch_regset_from_core_section_ftype *regset_from_core_section; + struct core_regset_section * core_regset_sections; gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries; int vtable_function_descriptors; int vbit_in_delta; @@ -344,6 +345,7 @@ struct gdbarch startup_gdbarch = default_register_reggroup_p, /* register_reggroup_p */ 0, /* fetch_pointer_argument */ 0, /* regset_from_core_section */ + 0, /* core_regset_sections */ 0, /* core_xfer_shared_libraries */ 0, /* vtable_function_descriptors */ 0, /* vbit_in_delta */ @@ -582,6 +584,8 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of register_reggroup_p, invalid_p == 0 */ /* Skip verify of fetch_pointer_argument, has predicate */ /* Skip verify of regset_from_core_section, has predicate */ + if (gdbarch->core_regset_sections == 0) + gdbarch->core_regset_sections = default_regset_sections; /* Skip verify of core_xfer_shared_libraries, has predicate */ /* Skip verify of vtable_function_descriptors, invalid_p == 0 */ /* Skip verify of vbit_in_delta, invalid_p == 0 */ @@ -694,6 +698,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s "gdbarch_dump: core_read_description = <0x%lx>\n", (long) gdbarch->core_read_description); fprintf_unfiltered (file, + "gdbarch_dump: core_regset_sections = %s\n", + (char *) '0'); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n", gdbarch_core_xfer_shared_libraries_p (gdbarch)); fprintf_unfiltered (file, @@ -2810,6 +2817,22 @@ set_gdbarch_regset_from_core_section (st gdbarch->regset_from_core_section = regset_from_core_section; } +struct core_regset_section * +gdbarch_core_regset_sections (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_core_regset_sections called\n"); + return gdbarch->core_regset_sections; +} + +void +set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, + struct core_regset_section * core_regset_sections) +{ + gdbarch->core_regset_sections = core_regset_sections; +} + int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch) { Index: src/gdb/gdbarch.h =================================================================== --- src.orig/gdb/gdbarch.h +++ src/gdb/gdbarch.h @@ -50,6 +50,7 @@ struct target_ops; struct obstack; struct bp_target_info; struct target_desc; +struct core_regset_section; extern struct gdbarch *current_gdbarch; @@ -626,6 +627,11 @@ typedef const struct regset * (gdbarch_r extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size); extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section); +/* Supported register notes in core files */ + +extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch); +extern void set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, struct core_regset_section * core_regset_sections); + /* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from core file into buffer READBUF with length LEN. */ Index: src/gdb/gdbarch.sh =================================================================== --- src.orig/gdb/gdbarch.sh +++ src/gdb/gdbarch.sh @@ -594,6 +594,9 @@ F:CORE_ADDR:fetch_pointer_argument:struc # name SECT_NAME and size SECT_SIZE. M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size +# Supported register notes in core files +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::default_regset_sections::(char *) '0' + # Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from # core file into buffer READBUF with length LEN. M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len @@ -729,6 +732,7 @@ struct target_ops; struct obstack; struct bp_target_info; struct target_desc; +struct core_regset_section; extern struct gdbarch *current_gdbarch; EOF Index: src/gdb/regset.h =================================================================== --- src.orig/gdb/regset.h +++ src/gdb/regset.h @@ -20,6 +20,12 @@ #ifndef REGSET_H #define REGSET_H 1 +struct core_regset_section +{ + const char *sect_name; + int size; +}; + struct gdbarch; struct regcache; Index: src/gdb/ppc-linux-tdep.c =================================================================== --- src.orig/gdb/ppc-linux-tdep.c +++ src/gdb/ppc-linux-tdep.c @@ -37,6 +37,16 @@ #include "trad-frame.h" #include "frame-unwind.h" #include "tramp-frame.h" +#include <sys/procfs.h> +#include "gregset.h" + +static struct core_regset_section ppc_regset_sections[] = +{ + { ".reg", sizeof (gdb_gregset_t) }, + { ".reg2", sizeof (gdb_fpregset_t) }, + { ".reg-ppc-vmx", 544 }, + { NULL, 0 } +}; static CORE_ADDR ppc_linux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) @@ -946,6 +956,10 @@ ppc_linux_init_abi (struct gdbarch_info tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sigaction_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sighandler_tramp_frame); } + + /* Register sections. */ + set_gdbarch_core_regset_sections (gdbarch, ppc_regset_sections); + set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section); /* Enable TLS support. */ Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -2631,6 +2631,8 @@ linux_nat_do_thread_registers (bfd *obfd const struct regset *regset; int core_regset_p; struct cleanup *old_chain; + struct core_regset_section *sect_list; + char *gdb_regset; old_chain = save_inferior_ptid (); inferior_ptid = ptid; @@ -2638,6 +2640,8 @@ linux_nat_do_thread_registers (bfd *obfd do_cleanups (old_chain); core_regset_p = gdbarch_regset_from_core_section_p (gdbarch); + sect_list = gdbarch_core_regset_sections (gdbarch); + if (core_regset_p && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg", sizeof (gregs))) != NULL @@ -2653,35 +2657,31 @@ linux_nat_do_thread_registers (bfd *obfd lwp, stop_signal, &gregs); - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", - sizeof (fpregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpregs, sizeof (fpregs)); - else - fill_fpregset (regcache, &fpregs, -1); - - note_data = (char *) elfcore_write_prfpreg (obfd, - note_data, - note_size, - &fpregs, sizeof (fpregs)); - -#ifdef FILL_FPXREGSET - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", - sizeof (fpxregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpxregs, sizeof (fpxregs)); - else - fill_fpxregset (regcache, &fpxregs, -1); - - note_data = (char *) elfcore_write_prxfpreg (obfd, - note_data, - note_size, - &fpxregs, sizeof (fpxregs)); -#endif + /* The loop below uses the new struct core_regset_section, which stores + the supported section names and sizes for the core file. Note that + note PRSTATUS needs to be treated specially. But the other notes are + structurally the same, so they can benefit from the new struct. */ + + if (core_regset_p && sect_list != NULL) + while ((++sect_list)->sect_name != NULL) + { + if ((regset = gdbarch_regset_from_core_section (gdbarch, + sect_list->sect_name, + (*sect_list).size)) + != NULL && regset->collect_regset != NULL) + { + gdb_regset = xmalloc ((*sect_list).size); + regset->collect_regset (regset, regcache, -1, + gdb_regset, (*sect_list).size); + note_data = (char *) elfcore_write_register_note (obfd, + note_data, + note_size, + sect_list->sect_name, + gdb_regset, + (*sect_list).size); + xfree (gdb_regset); + } + } return note_data; } Index: src/gdb/i386-linux-tdep.c =================================================================== --- src.orig/gdb/i386-linux-tdep.c +++ src/gdb/i386-linux-tdep.c @@ -28,12 +28,24 @@ #include "reggroups.h" #include "dwarf2-frame.h" #include "gdb_string.h" - +#include <sys/procfs.h> +#include "gregset.h" #include "i386-tdep.h" #include "i386-linux-tdep.h" #include "glibc-tdep.h" #include "solib-svr4.h" #include "symtab.h" +#include "regset.h" + +static struct core_regset_section i386_regset_sections[] = +{ + { ".reg", sizeof (gdb_gregset_t) }, + { ".reg2", sizeof (gdb_fpregset_t) }, +#ifdef FILL_FPXREGSET + { ".reg-xfp", sizeof (gdb_fpxregset_t) }, +#endif + { NULL, 0 } +}; /* Return the name of register REG. */ @@ -446,6 +458,10 @@ i386_linux_init_abi (struct gdbarch_info /* Enable TLS support. */ set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); + + /* Register sections. */ + set_gdbarch_core_regset_sections (gdbarch, i386_regset_sections); + } /* Provide a prototype to silence -Wmissing-prototypes. */ Index: src/gdb/arch-utils.c =================================================================== --- src.orig/gdb/arch-utils.c +++ src/gdb/arch-utils.c @@ -31,11 +31,19 @@ #include "gdbcore.h" #include "osabi.h" #include "target-descriptions.h" - +#include <sys/procfs.h> +#include "gregset.h" #include "version.h" +#include "regset.h" #include "floatformat.h" +struct core_regset_section default_regset_sections[] = +{ + { ".reg", sizeof (gdb_gregset_t) }, + { ".reg2", sizeof (gdb_fpregset_t) }, + { NULL, 0 } +}; int legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum) Index: src/gdb/arch-utils.h =================================================================== --- src.orig/gdb/arch-utils.h +++ src/gdb/arch-utils.h @@ -20,13 +20,15 @@ #ifndef GDBARCH_UTILS_H #define GDBARCH_UTILS_H - +#include "regset.h" struct gdbarch; struct frame_info; struct minimal_symbol; struct type; struct gdbarch_info; +extern struct core_regset_section default_regset_sections[]; + /* gdbarch trace variable */ extern int gdbarch_debug; ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-10 14:22 ` Carlos Eduardo Seo @ 2008-03-17 19:07 ` Ulrich Weigand 2008-03-20 15:31 ` Carlos Eduardo Seo 2008-03-27 1:52 ` Carlos Eduardo Seo 0 siblings, 2 replies; 37+ messages in thread From: Ulrich Weigand @ 2008-03-17 19:07 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > +# Supported register notes in core files '.' at the end. > +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::default_regset_sections::(char *) '0' Not '0' -- just 0. (That *is* a difference!) > @@ -2653,35 +2657,31 @@ linux_nat_do_thread_registers (bfd *obfd > lwp, > stop_signal, &gregs); > > - if (core_regset_p > - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", > - sizeof (fpregs))) != NULL > - && regset->collect_regset != NULL) > - regset->collect_regset (regset, regcache, -1, > - &fpregs, sizeof (fpregs)); > - else > - fill_fpregset (regcache, &fpregs, -1); > - > - note_data = (char *) elfcore_write_prfpreg (obfd, > - note_data, > - note_size, > - &fpregs, sizeof (fpregs)); Ah. I think I asked you to do this, but I overlooked something here: there are quite a number of Linux targets that either do not define gdbarch_regset_from_core_section or do not implement a collect_regset function. We don't want to break those, so we'll probably have to keep the fall-back to fill_fpregset for now. > -#ifdef FILL_FPXREGSET > - if (core_regset_p > - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", > - sizeof (fpxregs))) != NULL > - && regset->collect_regset != NULL) > - regset->collect_regset (regset, regcache, -1, > - &fpxregs, sizeof (fpxregs)); > - else > - fill_fpxregset (regcache, &fpxregs, -1); > - > - note_data = (char *) elfcore_write_prxfpreg (obfd, > - note_data, > - note_size, > - &fpxregs, sizeof (fpxregs)); > -#endif But *this* definitely can go away, as the i386 target does use gdbarch_regset_from_core_section with collect_regset. > + /* The loop below uses the new struct core_regset_section, which stores > + the supported section names and sizes for the core file. Note that > + note PRSTATUS needs to be treated specially. But the other notes are > + structurally the same, so they can benefit from the new struct. */ > + > + if (core_regset_p && sect_list != NULL) sect_list cannot really be NULL as it has a default. > + while ((++sect_list)->sect_name != NULL) This implicitly assumes that ".reg" must be the very first element. I'd rather see an explicit check of the type /* ".reg" was already handled above. */ if (strcmp (sect_list->sect_name, ".reg") == 0) continue; (And similarly for ".reg2" if we keep the special case above.) > + if ((regset = gdbarch_regset_from_core_section (gdbarch, > + sect_list->sect_name, > + (*sect_list).size)) I'd rather use sect_list->size (here and elsewhere). > +#include <sys/procfs.h> > +#include "gregset.h" > #include "i386-tdep.h" > #include "i386-linux-tdep.h" > #include "glibc-tdep.h" > #include "solib-svr4.h" > #include "symtab.h" > +#include "regset.h" These need Makefile.in dependency list changes. > +#include <sys/procfs.h> > +#include "gregset.h" > #include "version.h" > +#include "regset.h" Likewise. > Index: src/gdb/arch-utils.h > +#include "regset.h" > struct gdbarch; > struct frame_info; > struct minimal_symbol; > struct type; > struct gdbarch_info; > > +extern struct core_regset_section default_regset_sections[]; I'd prefer *not* to include a new header file here; a forward declaration of the struct should be enough: struct core_regset_section; Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-17 19:07 ` Ulrich Weigand @ 2008-03-20 15:31 ` Carlos Eduardo Seo 2008-03-25 20:13 ` Ulrich Weigand 2008-03-27 1:52 ` Carlos Eduardo Seo 1 sibling, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-03-20 15:31 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List Thanks for the review. I already corrected the points you mentioned. One thing remains: Ulrich Weigand wrote: >> Index: src/gdb/arch-utils.h > >> +#include "regset.h" >> struct gdbarch; >> struct frame_info; >> struct minimal_symbol; >> struct type; >> struct gdbarch_info; >> >> +extern struct core_regset_section default_regset_sections[]; > > I'd prefer *not* to include a new header file here; a forward > declaration of the struct should be enough: > struct core_regset_section; A forward declaration here doesn't seem to work. Any ideas? -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-20 15:31 ` Carlos Eduardo Seo @ 2008-03-25 20:13 ` Ulrich Weigand 2008-03-25 21:31 ` Andreas Schwab 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-03-25 20:13 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > Ulrich Weigand wrote: > > I'd prefer *not* to include a new header file here; a forward > > declaration of the struct should be enough: > > struct core_regset_section; > > A forward declaration here doesn't seem to work. What exactly seems to be the problem? The following code should be valid C, and compiles fine with GCC: struct core_regset_section; extern struct core_regset_section default_regset_sections[]; Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-25 20:13 ` Ulrich Weigand @ 2008-03-25 21:31 ` Andreas Schwab 2008-03-25 21:54 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Andreas Schwab @ 2008-03-25 21:31 UTC (permalink / raw) To: Ulrich Weigand; +Cc: Carlos Eduardo Seo, GDB Patches Mailing List "Ulrich Weigand" <uweigand@de.ibm.com> writes: > What exactly seems to be the problem? The following > code should be valid C, and compiles fine with GCC: Your GCC is buggy. > struct core_regset_section; > extern struct core_regset_section default_regset_sections[]; The C standard does not allow this. An array declaration requires a complete element type. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-25 21:31 ` Andreas Schwab @ 2008-03-25 21:54 ` Ulrich Weigand 2008-03-25 22:46 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-03-25 21:54 UTC (permalink / raw) To: Andreas Schwab; +Cc: Carlos Eduardo Seo, GDB Patches Mailing List Andreas Schwab wrote: > "Ulrich Weigand" <uweigand@de.ibm.com> writes: > > > What exactly seems to be the problem? The following > > code should be valid C, and compiles fine with GCC: > > Your GCC is buggy. Interesting. GCC 3.4.6 accepts it; GCC 4.1.1 does indeed reject it with: error: array type has incomplete element type > > struct core_regset_section; > > extern struct core_regset_section default_regset_sections[]; > > The C standard does not allow this. An array declaration requires a > complete element type. It looks like I was indeed misremembering this. I thought an extern declaration should be OK, as long as the declared identifier is only ever used in contexts where it decays to a pointer ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-25 21:54 ` Ulrich Weigand @ 2008-03-25 22:46 ` Carlos Eduardo Seo 2008-03-26 11:28 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-03-25 22:46 UTC (permalink / raw) To: Ulrich Weigand; +Cc: Andreas Schwab, GDB Patches Mailing List Ulrich Weigand wrote: > > Interesting. GCC 3.4.6 accepts it; GCC 4.1.1 does indeed > reject it with: > error: array type has incomplete element type > Exactly. GCC 4.x has more strict checks and, therefore doesn't allow this declaration. Sorry for not including the error in my previous message. So, is it OK to include that header? Thanks, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-25 22:46 ` Carlos Eduardo Seo @ 2008-03-26 11:28 ` Ulrich Weigand 0 siblings, 0 replies; 37+ messages in thread From: Ulrich Weigand @ 2008-03-26 11:28 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: Andreas Schwab, GDB Patches Mailing List Carlos Eduardo Seo wrote: > Exactly. GCC 4.x has more strict checks and, therefore doesn't allow > this declaration. Sorry for not including the error in my previous message. > > So, is it OK to include that header? Yes, this is OK then. Sorry for the confusion. Please make sure you also update the Makefile.in dependency rules. Thanks, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-17 19:07 ` Ulrich Weigand 2008-03-20 15:31 ` Carlos Eduardo Seo @ 2008-03-27 1:52 ` Carlos Eduardo Seo 2008-03-27 9:00 ` Andreas Schwab 2008-03-27 19:54 ` Ulrich Weigand 1 sibling, 2 replies; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-03-27 1:52 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 498 bytes --] Ulrich Weigand wrote: > >> +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::default_regset_sections::(char *) '0' > > Not '0' -- just 0. (That *is* a difference!) > Yes, I know. But gcc 4.x will complain about reading through a null pointer if I use 0. I'm attaching a new patch with the modifications you suggested. If you're OK with that, only this small issue remains. :) Regards, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center [-- Attachment #2: gdbarch-core-regset.diff --] [-- Type: text/x-patch, Size: 13829 bytes --] 2008-03-26 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * gdbarch.c: Refreshed. * gdbarch.h: Refreshed. * gdbarch.sh: Added new gdbarch struct core_regset_sections. * regset.h (core_regset_section): Declare. * ppc-linux-tdep.c: (ppc_regset_sections): Register sections list for ppc. (ppc_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * linux-nat.c (linux_nat_do_thread_registers): Added support to the new gdbarch struct core_regset_sections. * i386-linux-tdep.c (i386_regset_sections): Register sections list for i386. (i386_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * arch-utils.c (default_regset_sections): Declare. * arch-utils.h (default_regset_sections): Declare. Index: src/gdb/gdbarch.c =================================================================== --- src.orig/gdb/gdbarch.c +++ src/gdb/gdbarch.c @@ -222,6 +222,7 @@ struct gdbarch gdbarch_register_reggroup_p_ftype *register_reggroup_p; gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument; gdbarch_regset_from_core_section_ftype *regset_from_core_section; + struct core_regset_section * core_regset_sections; gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries; int vtable_function_descriptors; int vbit_in_delta; @@ -344,6 +345,7 @@ struct gdbarch startup_gdbarch = default_register_reggroup_p, /* register_reggroup_p */ 0, /* fetch_pointer_argument */ 0, /* regset_from_core_section */ + 0, /* core_regset_sections */ 0, /* core_xfer_shared_libraries */ 0, /* vtable_function_descriptors */ 0, /* vbit_in_delta */ @@ -582,6 +584,8 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of register_reggroup_p, invalid_p == 0 */ /* Skip verify of fetch_pointer_argument, has predicate */ /* Skip verify of regset_from_core_section, has predicate */ + if (gdbarch->core_regset_sections == 0) + gdbarch->core_regset_sections = default_regset_sections; /* Skip verify of core_xfer_shared_libraries, has predicate */ /* Skip verify of vtable_function_descriptors, invalid_p == 0 */ /* Skip verify of vbit_in_delta, invalid_p == 0 */ @@ -694,6 +698,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s "gdbarch_dump: core_read_description = <0x%lx>\n", (long) gdbarch->core_read_description); fprintf_unfiltered (file, + "gdbarch_dump: core_regset_sections = %s\n", + (char *) '0'); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n", gdbarch_core_xfer_shared_libraries_p (gdbarch)); fprintf_unfiltered (file, @@ -2810,6 +2817,22 @@ set_gdbarch_regset_from_core_section (st gdbarch->regset_from_core_section = regset_from_core_section; } +struct core_regset_section * +gdbarch_core_regset_sections (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_core_regset_sections called\n"); + return gdbarch->core_regset_sections; +} + +void +set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, + struct core_regset_section * core_regset_sections) +{ + gdbarch->core_regset_sections = core_regset_sections; +} + int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch) { Index: src/gdb/gdbarch.h =================================================================== --- src.orig/gdb/gdbarch.h +++ src/gdb/gdbarch.h @@ -50,6 +50,7 @@ struct target_ops; struct obstack; struct bp_target_info; struct target_desc; +struct core_regset_section; extern struct gdbarch *current_gdbarch; @@ -626,6 +627,11 @@ typedef const struct regset * (gdbarch_r extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size); extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section); +/* Supported register notes in core files. */ + +extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch); +extern void set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, struct core_regset_section * core_regset_sections); + /* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from core file into buffer READBUF with length LEN. */ Index: src/gdb/gdbarch.sh =================================================================== --- src.orig/gdb/gdbarch.sh +++ src/gdb/gdbarch.sh @@ -594,6 +594,9 @@ F:CORE_ADDR:fetch_pointer_argument:struc # name SECT_NAME and size SECT_SIZE. M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size +# Supported register notes in core files. +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::default_regset_sections::(char *) '0' + # Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from # core file into buffer READBUF with length LEN. M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len @@ -729,6 +732,7 @@ struct target_ops; struct obstack; struct bp_target_info; struct target_desc; +struct core_regset_section; extern struct gdbarch *current_gdbarch; EOF Index: src/gdb/regset.h =================================================================== --- src.orig/gdb/regset.h +++ src/gdb/regset.h @@ -20,6 +20,12 @@ #ifndef REGSET_H #define REGSET_H 1 +struct core_regset_section +{ + const char *sect_name; + int size; +}; + struct gdbarch; struct regcache; Index: src/gdb/ppc-linux-tdep.c =================================================================== --- src.orig/gdb/ppc-linux-tdep.c +++ src/gdb/ppc-linux-tdep.c @@ -37,6 +37,16 @@ #include "trad-frame.h" #include "frame-unwind.h" #include "tramp-frame.h" +#include <sys/procfs.h> +#include "gregset.h" + +static struct core_regset_section ppc_regset_sections[] = +{ + { ".reg", sizeof (gdb_gregset_t) }, + { ".reg2", sizeof (gdb_fpregset_t) }, + { ".reg-ppc-vmx", 544 }, + { NULL, 0 } +}; static CORE_ADDR ppc_linux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) @@ -950,6 +960,10 @@ ppc_linux_init_abi (struct gdbarch_info tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sigaction_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sighandler_tramp_frame); } + + /* Register sections. */ + set_gdbarch_core_regset_sections (gdbarch, ppc_regset_sections); + set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section); /* Enable TLS support. */ Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -2987,15 +2987,15 @@ linux_nat_do_thread_registers (bfd *obfd { gdb_gregset_t gregs; gdb_fpregset_t fpregs; -#ifdef FILL_FPXREGSET - gdb_fpxregset_t fpxregs; -#endif + unsigned long lwp = ptid_get_lwp (ptid); struct regcache *regcache = get_thread_regcache (ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); const struct regset *regset; int core_regset_p; struct cleanup *old_chain; + struct core_regset_section *sect_list; + char *gdb_regset; old_chain = save_inferior_ptid (); inferior_ptid = ptid; @@ -3003,6 +3003,8 @@ linux_nat_do_thread_registers (bfd *obfd do_cleanups (old_chain); core_regset_p = gdbarch_regset_from_core_section_p (gdbarch); + sect_list = gdbarch_core_regset_sections (gdbarch); + if (core_regset_p && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg", sizeof (gregs))) != NULL @@ -3018,35 +3020,46 @@ linux_nat_do_thread_registers (bfd *obfd lwp, stop_signal, &gregs); - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", - sizeof (fpregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpregs, sizeof (fpregs)); - else - fill_fpregset (regcache, &fpregs, -1); - - note_data = (char *) elfcore_write_prfpreg (obfd, - note_data, - note_size, - &fpregs, sizeof (fpregs)); - -#ifdef FILL_FPXREGSET - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", - sizeof (fpxregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpxregs, sizeof (fpxregs)); - else - fill_fpxregset (regcache, &fpxregs, -1); - - note_data = (char *) elfcore_write_prxfpreg (obfd, - note_data, - note_size, - &fpxregs, sizeof (fpxregs)); -#endif + /* The loop below uses the new struct core_regset_section, which stores + the supported section names and sizes for the core file. Note that + note PRSTATUS needs to be treated specially. But the other notes are + structurally the same, so they can benefit from the new struct. */ + + if (core_regset_p) + while ((++sect_list)->sect_name != NULL) + { + /* .reg was already handled above */ + if (strcmp (sect_list->sect_name, ".reg") == 0) + continue; + if ((regset = gdbarch_regset_from_core_section (gdbarch, + sect_list->sect_name, + sect_list->size)) + != NULL && regset->collect_regset != NULL) + { + gdb_regset = xmalloc (sect_list->size); + regset->collect_regset (regset, regcache, -1, + gdb_regset, sect_list->size); + note_data = (char *) elfcore_write_register_note (obfd, + note_data, + note_size, + sect_list->sect_name, + gdb_regset, + sect_list->size); + xfree (gdb_regset); + } + /* For the architectures that need a fill_fpregset fallback */ + else + { + if (strcmp (sect_list->sect_name, ".reg2") == 0) + { + fill_fpregset (regcache, &fpregs, -1); + note_data = (char *) elfcore_write_prfpreg (obfd, + note_data, + note_size, + &fpregs, sizeof (fpregs)); + } + } + } return note_data; } Index: src/gdb/i386-linux-tdep.c =================================================================== --- src.orig/gdb/i386-linux-tdep.c +++ src/gdb/i386-linux-tdep.c @@ -28,12 +28,24 @@ #include "reggroups.h" #include "dwarf2-frame.h" #include "gdb_string.h" - +#include <sys/procfs.h> +#include "gregset.h" #include "i386-tdep.h" #include "i386-linux-tdep.h" #include "glibc-tdep.h" #include "solib-svr4.h" #include "symtab.h" +#include "regset.h" + +static struct core_regset_section i386_regset_sections[] = +{ + { ".reg", sizeof (gdb_gregset_t) }, + { ".reg2", sizeof (gdb_fpregset_t) }, +#ifdef FILL_FPXREGSET + { ".reg-xfp", sizeof (gdb_fpxregset_t) }, +#endif + { NULL, 0 } +}; /* Return the name of register REG. */ @@ -446,6 +458,10 @@ i386_linux_init_abi (struct gdbarch_info /* Enable TLS support. */ set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); + + /* Register sections. */ + set_gdbarch_core_regset_sections (gdbarch, i386_regset_sections); + } /* Provide a prototype to silence -Wmissing-prototypes. */ Index: src/gdb/arch-utils.c =================================================================== --- src.orig/gdb/arch-utils.c +++ src/gdb/arch-utils.c @@ -31,11 +31,19 @@ #include "gdbcore.h" #include "osabi.h" #include "target-descriptions.h" - +#include <sys/procfs.h> +#include "gregset.h" #include "version.h" +#include "regset.h" #include "floatformat.h" +struct core_regset_section default_regset_sections[] = +{ + { ".reg", sizeof (gdb_gregset_t) }, + { ".reg2", sizeof (gdb_fpregset_t) }, + { NULL, 0 } +}; int legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum) Index: src/gdb/arch-utils.h =================================================================== --- src.orig/gdb/arch-utils.h +++ src/gdb/arch-utils.h @@ -21,11 +21,16 @@ #ifndef GDBARCH_UTILS_H #define GDBARCH_UTILS_H +#include "regset.h" + struct gdbarch; struct frame_info; struct minimal_symbol; struct type; struct gdbarch_info; +struct core_regset_section; + +extern struct core_regset_section default_regset_sections[]; /* gdbarch trace variable */ extern int gdbarch_debug; Index: src/gdb/Makefile.in =================================================================== --- src.orig/gdb/Makefile.in +++ src/gdb/Makefile.in @@ -1892,7 +1892,7 @@ annotate.o: annotate.c $(defs_h) $(annot arch-utils.o: arch-utils.c $(defs_h) $(arch_utils_h) $(buildsym_h) \ $(gdbcmd_h) $(inferior_h) $(gdb_string_h) $(regcache_h) \ $(gdb_assert_h) $(sim_regno_h) $(gdbcore_h) $(osabi_h) $(version_h) \ - $(floatformat_h) $(target_descriptions_h) + $(floatformat_h) $(target_descriptions_h) $(gregset_h) $(regset_h) arm-linux-nat.o: arm-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \ $(gdb_string_h) $(regcache_h) $(arm_tdep_h) $(gregset_h) \ $(target_h) $(linux_nat_h) $(gdb_proc_service_h) $(arm_linux_tdep_h) \ @@ -2228,7 +2228,8 @@ i386-linux-nat.o: i386-linux-nat.c $(def i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \ $(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \ $(dwarf2_frame_h) $(gdb_string_h) $(i386_tdep_h) \ - $(i386_linux_tdep_h) $(glibc_tdep_h) $(solib_svr4_h) $(symtab_h) + $(i386_linux_tdep_h) $(glibc_tdep_h) $(solib_svr4_h) $(symtab_h) \ + $(gregset_h) $(regset_h) i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h) \ $(target_h) i386nbsd-nat.o: i386nbsd-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \ ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-27 1:52 ` Carlos Eduardo Seo @ 2008-03-27 9:00 ` Andreas Schwab 2008-03-27 19:54 ` Ulrich Weigand 1 sibling, 0 replies; 37+ messages in thread From: Andreas Schwab @ 2008-03-27 9:00 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: Ulrich Weigand, GDB Patches Mailing List Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> writes: > @@ -694,6 +698,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s > "gdbarch_dump: core_read_description = <0x%lx>\n", > (long) gdbarch->core_read_description); > fprintf_unfiltered (file, > + "gdbarch_dump: core_regset_sections = %s\n", > + (char *) '0'); That doesn't make any sense, (char *) '0' is not a valid pointer, let alone a string. This will crash. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-27 1:52 ` Carlos Eduardo Seo 2008-03-27 9:00 ` Andreas Schwab @ 2008-03-27 19:54 ` Ulrich Weigand 2008-03-28 20:41 ` Carlos Eduardo Seo 1 sibling, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-03-27 19:54 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > >> +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::default_regset_sections::(char *) '0' > > > > Not '0' -- just 0. (That *is* a difference!) > > > > Yes, I know. But gcc 4.x will complain about reading through a null > pointer if I use 0. As Andreas pointed out, (char *) '0' is definitely broken -- this will interpret the numerical value of '0' (i.e. 48 in ASCII) as pointer value and try to dereference it, which will certainly crash. I had suggested to use a null pointer as this will be caught at run-time and printed as "(null)". However, re-thinking it, this is not actually guaranteed by the standard -- which is probably why you're seeing a warning ... Unfortunately, I've noticed another, more serious problem: > Index: src/gdb/arch-utils.c > =================================================================== > --- src.orig/gdb/arch-utils.c > +++ src/gdb/arch-utils.c > @@ -31,11 +31,19 @@ > #include "gdbcore.h" > #include "osabi.h" > #include "target-descriptions.h" > - > +#include <sys/procfs.h> > +#include "gregset.h" > #include "version.h" > +#include "regset.h" > > #include "floatformat.h" > > +struct core_regset_section default_regset_sections[] = > +{ > + { ".reg", sizeof (gdb_gregset_t) }, > + { ".reg2", sizeof (gdb_fpregset_t) }, > + { NULL, 0 } > +}; This isn't really feasible: you cannot simply include the platform-specific <sys/procfs.h> into a generic file -- it may not even be available on some platforms; and on other platforms it may not provide the required gregset_t type. I'm sorry for all the back-and-forth on this, but it seems we do have to implement a Linux-specific fallback to that; I don't see how we can do a generic default. To do so, you'll need to let the gdbarch variable default to NULL, and in linux_nat_do_thread_registers perform the fpregset fallback if that is the case. ppc and i386 would then be the only architectures that install the new gdbarch variable; over time, the remaining Linux platforms should follow suite and we can remove the fallbacks. > Index: src/gdb/ppc-linux-tdep.c > =================================================================== > --- src.orig/gdb/ppc-linux-tdep.c > +++ src/gdb/ppc-linux-tdep.c > @@ -37,6 +37,16 @@ > #include "trad-frame.h" > #include "frame-unwind.h" > #include "tramp-frame.h" > +#include <sys/procfs.h> You cannot include a platform-specific header into a -tdep file either, this file is also used for cross-debugging from arbitrary hosts. > +#include "gregset.h" > + > +static struct core_regset_section ppc_regset_sections[] = > +{ > + { ".reg", sizeof (gdb_gregset_t) }, > + { ".reg2", sizeof (gdb_fpregset_t) }, However, you can simply use all numerical values here -- the sizes of the register sections in PowerPC core files are constants. > + { ".reg-ppc-vmx", 544 }, > + { NULL, 0 } > +}; The same applies to the i386 changes: > +++ src/gdb/i386-linux-tdep.c > @@ -28,12 +28,24 @@ > #include "reggroups.h" > #include "dwarf2-frame.h" > #include "gdb_string.h" > - > +#include <sys/procfs.h> > +#include "gregset.h" > #include "i386-tdep.h" > #include "i386-linux-tdep.h" > #include "glibc-tdep.h" > #include "solib-svr4.h" > #include "symtab.h" > +#include "regset.h" > + > +static struct core_regset_section i386_regset_sections[] = > +{ > + { ".reg", sizeof (gdb_gregset_t) }, > + { ".reg2", sizeof (gdb_fpregset_t) }, > +#ifdef FILL_FPXREGSET > + { ".reg-xfp", sizeof (gdb_fpxregset_t) }, > +#endif > + { NULL, 0 } > +}; One more issue in linux-nat.c: > + if (core_regset_p) > + while ((++sect_list)->sect_name != NULL) The ++sect_list still skips the first entry unconditionally. You should increment sect_list at the *end* of the loop. Once again, sorry for leading you down a wrong track here. Thanks for your continued work to fix this problem ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-27 19:54 ` Ulrich Weigand @ 2008-03-28 20:41 ` Carlos Eduardo Seo 2008-03-31 19:19 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-03-28 20:41 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List Ulrich Weigand wrote: > > I'm sorry for all the back-and-forth on this, but it seems > we do have to implement a Linux-specific fallback to that; > I don't see how we can do a generic default. To do so, > you'll need to let the gdbarch variable default to NULL, > and in linux_nat_do_thread_registers perform the fpregset > fallback if that is the case. ppc and i386 would then be > the only architectures that install the new gdbarch variable; > over time, the remaining Linux platforms should follow suite > and we can remove the fallbacks. So, you're suggesting that we go back to something similar I did here in linux_nat_do_thread_registers? http://sourceware.org/ml/gdb-patches/2008-02/msg00157.html Thanks, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-28 20:41 ` Carlos Eduardo Seo @ 2008-03-31 19:19 ` Ulrich Weigand 2008-05-09 19:27 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-03-31 19:19 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > So, you're suggesting that we go back to something similar I did here in > linux_nat_do_thread_registers? > > http://sourceware.org/ml/gdb-patches/2008-02/msg00157.html Yes. It would still be good to convert x86 to we can at least get rid of the FILL_FPXREGSET special case ... Thanks, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-03-31 19:19 ` Ulrich Weigand @ 2008-05-09 19:27 ` Carlos Eduardo Seo 2008-05-09 20:30 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-05-09 19:27 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List Ulrich Weigand wrote: > Carlos Eduardo Seo wrote: > >> So, you're suggesting that we go back to something similar I did here in >> linux_nat_do_thread_registers? >> >> http://sourceware.org/ml/gdb-patches/2008-02/msg00157.html > > Yes. It would still be good to convert x86 to we can at least > get rid of the FILL_FPXREGSET special case ... > Hello Sorry for the delay, but I was on vacation. The patch is almost ready; only the debug printf issue remains. My only question now is where is the best place to declare the 'host_address_to_string' conversion function? I thought about utils.c, but I don't think gdbarch.c will find it there. Regards, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-09 19:27 ` Carlos Eduardo Seo @ 2008-05-09 20:30 ` Ulrich Weigand 2008-05-10 1:33 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-05-09 20:30 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo: > The patch is almost ready; only the debug printf issue remains. My only > question now is where is the best place to declare the > 'host_address_to_string' conversion function? I thought about utils.c, > but I don't think gdbarch.c will find it there. I would suggest to place the definition in utils.c (next to gdb_print_host_address), and a prototype in defs.h (next to the prototype for gdb_print_host_address). As gdbarch.c does include defs.h, it will find it here ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-09 20:30 ` Ulrich Weigand @ 2008-05-10 1:33 ` Carlos Eduardo Seo 2008-05-14 4:22 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-05-10 1:33 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 496 bytes --] Ulrich Weigand wrote: > I would suggest to place the definition in utils.c (next to > gdb_print_host_address), and a prototype in defs.h (next to > the prototype for gdb_print_host_address). As gdbarch.c > does include defs.h, it will find it here ... > Ok, done. I also separated the ppc and x86 implementations from the main gcore stuff, to make it easier to analyze. Is this close to what you had in mind? Thanks, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center [-- Attachment #2: gcore-regnotes.diff --] [-- Type: text/x-patch, Size: 10373 bytes --] 2008-05-07 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * gdbarch.sh: Added new gdbarch struct core_regset_sections. * gdbarch.c: Refreshed. * gdbarch.h: Refreshed. * regset.h (core_regset_section): Declared. * linux-nat.c (linux_nat_do_thread_registers): Added support to the new gdbarch struct core_regset_sections. * utils.c (host_address_to_string): New function. * defs.h (host_address_to_string): New prototype. Index: src/gdb/gdbarch.sh =================================================================== --- src.orig/gdb/gdbarch.sh +++ src/gdb/gdbarch.sh @@ -600,6 +600,9 @@ F:CORE_ADDR:fetch_pointer_argument:struc # name SECT_NAME and size SECT_SIZE. M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size +# Supported register notes in a core file +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::host_address_to_string (gdbarch->core_regset_sections) + # Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from # core file into buffer READBUF with length LEN. M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len @@ -815,6 +818,7 @@ struct obstack; struct bp_target_info; struct target_desc; struct displaced_step_closure; +struct core_regset_section; extern struct gdbarch *current_gdbarch; EOF Index: src/gdb/gdbarch.c =================================================================== --- src.orig/gdb/gdbarch.c +++ src/gdb/gdbarch.c @@ -222,6 +222,7 @@ struct gdbarch gdbarch_register_reggroup_p_ftype *register_reggroup_p; gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument; gdbarch_regset_from_core_section_ftype *regset_from_core_section; + struct core_regset_section * core_regset_sections; gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries; int vtable_function_descriptors; int vbit_in_delta; @@ -352,6 +353,7 @@ struct gdbarch startup_gdbarch = default_register_reggroup_p, /* register_reggroup_p */ 0, /* fetch_pointer_argument */ 0, /* regset_from_core_section */ + 0, /* core_regset_sections */ 0, /* core_xfer_shared_libraries */ 0, /* vtable_function_descriptors */ 0, /* vbit_in_delta */ @@ -725,6 +727,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s "gdbarch_dump: core_read_description = <0x%lx>\n", (long) gdbarch->core_read_description); fprintf_unfiltered (file, + "gdbarch_dump: core_regset_sections = %s\n", + host_address_to_string (gdbarch->core_regset_sections)); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n", gdbarch_core_xfer_shared_libraries_p (gdbarch)); fprintf_unfiltered (file, @@ -2877,6 +2882,22 @@ set_gdbarch_regset_from_core_section (st gdbarch->regset_from_core_section = regset_from_core_section; } +struct core_regset_section * +gdbarch_core_regset_sections (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_core_regset_sections called\n"); + return gdbarch->core_regset_sections; +} + +void +set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, + struct core_regset_section * core_regset_sections) +{ + gdbarch->core_regset_sections = core_regset_sections; +} + int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch) { Index: src/gdb/gdbarch.h =================================================================== --- src.orig/gdb/gdbarch.h +++ src/gdb/gdbarch.h @@ -51,6 +51,7 @@ struct obstack; struct bp_target_info; struct target_desc; struct displaced_step_closure; +struct core_regset_section; extern struct gdbarch *current_gdbarch; @@ -634,6 +635,11 @@ typedef const struct regset * (gdbarch_r extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size); extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section); +/* Supported register notes in a core file */ + +extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch); +extern void set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, struct core_regset_section * core_regset_sections); + /* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from core file into buffer READBUF with length LEN. */ Index: src/gdb/regset.h =================================================================== --- src.orig/gdb/regset.h +++ src/gdb/regset.h @@ -23,6 +23,13 @@ struct gdbarch; struct regcache; +/* Data structure for the supported register notes in a core file */ +struct core_regset_section +{ + const char *sect_name; + int size; +}; + /* Data structure describing a register set. */ typedef void (supply_regset_ftype) (const struct regset *, struct regcache *, Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -3124,15 +3124,14 @@ linux_nat_do_thread_registers (bfd *obfd { gdb_gregset_t gregs; gdb_fpregset_t fpregs; -#ifdef FILL_FPXREGSET - gdb_fpxregset_t fpxregs; -#endif unsigned long lwp = ptid_get_lwp (ptid); struct regcache *regcache = get_thread_regcache (ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); const struct regset *regset; int core_regset_p; struct cleanup *old_chain; + struct core_regset_section *sect_list; + char *gdb_regset; old_chain = save_inferior_ptid (); inferior_ptid = ptid; @@ -3140,6 +3139,8 @@ linux_nat_do_thread_registers (bfd *obfd do_cleanups (old_chain); core_regset_p = gdbarch_regset_from_core_section_p (gdbarch); + sect_list = gdbarch_core_regset_sections (gdbarch); + if (core_regset_p && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg", sizeof (gregs))) != NULL @@ -3155,35 +3156,59 @@ linux_nat_do_thread_registers (bfd *obfd lwp, stop_signal, &gregs); - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", - sizeof (fpregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpregs, sizeof (fpregs)); + /* The loop below uses the new struct core_regset_section, which stores + the supported section names and sizes for the core file. Note that + note PRSTATUS needs to be treated specially. But the other notes are + structurally the same, so they can benefit from the new struct. */ + if (core_regset_p && sect_list != NULL) + while (sect_list->sect_name != NULL) + { + /* .reg was already handled above */ + if (strcmp (sect_list->sect_name, ".reg") == 0) + { + sect_list++; + continue; + } + if ((regset = gdbarch_regset_from_core_section (gdbarch, + sect_list->sect_name, + sect_list->size)) + != NULL && regset->collect_regset != NULL) + { + gdb_regset = xmalloc (sect_list->size); + regset->collect_regset (regset, regcache, -1, + gdb_regset, sect_list->size); + note_data = (char *) elfcore_write_register_note (obfd, + note_data, + note_size, + sect_list->sect_name, + gdb_regset, + sect_list->size); + xfree (gdb_regset); + } + sect_list++; + } + + /* For architectures that does not have the struct core_regset_section implemented, + we use the old method. When all the architectures have the new support, the code + below should be deprecated. The FILL_FPXREGSET fallback was removed since i386 + has the new method implemented. */ else - fill_fpregset (regcache, &fpregs, -1); - - note_data = (char *) elfcore_write_prfpreg (obfd, - note_data, - note_size, - &fpregs, sizeof (fpregs)); + { + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", + sizeof (fpregs))) != NULL + && regset->collect_regset != NULL) + regset->collect_regset (regset, regcache, -1, + &fpregs, sizeof (fpregs)); + else + fill_fpregset (regcache, &fpregs, -1); -#ifdef FILL_FPXREGSET - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", - sizeof (fpxregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpxregs, sizeof (fpxregs)); - else - fill_fpxregset (regcache, &fpxregs, -1); + note_data = (char *) elfcore_write_prfpreg (obfd, + note_data, + note_size, + &fpregs, sizeof (fpregs)); + } - note_data = (char *) elfcore_write_prxfpreg (obfd, - note_data, - note_size, - &fpxregs, sizeof (fpxregs)); -#endif return note_data; } Index: src/gdb/utils.c =================================================================== --- src.orig/gdb/utils.c +++ src/gdb/utils.c @@ -1075,7 +1075,6 @@ gdb_print_host_address (const void *addr fprintf_filtered (stream, "0x%lx", (unsigned long) addr); } -\f /* This function supports the query, nquery, and yquery functions. Ask user a y-or-n question and return 0 if answer is no, 1 if @@ -2869,6 +2868,14 @@ string_to_core_addr (const char *my_stri return addr; } +const char * +host_address_to_string (const void *addr) +{ + char *str = get_cell (); + sprintf (str, "0x%lx", (unsigned long) addr); + return str; +} + char * gdb_realpath (const char *filename) { Index: src/gdb/defs.h =================================================================== --- src.orig/gdb/defs.h +++ src/gdb/defs.h @@ -470,6 +470,8 @@ extern void fputstrn_unfiltered (const c /* Display the host ADDR on STREAM formatted as ``0x%x''. */ extern void gdb_print_host_address (const void *addr, struct ui_file *stream); +extern const char *host_address_to_string (const void *addr); + /* Convert a CORE_ADDR into a HEX string. paddr() is like %08lx. paddr_nz() is like %lx. paddr_u() is like %lu. paddr_width() is for ``%*''. */ [-- Attachment #3: gcore-regnotes-i386.diff --] [-- Type: text/x-patch, Size: 1239 bytes --] 2008-05-07 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * i386-linux-tdep.c (i386_regset_rections): New register sections list for i386. (i386_linux_init_abi): Initialized new gdbarch struct core_regset_sections. Index: src/gdb/i386-linux-tdep.c =================================================================== --- src.orig/gdb/i386-linux-tdep.c +++ src/gdb/i386-linux-tdep.c @@ -35,6 +35,18 @@ #include "solib-svr4.h" #include "symtab.h" #include "arch-utils.h" +#include "regset.h" + +/* Supported register note sections */ +static struct core_regset_section i386_regset_sections[] = +{ + { ".reg", 144 }, + { ".reg2", 108 }, +#ifdef FILL_FPXREGSET + { ".reg-xfp", 512 }, +#endif + { NULL, 0 } +}; /* Return the name of register REG. */ @@ -448,6 +460,9 @@ i386_linux_init_abi (struct gdbarch_info set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); + /* Install supported register note sections */ + set_gdbarch_core_regset_sections (gdbarch, i386_regset_sections); + /* Displaced stepping. */ set_gdbarch_displaced_step_copy_insn (gdbarch, simple_displaced_step_copy_insn); [-- Attachment #4: gcore-regnotes-ppc.diff --] [-- Type: text/x-patch, Size: 1239 bytes --] 2008-05-08 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * ppc-linux-tdep.c (ppc_regset_sections): Register sections list for ppc. (ppc_linux_init_abi): Initialized new gdbarch struct core_regset_sections Index: src/gdb/ppc-linux-tdep.c =================================================================== --- src.orig/gdb/ppc-linux-tdep.c +++ src/gdb/ppc-linux-tdep.c @@ -45,6 +45,14 @@ #include "features/rs6000/powerpc-altivec64l.c" #include "features/rs6000/powerpc-e500l.c" +static struct core_regset_section ppc_regset_sections[] = +{ + { ".reg", 268 }, + { ".reg2", 264 }, + { ".reg-ppc-vmx", 544 }, + { NULL, 0} +}; + static CORE_ADDR ppc_linux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) { @@ -1081,6 +1089,9 @@ ppc_linux_init_abi (struct gdbarch_info set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section); set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description); + /* Supported register sections. */ + set_gdbarch_core_regset_sections (gdbarch, ppc_regset_sections); + /* Enable TLS support. */ set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-10 1:33 ` Carlos Eduardo Seo @ 2008-05-14 4:22 ` Ulrich Weigand 2008-05-20 18:41 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-05-14 4:22 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduaro Seo wrote: > I also separated the ppc and x86 implementations from the main gcore > stuff, to make it easier to analyze. > > Is this close to what you had in mind? Thanks, this is looking very good. I've only a couple of minor issues: > +# Supported register notes in a core file Please add a '.' at the end. > +/* Data structure for the supported register notes in a core file */ Likewise. > + /* The loop below uses the new struct core_regset_section, which stores > + the supported section names and sizes for the core file. Note that > + note PRSTATUS needs to be treated specially. But the other notes are > + structurally the same, so they can benefit from the new struct. */ Always use two spaces after '.'. > + /* .reg was already handled above */ '.' at the end. > + if ((regset = gdbarch_regset_from_core_section (gdbarch, > + sect_list->sect_name, > + sect_list->size)) > + != NULL && regset->collect_regset != NULL) I think we should assert that regset and regset->collect_regset are non-NULL here. If a target provides a core_regset_sections list, it simply needs to ensure that its regset_from_core_section will recognize all sections in the list. > + /* For architectures that does not have the struct core_regset_section implemented, > + we use the old method. When all the architectures have the new support, the code > + below should be deprecated. The FILL_FPXREGSET fallback was removed since i386 > + has the new method implemented. */ Again two spaces after '.'. Please make sure that the line length does not exceed 80 characters. Also, I think the sentence about FILL_FPXREGSET is superfluous -- that's already been addressed, no need to keep a reminder to it in the code. Finally, "... the code below should be deprecated" ... once all architectures have the new support, the code below should be *deleted*. It is already deprecated (i.e. new code should not be using it any longer) today. > @@ -1075,7 +1075,6 @@ gdb_print_host_address (const void *addr > > fprintf_filtered (stream, "0x%lx", (unsigned long) addr); > } > -\f This whitespace change probably was unintentional? > +const char * > +host_address_to_string (const void *addr) > +{ > + char *str = get_cell (); > + sprintf (str, "0x%lx", (unsigned long) addr); > + return str; > +} Please move gdb_print_host_address and host_address_to_string next to each other, so that it becomes clearer that the comment in gdb_print_host_address also applies to host_address_to_string. > @@ -35,6 +35,18 @@ > #include "solib-svr4.h" > #include "symtab.h" > #include "arch-utils.h" > +#include "regset.h" Please update the Makefile.in dependency list as well. > +/* Supported register note sections */ '.' at the end. > +static struct core_regset_section i386_regset_sections[] = As this is Linux-specific, maybe i386_linux_regset_section ? > + { ".reg", 144 }, > + { ".reg2", 108 }, > +#ifdef FILL_FPXREGSET > + { ".reg-xfp", 512 }, > +#endif > + { NULL, 0 } Do we actually need the #ifdef any more? There shouldn't be any harm in unconditionally including those ... > + /* Install supported register note sections */ '.' at the end. > Index: src/gdb/ppc-linux-tdep.c > =================================================================== > --- src.orig/gdb/ppc-linux-tdep.c > +++ src/gdb/ppc-linux-tdep.c > @@ -45,6 +45,14 @@ > #include "features/rs6000/powerpc-altivec64l.c" > #include "features/rs6000/powerpc-e500l.c" > > +static struct core_regset_section ppc_regset_sections[] = Again ppc_linux_ ... as long as it is Linux-specific. With those minor modifications, I think this patch should be OK (assuming testing passes, of course). Thanks, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-14 4:22 ` Ulrich Weigand @ 2008-05-20 18:41 ` Carlos Eduardo Seo 2008-05-21 18:46 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-05-20 18:41 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 300 bytes --] Ulrich Weigand wrote: > > With those minor modifications, I think this patch should be OK > (assuming testing passes, of course). > Here are the patches revised. Testsuite runs show no regressions in ppc and i386. Regards, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center [-- Attachment #2: gcore-regnotes.diff --] [-- Type: text/x-patch, Size: 9912 bytes --] 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * gdbarch.sh: Added new gdbarch struct core_regset_sections. * gdbarch.c: Refreshed. * gdbarch.h: Refreshed. * regset.h (core_regset_section): Declared. * linux-nat.c (linux_nat_do_thread_registers): Added support to the new gdbarch struct core_regset_sections. * utils.c (host_address_to_string): New function. * defs.h (host_address_to_string): New prototype. Index: src/gdb/gdbarch.sh =================================================================== --- src.orig/gdb/gdbarch.sh +++ src/gdb/gdbarch.sh @@ -600,6 +600,9 @@ F:CORE_ADDR:fetch_pointer_argument:struc # name SECT_NAME and size SECT_SIZE. M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size +# Supported register notes in a core file. +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::host_address_to_string (gdbarch->core_regset_sections) + # Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from # core file into buffer READBUF with length LEN. M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len @@ -815,6 +818,7 @@ struct obstack; struct bp_target_info; struct target_desc; struct displaced_step_closure; +struct core_regset_section; extern struct gdbarch *current_gdbarch; EOF Index: src/gdb/gdbarch.c =================================================================== --- src.orig/gdb/gdbarch.c +++ src/gdb/gdbarch.c @@ -222,6 +222,7 @@ struct gdbarch gdbarch_register_reggroup_p_ftype *register_reggroup_p; gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument; gdbarch_regset_from_core_section_ftype *regset_from_core_section; + struct core_regset_section * core_regset_sections; gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries; int vtable_function_descriptors; int vbit_in_delta; @@ -352,6 +353,7 @@ struct gdbarch startup_gdbarch = default_register_reggroup_p, /* register_reggroup_p */ 0, /* fetch_pointer_argument */ 0, /* regset_from_core_section */ + 0, /* core_regset_sections */ 0, /* core_xfer_shared_libraries */ 0, /* vtable_function_descriptors */ 0, /* vbit_in_delta */ @@ -725,6 +727,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s "gdbarch_dump: core_read_description = <0x%lx>\n", (long) gdbarch->core_read_description); fprintf_unfiltered (file, + "gdbarch_dump: core_regset_sections = %s\n", + host_address_to_string (gdbarch->core_regset_sections)); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n", gdbarch_core_xfer_shared_libraries_p (gdbarch)); fprintf_unfiltered (file, @@ -2877,6 +2882,22 @@ set_gdbarch_regset_from_core_section (st gdbarch->regset_from_core_section = regset_from_core_section; } +struct core_regset_section * +gdbarch_core_regset_sections (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_core_regset_sections called\n"); + return gdbarch->core_regset_sections; +} + +void +set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, + struct core_regset_section * core_regset_sections) +{ + gdbarch->core_regset_sections = core_regset_sections; +} + int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch) { Index: src/gdb/gdbarch.h =================================================================== --- src.orig/gdb/gdbarch.h +++ src/gdb/gdbarch.h @@ -51,6 +51,7 @@ struct obstack; struct bp_target_info; struct target_desc; struct displaced_step_closure; +struct core_regset_section; extern struct gdbarch *current_gdbarch; @@ -634,6 +635,11 @@ typedef const struct regset * (gdbarch_r extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size); extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section); +/* Supported register notes in a core file. */ + +extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch); +extern void set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, struct core_regset_section * core_regset_sections); + /* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from core file into buffer READBUF with length LEN. */ Index: src/gdb/regset.h =================================================================== --- src.orig/gdb/regset.h +++ src/gdb/regset.h @@ -23,6 +23,13 @@ struct gdbarch; struct regcache; +/* Data structure for the supported register notes in a core file. */ +struct core_regset_section +{ + const char *sect_name; + int size; +}; + /* Data structure describing a register set. */ typedef void (supply_regset_ftype) (const struct regset *, struct regcache *, Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -3124,15 +3124,14 @@ linux_nat_do_thread_registers (bfd *obfd { gdb_gregset_t gregs; gdb_fpregset_t fpregs; -#ifdef FILL_FPXREGSET - gdb_fpxregset_t fpxregs; -#endif unsigned long lwp = ptid_get_lwp (ptid); struct regcache *regcache = get_thread_regcache (ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); const struct regset *regset; int core_regset_p; struct cleanup *old_chain; + struct core_regset_section *sect_list; + char *gdb_regset; old_chain = save_inferior_ptid (); inferior_ptid = ptid; @@ -3140,6 +3139,8 @@ linux_nat_do_thread_registers (bfd *obfd do_cleanups (old_chain); core_regset_p = gdbarch_regset_from_core_section_p (gdbarch); + sect_list = gdbarch_core_regset_sections (gdbarch); + if (core_regset_p && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg", sizeof (gregs))) != NULL @@ -3155,35 +3156,55 @@ linux_nat_do_thread_registers (bfd *obfd lwp, stop_signal, &gregs); - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", - sizeof (fpregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpregs, sizeof (fpregs)); + /* The loop below uses the new struct core_regset_section, which stores + the supported section names and sizes for the core file. Note that + note PRSTATUS needs to be treated specially. But the other notes are + structurally the same, so they can benefit from the new struct. */ + if (core_regset_p && sect_list != NULL) + while (sect_list->sect_name != NULL) + { + /* .reg was already handled above. */ + if (strcmp (sect_list->sect_name, ".reg") == 0) + { + sect_list++; + continue; + } + regset = gdbarch_regset_from_core_section (gdbarch, + sect_list->sect_name, + sect_list->size); + gdb_regset = xmalloc (sect_list->size); + regset->collect_regset (regset, regcache, -1, + gdb_regset, sect_list->size); + note_data = (char *) elfcore_write_register_note (obfd, + note_data, + note_size, + sect_list->sect_name, + gdb_regset, + sect_list->size); + xfree (gdb_regset); + sect_list++; + } + + /* For architectures that does not have the struct core_regset_section + implemented, we use the old method. When all the architectures have + the new support, the code below should be deleted. */ else - fill_fpregset (regcache, &fpregs, -1); - - note_data = (char *) elfcore_write_prfpreg (obfd, - note_data, - note_size, - &fpregs, sizeof (fpregs)); + { + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", + sizeof (fpregs))) != NULL + && regset->collect_regset != NULL) + regset->collect_regset (regset, regcache, -1, + &fpregs, sizeof (fpregs)); + else + fill_fpregset (regcache, &fpregs, -1); -#ifdef FILL_FPXREGSET - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", - sizeof (fpxregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpxregs, sizeof (fpxregs)); - else - fill_fpxregset (regcache, &fpxregs, -1); + note_data = (char *) elfcore_write_prfpreg (obfd, + note_data, + note_size, + &fpregs, sizeof (fpregs)); + } - note_data = (char *) elfcore_write_prxfpreg (obfd, - note_data, - note_size, - &fpxregs, sizeof (fpxregs)); -#endif return note_data; } Index: src/gdb/utils.c =================================================================== --- src.orig/gdb/utils.c +++ src/gdb/utils.c @@ -2869,6 +2869,14 @@ string_to_core_addr (const char *my_stri return addr; } +const char * +host_address_to_string (const void *addr) +{ + char *str = get_cell (); + sprintf (str, "0x%lx", (unsigned long) addr); + return str; +} + char * gdb_realpath (const char *filename) { Index: src/gdb/defs.h =================================================================== --- src.orig/gdb/defs.h +++ src/gdb/defs.h @@ -470,6 +470,8 @@ extern void fputstrn_unfiltered (const c /* Display the host ADDR on STREAM formatted as ``0x%x''. */ extern void gdb_print_host_address (const void *addr, struct ui_file *stream); +extern const char *host_address_to_string (const void *addr); + /* Convert a CORE_ADDR into a HEX string. paddr() is like %08lx. paddr_nz() is like %lx. paddr_u() is like %lu. paddr_width() is for ``%*''. */ [-- Attachment #3: gcore-regnotes-i386.diff --] [-- Type: text/x-patch, Size: 1889 bytes --] 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * i386-linux-tdep.c (i386_regset_rections): New register sections list for i386. (i386_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * Makefile.in: Updated to reflect dependency changes. Index: src/gdb/i386-linux-tdep.c =================================================================== --- src.orig/gdb/i386-linux-tdep.c +++ src/gdb/i386-linux-tdep.c @@ -35,6 +35,16 @@ #include "solib-svr4.h" #include "symtab.h" #include "arch-utils.h" +#include "regset.h" + +/* Supported register note sections. */ +static struct core_regset_section i386_linux_regset_sections[] = +{ + { ".reg", 144 }, + { ".reg2", 108 }, + { ".reg-xfp", 512 }, + { NULL, 0 } +}; /* Return the name of register REG. */ @@ -448,6 +458,9 @@ i386_linux_init_abi (struct gdbarch_info set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); + /* Install supported register note sections. */ + set_gdbarch_core_regset_sections (gdbarch, i386_linux_regset_sections); + /* Displaced stepping. */ set_gdbarch_displaced_step_copy_insn (gdbarch, simple_displaced_step_copy_insn); Index: src/gdb/Makefile.in =================================================================== --- src.orig/gdb/Makefile.in +++ src/gdb/Makefile.in @@ -2269,7 +2269,7 @@ i386-linux-tdep.o: i386-linux-tdep.c $(d $(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \ $(dwarf2_frame_h) $(gdb_string_h) $(i386_tdep_h) \ $(i386_linux_tdep_h) $(glibc_tdep_h) $(solib_svr4_h) $(symtab_h) \ - $(arch_utils_h) + $(arch_utils_h) $(regset_h) i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h) \ $(target_h) i386nbsd-nat.o: i386nbsd-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \ [-- Attachment #4: gcore-regnotes-ppc.diff --] [-- Type: text/x-patch, Size: 1251 bytes --] 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * ppc-linux-tdep.c (ppc_regset_sections): Register sections list for ppc. (ppc_linux_init_abi): Initialized new gdbarch struct core_regset_sections Index: src/gdb/ppc-linux-tdep.c =================================================================== --- src.orig/gdb/ppc-linux-tdep.c +++ src/gdb/ppc-linux-tdep.c @@ -45,6 +45,14 @@ #include "features/rs6000/powerpc-altivec64l.c" #include "features/rs6000/powerpc-e500l.c" +static struct core_regset_section ppc_linux_regset_sections[] = +{ + { ".reg", 268 }, + { ".reg2", 264 }, + { ".reg-ppc-vmx", 544 }, + { NULL, 0} +}; + static CORE_ADDR ppc_linux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) { @@ -1081,6 +1089,9 @@ ppc_linux_init_abi (struct gdbarch_info set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section); set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description); + /* Supported register sections. */ + set_gdbarch_core_regset_sections (gdbarch, ppc_linux_regset_sections); + /* Enable TLS support. */ set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-20 18:41 ` Carlos Eduardo Seo @ 2008-05-21 18:46 ` Ulrich Weigand 2008-05-22 14:34 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-05-21 18:46 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > Here are the patches revised. Testsuite runs show no regressions in ppc > and i386. Thanks for making those changes. > 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> > > * gdbarch.sh: Added new gdbarch struct > core_regset_sections. > * gdbarch.c: Refreshed. > * gdbarch.h: Refreshed. > * regset.h (core_regset_section): Declared. > * linux-nat.c (linux_nat_do_thread_registers): Added > support to the new gdbarch struct core_regset_sections. This should read "Added support for ...", not "to ...". > + /* The loop below uses the new struct core_regset_section, which stores > + the supported section names and sizes for the core file. Note that Two spaces after '.' here as well, please. > + note PRSTATUS needs to be treated specially. But the other notes are > + structurally the same, so they can benefit from the new struct. */ > + if (core_regset_p && sect_list != NULL) > + while (sect_list->sect_name != NULL) > + { > + /* .reg was already handled above. */ > + if (strcmp (sect_list->sect_name, ".reg") == 0) > + { > + sect_list++; > + continue; > + } > + regset = gdbarch_regset_from_core_section (gdbarch, > + sect_list->sect_name, > + sect_list->size); Please add an assertion gdb_assert (regset && regset->collect_regset) here, so we don't just crash on the call below if a gdbarch doesn't provide those functions as it should ... > + gdb_regset = xmalloc (sect_list->size); > + regset->collect_regset (regset, regcache, -1, > + gdb_regset, sect_list->size); > + note_data = (char *) elfcore_write_register_note (obfd, > + note_data, > + note_size, > + sect_list->sect_name, > + gdb_regset, > + sect_list->size); > + xfree (gdb_regset); > + sect_list++; > + } > + > + /* For architectures that does not have the struct core_regset_section > + implemented, we use the old method. When all the architectures have Two spaces after '.'. With these final changes, the patch is OK. Thanks, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-21 18:46 ` Ulrich Weigand @ 2008-05-22 14:34 ` Carlos Eduardo Seo 2008-05-22 18:45 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-05-22 14:34 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List [-- Attachment #1: Type: text/plain, Size: 289 bytes --] Ulrich Weigand wrote: > > With these final changes, the patch is OK. > Thanks, Ulrich. This is the final version then. I'll submit the binutils patch now and when that's accepted, I'll commit this one. Regards, -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center [-- Attachment #2: gcore-regnotes.diff --] [-- Type: text/x-patch, Size: 9965 bytes --] 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * gdbarch.sh: Added new gdbarch struct core_regset_sections. * gdbarch.c: Refreshed. * gdbarch.h: Refreshed. * regset.h (core_regset_section): Declared. * linux-nat.c (linux_nat_do_thread_registers): Added support for the new gdbarch struct core_regset_sections. * utils.c (host_address_to_string): New function. * defs.h (host_address_to_string): New prototype. Index: src/gdb/gdbarch.sh =================================================================== --- src.orig/gdb/gdbarch.sh +++ src/gdb/gdbarch.sh @@ -599,6 +599,9 @@ F:CORE_ADDR:fetch_pointer_argument:struc # name SECT_NAME and size SECT_SIZE. M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size +# Supported register notes in a core file. +v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::host_address_to_string (gdbarch->core_regset_sections) + # Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from # core file into buffer READBUF with length LEN. M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len @@ -814,6 +817,7 @@ struct obstack; struct bp_target_info; struct target_desc; struct displaced_step_closure; +struct core_regset_section; extern struct gdbarch *current_gdbarch; EOF Index: src/gdb/gdbarch.c =================================================================== --- src.orig/gdb/gdbarch.c +++ src/gdb/gdbarch.c @@ -221,6 +221,7 @@ struct gdbarch gdbarch_register_reggroup_p_ftype *register_reggroup_p; gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument; gdbarch_regset_from_core_section_ftype *regset_from_core_section; + struct core_regset_section * core_regset_sections; gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries; int vtable_function_descriptors; int vbit_in_delta; @@ -350,6 +351,7 @@ struct gdbarch startup_gdbarch = default_register_reggroup_p, /* register_reggroup_p */ 0, /* fetch_pointer_argument */ 0, /* regset_from_core_section */ + 0, /* core_regset_sections */ 0, /* core_xfer_shared_libraries */ 0, /* vtable_function_descriptors */ 0, /* vbit_in_delta */ @@ -721,6 +723,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s "gdbarch_dump: core_read_description = <0x%lx>\n", (long) gdbarch->core_read_description); fprintf_unfiltered (file, + "gdbarch_dump: core_regset_sections = %s\n", + host_address_to_string (gdbarch->core_regset_sections)); + fprintf_unfiltered (file, "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n", gdbarch_core_xfer_shared_libraries_p (gdbarch)); fprintf_unfiltered (file, @@ -2853,6 +2858,22 @@ set_gdbarch_regset_from_core_section (st gdbarch->regset_from_core_section = regset_from_core_section; } +struct core_regset_section * +gdbarch_core_regset_sections (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_core_regset_sections called\n"); + return gdbarch->core_regset_sections; +} + +void +set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, + struct core_regset_section * core_regset_sections) +{ + gdbarch->core_regset_sections = core_regset_sections; +} + int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch) { Index: src/gdb/gdbarch.h =================================================================== --- src.orig/gdb/gdbarch.h +++ src/gdb/gdbarch.h @@ -51,6 +51,7 @@ struct obstack; struct bp_target_info; struct target_desc; struct displaced_step_closure; +struct core_regset_section; extern struct gdbarch *current_gdbarch; @@ -630,6 +631,11 @@ typedef const struct regset * (gdbarch_r extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size); extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section); +/* Supported register notes in a core file. */ + +extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch); +extern void set_gdbarch_core_regset_sections (struct gdbarch *gdbarch, struct core_regset_section * core_regset_sections); + /* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from core file into buffer READBUF with length LEN. */ Index: src/gdb/regset.h =================================================================== --- src.orig/gdb/regset.h +++ src/gdb/regset.h @@ -23,6 +23,13 @@ struct gdbarch; struct regcache; +/* Data structure for the supported register notes in a core file. */ +struct core_regset_section +{ + const char *sect_name; + int size; +}; + /* Data structure describing a register set. */ typedef void (supply_regset_ftype) (const struct regset *, struct regcache *, Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c +++ src/gdb/linux-nat.c @@ -3112,15 +3112,14 @@ linux_nat_do_thread_registers (bfd *obfd { gdb_gregset_t gregs; gdb_fpregset_t fpregs; -#ifdef FILL_FPXREGSET - gdb_fpxregset_t fpxregs; -#endif unsigned long lwp = ptid_get_lwp (ptid); struct regcache *regcache = get_thread_regcache (ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); const struct regset *regset; int core_regset_p; struct cleanup *old_chain; + struct core_regset_section *sect_list; + char *gdb_regset; old_chain = save_inferior_ptid (); inferior_ptid = ptid; @@ -3128,6 +3127,8 @@ linux_nat_do_thread_registers (bfd *obfd do_cleanups (old_chain); core_regset_p = gdbarch_regset_from_core_section_p (gdbarch); + sect_list = gdbarch_core_regset_sections (gdbarch); + if (core_regset_p && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg", sizeof (gregs))) != NULL @@ -3143,35 +3144,56 @@ linux_nat_do_thread_registers (bfd *obfd lwp, stop_signal, &gregs); - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", - sizeof (fpregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpregs, sizeof (fpregs)); + /* The loop below uses the new struct core_regset_section, which stores + the supported section names and sizes for the core file. Note that + note PRSTATUS needs to be treated specially. But the other notes are + structurally the same, so they can benefit from the new struct. */ + if (core_regset_p && sect_list != NULL) + while (sect_list->sect_name != NULL) + { + /* .reg was already handled above. */ + if (strcmp (sect_list->sect_name, ".reg") == 0) + { + sect_list++; + continue; + } + regset = gdbarch_regset_from_core_section (gdbarch, + sect_list->sect_name, + sect_list->size); + gdb_assert (regset && regset->collect_regset); + gdb_regset = xmalloc (sect_list->size); + regset->collect_regset (regset, regcache, -1, + gdb_regset, sect_list->size); + note_data = (char *) elfcore_write_register_note (obfd, + note_data, + note_size, + sect_list->sect_name, + gdb_regset, + sect_list->size); + xfree (gdb_regset); + sect_list++; + } + + /* For architectures that does not have the struct core_regset_section + implemented, we use the old method. When all the architectures have + the new support, the code below should be deleted. */ else - fill_fpregset (regcache, &fpregs, -1); - - note_data = (char *) elfcore_write_prfpreg (obfd, - note_data, - note_size, - &fpregs, sizeof (fpregs)); + { + if (core_regset_p + && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", + sizeof (fpregs))) != NULL + && regset->collect_regset != NULL) + regset->collect_regset (regset, regcache, -1, + &fpregs, sizeof (fpregs)); + else + fill_fpregset (regcache, &fpregs, -1); -#ifdef FILL_FPXREGSET - if (core_regset_p - && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp", - sizeof (fpxregs))) != NULL - && regset->collect_regset != NULL) - regset->collect_regset (regset, regcache, -1, - &fpxregs, sizeof (fpxregs)); - else - fill_fpxregset (regcache, &fpxregs, -1); + note_data = (char *) elfcore_write_prfpreg (obfd, + note_data, + note_size, + &fpregs, sizeof (fpregs)); + } - note_data = (char *) elfcore_write_prxfpreg (obfd, - note_data, - note_size, - &fpxregs, sizeof (fpxregs)); -#endif return note_data; } Index: src/gdb/utils.c =================================================================== --- src.orig/gdb/utils.c +++ src/gdb/utils.c @@ -2869,6 +2869,14 @@ string_to_core_addr (const char *my_stri return addr; } +const char * +host_address_to_string (const void *addr) +{ + char *str = get_cell (); + sprintf (str, "0x%lx", (unsigned long) addr); + return str; +} + char * gdb_realpath (const char *filename) { Index: src/gdb/defs.h =================================================================== --- src.orig/gdb/defs.h +++ src/gdb/defs.h @@ -470,6 +470,8 @@ extern void fputstrn_unfiltered (const c /* Display the host ADDR on STREAM formatted as ``0x%x''. */ extern void gdb_print_host_address (const void *addr, struct ui_file *stream); +extern const char *host_address_to_string (const void *addr); + /* Convert a CORE_ADDR into a HEX string. paddr() is like %08lx. paddr_nz() is like %lx. paddr_u() is like %lu. paddr_width() is for ``%*''. */ [-- Attachment #3: gcore-regnotes-i386.diff --] [-- Type: text/x-patch, Size: 1889 bytes --] 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * i386-linux-tdep.c (i386_regset_rections): New register sections list for i386. (i386_linux_init_abi): Initialized new gdbarch struct core_regset_sections. * Makefile.in: Updated to reflect dependency changes. Index: src/gdb/i386-linux-tdep.c =================================================================== --- src.orig/gdb/i386-linux-tdep.c +++ src/gdb/i386-linux-tdep.c @@ -35,6 +35,16 @@ #include "solib-svr4.h" #include "symtab.h" #include "arch-utils.h" +#include "regset.h" + +/* Supported register note sections. */ +static struct core_regset_section i386_linux_regset_sections[] = +{ + { ".reg", 144 }, + { ".reg2", 108 }, + { ".reg-xfp", 512 }, + { NULL, 0 } +}; /* Return the name of register REG. */ @@ -448,6 +458,9 @@ i386_linux_init_abi (struct gdbarch_info set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); + /* Install supported register note sections. */ + set_gdbarch_core_regset_sections (gdbarch, i386_linux_regset_sections); + /* Displaced stepping. */ set_gdbarch_displaced_step_copy_insn (gdbarch, simple_displaced_step_copy_insn); Index: src/gdb/Makefile.in =================================================================== --- src.orig/gdb/Makefile.in +++ src/gdb/Makefile.in @@ -2268,7 +2268,7 @@ i386-linux-tdep.o: i386-linux-tdep.c $(d $(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \ $(dwarf2_frame_h) $(gdb_string_h) $(i386_tdep_h) \ $(i386_linux_tdep_h) $(glibc_tdep_h) $(solib_svr4_h) $(symtab_h) \ - $(arch_utils_h) + $(arch_utils_h) $(regset_h) i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h) \ $(target_h) i386nbsd-nat.o: i386nbsd-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \ [-- Attachment #4: gcore-regnotes-ppc.diff --] [-- Type: text/x-patch, Size: 1267 bytes --] 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> * ppc-linux-tdep.c (ppc_regset_sections): Register sections list for ppc. (ppc_linux_init_abi): Initialized new gdbarch struct core_regset_sections Index: src/gdb/ppc-linux-tdep.c =================================================================== --- src.orig/gdb/ppc-linux-tdep.c +++ src/gdb/ppc-linux-tdep.c @@ -489,6 +489,14 @@ ppc64_standard_linkage1_target (struct f return ppc64_desc_entry_point (desc); } +static struct core_regset_section ppc_linux_regset_sections[] = +{ + { ".reg", 268 }, + { ".reg2", 264 }, + { ".reg-ppc-vmx", 544 }, + { NULL, 0} +}; + static CORE_ADDR ppc64_standard_linkage2_target (struct frame_info *frame, CORE_ADDR pc, unsigned int *insn) @@ -1042,6 +1050,9 @@ ppc_linux_init_abi (struct gdbarch_info set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section); set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description); + /* Supported register sections. */ + set_gdbarch_core_regset_sections (gdbarch, ppc_linux_regset_sections); + /* Enable TLS support. */ set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-22 14:34 ` Carlos Eduardo Seo @ 2008-05-22 18:45 ` Ulrich Weigand 2008-05-26 16:26 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2008-05-22 18:45 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: GDB Patches Mailing List Carlos Eduardo Seo wrote: > 2008-05-14 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> > > * gdbarch.sh: Added new gdbarch struct > core_regset_sections. > * gdbarch.c: Refreshed. > * gdbarch.h: Refreshed. > * regset.h (core_regset_section): Declared. > * linux-nat.c (linux_nat_do_thread_registers): Added > support for the new gdbarch struct core_regset_sections. > * utils.c (host_address_to_string): New function. > * defs.h (host_address_to_string): New prototype. This version is OK, thanks! Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2008-05-22 18:45 ` Ulrich Weigand @ 2008-05-26 16:26 ` Carlos Eduardo Seo 0 siblings, 0 replies; 37+ messages in thread From: Carlos Eduardo Seo @ 2008-05-26 16:26 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List Ulrich Weigand wrote: > > This version is OK, thanks! > Committed! Thanks! -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center ^ permalink raw reply [flat|nested] 37+ messages in thread
[parent not found: <OF67129E0D.852FADB2-ON4125738B.0050E74D-4125738B.005102FF@de.ibm.com>]
* Re: [RFC] Add support for PPC Altivec registers in gcore [not found] <OF67129E0D.852FADB2-ON4125738B.0050E74D-4125738B.005102FF@de.ibm.com> @ 2007-11-25 4:51 ` Carlos Eduardo Seo 2007-11-26 16:09 ` Ulrich Weigand 0 siblings, 1 reply; 37+ messages in thread From: Carlos Eduardo Seo @ 2007-11-25 4:51 UTC (permalink / raw) To: Ulrich Weigand; +Cc: GDB Patches Mailing List -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ulrich Weigand wrote: > > Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> wrote on 11/06/2007 > 02:42:43 PM: > > > I was taking a look at gdbarch.sh. Where's the "right" place to put > > the register list? > > In "function_list". If you want to add a new data symbol, you'll > need type "v". Best place is probably after regset_from_core_section. Do you think it's better to initialize this new structure with the registers names in gdbarch.c, or have it initialized in each arch-tdep.c file with the supported registers for that arch? - -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHSP9Aqvq7Aov/qQARAqhbAJ9LhIlde4temthhdowinlysnO9TbQCeMcXk ZqpCz9hMw8462qMvrhDY7bg= =yy6H -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-11-25 4:51 ` Carlos Eduardo Seo @ 2007-11-26 16:09 ` Ulrich Weigand 2007-11-26 16:12 ` Carlos Eduardo Seo 0 siblings, 1 reply; 37+ messages in thread From: Ulrich Weigand @ 2007-11-26 16:09 UTC (permalink / raw) To: Carlos Eduardo Seo; +Cc: Ulrich Weigand, GDB Patches Mailing List Carlos Eduardo Seo wrote: > Ulrich Weigand wrote: > > > > Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> wrote on 11/06/2007 > > 02:42:43 PM: > > > > > I was taking a look at gdbarch.sh. Where's the "right" place to put > > > the register list? > > > > In "function_list". If you want to add a new data symbol, you'll > > need type "v". Best place is probably after regset_from_core_section. > Do you think it's better to initialize this new structure with the > registers names in gdbarch.c, or have it initialized in each > arch-tdep.c file with the supported registers for that arch? Maybe there is some misunderstanding: I was not talking about a list of *register names*, rather a set of core file *section names*. I'd suggest to define a data structure along the lines of: struct core_regset_section { const char *name; int len; }; and then define arrays of those in the -tdep.c files, like: static struct core_regset_section ppc_regset_sections[] = { { ".reg", ... }, { ".reg2", ... }, { ".reg-vmx", ... }, { NULL, 0 } }; In gdbarch.sh, you'd then add an entry like: v:struct core_regset_section *:core_regset_sections which would generate functions gdbarch_core_regset_sections and gdbarch_set_core_regset_sections In the -tdep.c file, you'd now be able to install the array defined above: gdbarch_set_core_regset_sections (gdbarch, ppc_regset_sections); and in linux-nat.c, you'd be able to call gdbarch_core_regset_sections to get at that list. For platforms that do not override that gdbarch routine, you can fall back to a default along the lines of struct default_regset_sections[] = { { ".reg", sizeof (gdb_gregset_t) }, { ".reg2", sizeof (gdb_fpregset_t) }, { NULL, 0 } }; Does this make sense? Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [RFC] Add support for PPC Altivec registers in gcore 2007-11-26 16:09 ` Ulrich Weigand @ 2007-11-26 16:12 ` Carlos Eduardo Seo 0 siblings, 0 replies; 37+ messages in thread From: Carlos Eduardo Seo @ 2007-11-26 16:12 UTC (permalink / raw) To: Ulrich Weigand; +Cc: Ulrich Weigand, GDB Patches Mailing List -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ulrich Weigand wrote: > > Does this make sense? Yeah, much clearer now. Thanks! - -- Carlos Eduardo Seo Software Engineer IBM Linux Technology Center -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHSvBSqvq7Aov/qQARAjdKAJ0ZIoBQmVj3pLMBOaZxDYA1MRGwGwCdGZUo E3bppt1y3nUIHT6gInZSfJM= =9qZ7 -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2008-05-24 16:34 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 22:14 [RFC] Add support for PPC Altivec registers in gcore Carlos Eduardo Seo
2007-10-29 19:24 ` Ulrich Weigand
2007-10-30 21:02 ` Carlos Eduardo Seo
2007-10-30 21:18 ` Ulrich Weigand
2007-10-30 21:30 ` Carlos Eduardo Seo
2007-10-30 21:31 ` Ulrich Weigand
2007-10-31 21:14 ` Carlos Eduardo Seo
2007-10-31 21:43 ` Ulrich Weigand
2008-02-08 21:42 ` Carlos Eduardo Seo
2008-02-18 18:42 ` Ulrich Weigand
2008-02-27 17:07 ` Carlos Eduardo Seo
2008-03-05 18:27 ` Ulrich Weigand
2008-03-10 14:22 ` Carlos Eduardo Seo
2008-03-17 19:07 ` Ulrich Weigand
2008-03-20 15:31 ` Carlos Eduardo Seo
2008-03-25 20:13 ` Ulrich Weigand
2008-03-25 21:31 ` Andreas Schwab
2008-03-25 21:54 ` Ulrich Weigand
2008-03-25 22:46 ` Carlos Eduardo Seo
2008-03-26 11:28 ` Ulrich Weigand
2008-03-27 1:52 ` Carlos Eduardo Seo
2008-03-27 9:00 ` Andreas Schwab
2008-03-27 19:54 ` Ulrich Weigand
2008-03-28 20:41 ` Carlos Eduardo Seo
2008-03-31 19:19 ` Ulrich Weigand
2008-05-09 19:27 ` Carlos Eduardo Seo
2008-05-09 20:30 ` Ulrich Weigand
2008-05-10 1:33 ` Carlos Eduardo Seo
2008-05-14 4:22 ` Ulrich Weigand
2008-05-20 18:41 ` Carlos Eduardo Seo
2008-05-21 18:46 ` Ulrich Weigand
2008-05-22 14:34 ` Carlos Eduardo Seo
2008-05-22 18:45 ` Ulrich Weigand
2008-05-26 16:26 ` Carlos Eduardo Seo
[not found] <OF67129E0D.852FADB2-ON4125738B.0050E74D-4125738B.005102FF@de.ibm.com>
2007-11-25 4:51 ` Carlos Eduardo Seo
2007-11-26 16:09 ` Ulrich Weigand
2007-11-26 16:12 ` Carlos Eduardo Seo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox