* [PATCH v3] gdb/csky support .reg2 for kernel 4.x and later
@ 2022-08-09 2:29 jiangshuai_li via Gdb-patches
2022-08-09 7:56 ` Tom de Vries via Gdb-patches
0 siblings, 1 reply; 4+ messages in thread
From: jiangshuai_li via Gdb-patches @ 2022-08-09 2:29 UTC (permalink / raw)
To: gdb-patches, Tom de Vries
>On 8/1/22 04:40, Jiangshuai Li via Gdb-patches wrote:
>> + warning (_("Unknow size %ld of section .reg2, can not get value"
>> + " of float registers."), len);
>
>This broke the build on the gdb-armhf-ubuntu20_04 builder ( see
>https://builder.sourceware.org/buildbot/#/builders/170/builds/246 ):
>...
>../../binutils-gdb/gdb/csky-linux-tdep.c: In function ‘void
>csky_supply_fregset(const regset*, regcache*, int, const void*, size_t)’:
>../../binutils-gdb/gdb/csky-linux-tdep.c:194:18: error: format ‘%ld’
>expects argument of type ‘long int’, but argument 2 has type ‘size_t’
>{aka ‘unsigned int’} [-Werror=format=]
> 194 | warning (_("Unknow size %ld of section .reg2, can not get
>value"
> |
>^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 195 | " of float registers."), len);
>...
>
>There are uses of %z in gdb, but very few, so I suppose the way to fix
>this is to use %s and pulongest.
Thanks, i have used your suggestion to fix it, a patch has been committed.
Jiangshuai.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] gdb/csky support .reg2 for kernel 4.x and later
2022-08-09 2:29 [PATCH v3] gdb/csky support .reg2 for kernel 4.x and later jiangshuai_li via Gdb-patches
@ 2022-08-09 7:56 ` Tom de Vries via Gdb-patches
0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries via Gdb-patches @ 2022-08-09 7:56 UTC (permalink / raw)
To: jiangshuai_li, gdb-patches
On 8/9/22 04:29, jiangshuai_li wrote:
> >On 8/1/22 04:40, Jiangshuai Li via Gdb-patches wrote:
> >> + warning (_("Unknow size %ld of section .reg2, can not get value"
> >> + " of float registers."), len);
> >
> >This broke the build on the gdb-armhf-ubuntu20_04 builder ( see
> >https://builder.sourceware.org/buildbot/#/builders/170/builds/246 ):
> >...
> >../../binutils-gdb/gdb/csky-linux-tdep.c: In function ‘void
> >csky_supply_fregset(const regset*, regcache*, int, const void*, size_t)’:
> >../../binutils-gdb/gdb/csky-linux-tdep.c:194:18: error: format ‘%ld’
> >expects argument of type ‘long int’, but argument 2 has type ‘size_t’
> >{aka ‘unsigned int’} [-Werror=format=]
> > 194 | warning (_("Unknow size %ld of section .reg2, can not get
> >value"
> > |
> >^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 195 | " of float registers."), len);
> >...
> >
> >There are uses of %z in gdb, but very few, so I suppose the way to fix
> >this is to use %s and pulongest.
>
> Thanks, i have used your suggestion to fix it, a patch has been committed.
>
Thanks for fixing it, and I see the gdb-armhf-ubuntu20_04 builder is
back to green status, yay !
Thanks,
- Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] gdb/csky support .reg2 for kernel 4.x and later
2022-08-01 2:40 Jiangshuai Li via Gdb-patches
@ 2022-08-08 7:32 ` Tom de Vries via Gdb-patches
0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries via Gdb-patches @ 2022-08-08 7:32 UTC (permalink / raw)
To: Jiangshuai Li, gdb-patches
On 8/1/22 04:40, Jiangshuai Li via Gdb-patches wrote:
> + warning (_("Unknow size %ld of section .reg2, can not get value"
> + " of float registers."), len);
This broke the build on the gdb-armhf-ubuntu20_04 builder ( see
https://builder.sourceware.org/buildbot/#/builders/170/builds/246 ):
...
../../binutils-gdb/gdb/csky-linux-tdep.c: In function ‘void
csky_supply_fregset(const regset*, regcache*, int, const void*, size_t)’:
../../binutils-gdb/gdb/csky-linux-tdep.c:194:18: error: format ‘%ld’
expects argument of type ‘long int’, but argument 2 has type ‘size_t’
{aka ‘unsigned int’} [-Werror=format=]
194 | warning (_("Unknow size %ld of section .reg2, can not get
value"
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 | " of float registers."), len);
...
There are uses of %z in gdb, but very few, so I suppose the way to fix
this is to use %s and pulongest.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3] gdb/csky support .reg2 for kernel 4.x and later
@ 2022-08-01 2:40 Jiangshuai Li via Gdb-patches
2022-08-08 7:32 ` Tom de Vries via Gdb-patches
0 siblings, 1 reply; 4+ messages in thread
From: Jiangshuai Li via Gdb-patches @ 2022-08-01 2:40 UTC (permalink / raw)
To: gdb-patches; +Cc: Jiangshuai Li
When kernel's version >= 4.x, the size of .reg2 section will be 400.
Contents of .reg2 are {
unsigned long vr[96];
unsigned long fcr;
unsigned long fesr;
unsigned long fid;
unsigned long reserved;
};
VR[96] means: (vr0~vr15) + (fr16~fr31), each Vector register is
128-bits, each Float register is 64 bits, the total size is
(4*96).
In addition, for fr0~fr15, each FRx is the lower 64 bits of the
corresponding VRx. So fr0~fr15 and vr0~vr15 regisetrs use the same
offset.
---
gdb/csky-linux-tdep.c | 164 +++++++++++++++++++++++++++++++++++++-----
gdb/csky-tdep.h | 3 +
2 files changed, 151 insertions(+), 16 deletions(-)
diff --git a/gdb/csky-linux-tdep.c b/gdb/csky-linux-tdep.c
index 440045e7713..08eb8f42768 100644
--- a/gdb/csky-linux-tdep.c
+++ b/gdb/csky-linux-tdep.c
@@ -36,6 +36,8 @@
#define SIZEOF_CSKY_GREGSET 34*4
/* Float regset fesr fsr fr0-fr31 for CK810. */
#define SIZEOF_CSKY_FREGSET 34*4
+/* Float regset vr0~vr15 fr15~fr31, reserved for CK810 when kernel 4.x. */
+#define SIZEOF_CSKY_FREGSET_K4X 400
/* Offset mapping table from core_section to regcache of general
registers for ck810. */
@@ -118,15 +120,83 @@ csky_supply_fregset (const struct regset *regset,
int fregset_num = ARRAY_SIZE (csky_fregset_offset);
gdb_assert (len >= SIZEOF_CSKY_FREGSET);
- for (i = 0; i < fregset_num; i++)
+ if (len == SIZEOF_CSKY_FREGSET)
{
- if ((regnum == csky_fregset_offset[i] || regnum == -1)
- && csky_fregset_offset[i] != -1)
- {
- int num = csky_fregset_offset[i];
- offset += register_size (gdbarch, num);
- regcache->raw_supply (csky_fregset_offset[i], fregs + offset);
- }
+ for (i = 0; i < fregset_num; i++)
+ {
+ if ((regnum == csky_fregset_offset[i] || regnum == -1)
+ && csky_fregset_offset[i] != -1)
+ {
+ int num = csky_fregset_offset[i];
+ offset += register_size (gdbarch, num);
+ regcache->raw_supply (csky_fregset_offset[i], fregs + offset);
+ }
+ }
+ }
+ else if (len == SIZEOF_CSKY_FREGSET_K4X)
+ {
+ /* When kernel version >= 4.x, .reg2 size will be 400.
+ Contents is {
+ unsigned long vr[96];
+ unsigned long fcr;
+ unsigned long fesr;
+ unsigned long fid;
+ unsigned long reserved;
+ }
+ VR[96] means: (vr0~vr15) + (fr16~fr31), each Vector register is
+ 128-bits, each Float register is 64 bits, the total size is
+ (4*96).
+
+ In addition, for fr0~fr15, each FRx is the lower 64 bits of the
+ corresponding VRx. So fr0~fr15 and vr0~vr15 regisetrs use the same
+ offset. */
+ int fcr_regno[] = {122, 123, 121}; /* fcr, fesr, fid. */
+
+ /* Supply vr0~vr15. */
+ for (i = 0; i < 16; i ++)
+ {
+ if (gdbarch_register_name (gdbarch, (CSKY_VR0_REGNUM + i)))
+ {
+ offset = 16 * i;
+ regcache->raw_supply (CSKY_VR0_REGNUM + i,
+ fregs + offset);
+ }
+ }
+ /* Supply fr0~fr15. */
+ for (i = 0; i < 16; i ++)
+ {
+ if (gdbarch_register_name (gdbarch, (CSKY_FR0_REGNUM + i)))
+ {
+ offset = 16 * i;
+ regcache->raw_supply (CSKY_FR0_REGNUM + i,
+ fregs + offset);
+ }
+ }
+ /* Supply fr16~fr31. */
+ for (i = 0; i < 16; i ++)
+ {
+ if (gdbarch_register_name (gdbarch, (CSKY_FR16_REGNUM + i)))
+ {
+ offset = (16 * 16) + (8 * i);
+ regcache->raw_supply (CSKY_FR16_REGNUM + i,
+ fregs + offset);
+ }
+ }
+ /* Supply fcr, fesr, fid. */
+ for (i = 0; i < 3; i ++)
+ {
+ if (gdbarch_register_name (gdbarch, fcr_regno[i]))
+ {
+ offset = (16 * 16) + (16 * 8) + (4 * i);
+ regcache->raw_supply (fcr_regno[i],
+ fregs + offset);
+ }
+ }
+ }
+ else
+ {
+ warning (_("Unknow size %ld of section .reg2, can not get value"
+ " of float registers."), len);
}
}
@@ -144,14 +214,73 @@ csky_collect_fregset (const struct regset *regset,
int offset = 0;
gdb_assert (len >= SIZEOF_CSKY_FREGSET);
- for (regno = 0; regno < fregset_num; regno++)
+ if (len == SIZEOF_CSKY_FREGSET)
+ {
+ for (regno = 0; regno < fregset_num; regno++)
+ {
+ if ((regnum == csky_fregset_offset[regno] || regnum == -1)
+ && csky_fregset_offset[regno] != -1)
+ {
+ offset += register_size (gdbarch, csky_fregset_offset[regno]);
+ regcache->raw_collect (regno, fregs + offset);
+ }
+ }
+ }
+ else if (len == SIZEOF_CSKY_FREGSET_K4X)
+ {
+ /* When kernel version >= 4.x, .reg2 size will be 400.
+ Contents is {
+ unsigned long vr[96];
+ unsigned long fcr;
+ unsigned long fesr;
+ unsigned long fid;
+ unsigned long reserved;
+ }
+ VR[96] means: (vr0~vr15) + (fr16~fr31), each Vector register is$
+ 128-bits, each Float register is 64 bits, the total size is$
+ (4*96).$
+
+ In addition, for fr0~fr15, each FRx is the lower 64 bits of the$
+ corresponding VRx. So fr0~fr15 and vr0~vr15 regisetrs use the same$
+ offset. */
+ int i = 0;
+ int fcr_regno[] = {122, 123, 121}; /* fcr, fesr, fid. */
+
+ /* Supply vr0~vr15. */
+ for (i = 0; i < 16; i ++)
+ {
+ if (gdbarch_register_name (gdbarch, (CSKY_VR0_REGNUM + i)))
+ {
+ offset = 16 * i;
+ regcache ->raw_collect (CSKY_VR0_REGNUM + i,
+ fregs + offset);
+ }
+ }
+ /* Supply fr16~fr31. */
+ for (i = 0; i < 16; i ++)
+ {
+ if (gdbarch_register_name (gdbarch, (CSKY_FR16_REGNUM + i)))
+ {
+ offset = (16 * 16) + (8 * i);
+ regcache ->raw_collect (CSKY_FR16_REGNUM + i,
+ fregs + offset);
+ }
+ }
+ /* Supply fcr, fesr, fid. */
+ for (i = 0; i < 3; i ++)
+ {
+ if (gdbarch_register_name (gdbarch, fcr_regno[i]))
+ {
+ offset = (16 * 16) + (16 * 8) + (4 * i);
+ regcache ->raw_collect (fcr_regno[i],
+ fregs + offset);
+ }
+ }
+ }
+ else
{
- if ((regnum == csky_fregset_offset[regno] || regnum == -1)
- && csky_fregset_offset[regno] != -1)
- {
- offset += register_size (gdbarch, csky_fregset_offset[regno]);
- regcache->raw_collect (regno, fregs + offset);
- }
+ warning (_("Unknow size %ld of section .reg2, will not set value"
+ " of float registers."), len);
}
}
@@ -166,7 +295,10 @@ static const struct regset csky_regset_float =
{
NULL,
csky_supply_fregset,
- csky_collect_fregset
+ csky_collect_fregset,
+ /* Allow .reg2 to have a different size, and the size of .reg2 should
+ always be bigger than SIZEOF_CSKY_FREGSET. */
+ 1
};
/* Iterate over core file register note sections. */
diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h
index 4cfc0a5d086..3391a08c2e5 100644
--- a/gdb/csky-tdep.h
+++ b/gdb/csky-tdep.h
@@ -93,6 +93,9 @@ enum csky_regnum
CSKY_PSR_REGNUM = CSKY_CR0_REGNUM,
CSKY_MAX_REGISTER_SIZE = 16,
+
+ /* Actually, the max regs number should be 1187. But if the
+ gdb stub does not send a tdesc-xml file to gdb, 253 works. */
CSKY_MAX_REGS = 253
};
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-09 7:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-09 2:29 [PATCH v3] gdb/csky support .reg2 for kernel 4.x and later jiangshuai_li via Gdb-patches
2022-08-09 7:56 ` Tom de Vries via Gdb-patches
-- strict thread matches above, loose matches on Subject: below --
2022-08-01 2:40 Jiangshuai Li via Gdb-patches
2022-08-08 7:32 ` Tom de Vries via Gdb-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox