[2/2] gdbserver: xtensa: support THREADPTR register
Commit Message
Provide aceess to the THREADPTR register to remote gdb.
2017-01-18 Max Filippov <jcmvbkbc@gmail.com>
gdb/gdbserver/
* linux-xtensa-low.c (regnum::R_THREADPTR): New enum member.
(xtensa_fill_gregset): Call collect_register_by_name for
threadptr register.
(xtensa_store_gregset): Call supply_register_by_name for
threadptr register.
---
gdb/gdbserver/linux-xtensa-low.c | 9 +++++++++
1 file changed, 9 insertions(+)
Comments
On 01/18/2017 05:56 PM, Max Filippov wrote:
> Provide aceess to the THREADPTR register to remote gdb.
>
> 2017-01-18 Max Filippov <jcmvbkbc@gmail.com>
> gdb/gdbserver/
Similarly, drop the gdb/gdbserver/
> * linux-xtensa-low.c (regnum::R_THREADPTR): New enum member.
> (xtensa_fill_gregset): Call collect_register_by_name for
> threadptr register.
> (xtensa_store_gregset): Call supply_register_by_name for
> threadptr register.
> ---
> gdb/gdbserver/linux-xtensa-low.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/gdb/gdbserver/linux-xtensa-low.c b/gdb/gdbserver/linux-xtensa-low.c
> index 73fbfe2..eca0289 100644
> --- a/gdb/gdbserver/linux-xtensa-low.c
> +++ b/gdb/gdbserver/linux-xtensa-low.c
> @@ -36,6 +36,7 @@ enum regnum {
> R_LBEG, R_LEND, R_LCOUNT,
> R_SAR,
> R_WS, R_WB,
> + R_THREADPTR,
> R_A0 = 64
> };
Does xtensa have xml register description support? It would be nice to
have those described instead of hardcoding the entries like this.
>
> @@ -86,6 +87,10 @@ xtensa_fill_gregset (struct regcache *regcache, void *buf)
> collect_register (regcache, i, ptr);
> ptr += register_size (tdesc, i);
> }
> +
> +#if XCHAL_HAVE_THREADPTR
> + collect_register_by_name (regcache, "threadptr", (char*)&rset[R_THREADPTR]);
Missing spaces in the cast. "(char *) &rset[R_THREADPTR]"
How is XCHAL_HAVE_THREADPTR set? Is it a reliable way of confirming the
presence of this register? Can a runtime check be used instead?
> +#endif
> }
>
> static void
> @@ -133,6 +138,10 @@ xtensa_store_gregset (struct regcache *regcache, const void *buf)
> supply_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
> supply_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
> supply_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
> +
> +#if XCHAL_HAVE_THREADPTR
> + supply_register_by_name (regcache, "threadptr", (char*)&rset[R_THREADPTR]);
Same as above regarding spaces and the cast construct and the
XCHAL_HAVE_THREADPTR check.
On Mon, Feb 13, 2017 at 10:26 AM, Luis Machado
<lgustavo@codesourcery.com> wrote:
> On 01/18/2017 05:56 PM, Max Filippov wrote:
>>
>> Provide aceess to the THREADPTR register to remote gdb.
>>
>> 2017-01-18 Max Filippov <jcmvbkbc@gmail.com>
>> gdb/gdbserver/
>
>
>
> Similarly, drop the gdb/gdbserver/
>
>> * linux-xtensa-low.c (regnum::R_THREADPTR): New enum member.
>> (xtensa_fill_gregset): Call collect_register_by_name for
>> threadptr register.
>> (xtensa_store_gregset): Call supply_register_by_name for
>> threadptr register.
>> ---
>> gdb/gdbserver/linux-xtensa-low.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/gdb/gdbserver/linux-xtensa-low.c
>> b/gdb/gdbserver/linux-xtensa-low.c
>> index 73fbfe2..eca0289 100644
>> --- a/gdb/gdbserver/linux-xtensa-low.c
>> +++ b/gdb/gdbserver/linux-xtensa-low.c
>> @@ -36,6 +36,7 @@ enum regnum {
>> R_LBEG, R_LEND, R_LCOUNT,
>> R_SAR,
>> R_WS, R_WB,
>> + R_THREADPTR,
>> R_A0 = 64
>> };
>
>
> Does xtensa have xml register description support?
AFAIK no.
> It would be nice to have
> those described instead of hardcoding the entries like this.
>>
>> @@ -86,6 +87,10 @@ xtensa_fill_gregset (struct regcache *regcache, void
>> *buf)
>> collect_register (regcache, i, ptr);
>> ptr += register_size (tdesc, i);
>> }
>> +
>> +#if XCHAL_HAVE_THREADPTR
>> + collect_register_by_name (regcache, "threadptr",
>> (char*)&rset[R_THREADPTR]);
>
>
> Missing spaces in the cast. "(char *) &rset[R_THREADPTR]"
Will add.
> How is XCHAL_HAVE_THREADPTR set?
It is defined in the core configuration overlay, include/xtensa-config.h
This file is generated for each Xtensa core and is copied over to the
source tree before building gdb for that specific core.
> Is it a reliable way of confirming the presence of this register?
This is the primary source of configuration-specific information.
> Can a runtime check be used instead?
AFAIK this information is not provided anywhere else.
>> +#endif
>> }
>>
>> static void
>> @@ -133,6 +138,10 @@ xtensa_store_gregset (struct regcache *regcache,
>> const void *buf)
>> supply_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
>> supply_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
>> supply_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
>> +
>> +#if XCHAL_HAVE_THREADPTR
>> + supply_register_by_name (regcache, "threadptr",
>> (char*)&rset[R_THREADPTR]);
>
>
> Same as above regarding spaces and the cast construct and the
> XCHAL_HAVE_THREADPTR check.
Will fix.
@@ -36,6 +36,7 @@ enum regnum {
R_LBEG, R_LEND, R_LCOUNT,
R_SAR,
R_WS, R_WB,
+ R_THREADPTR,
R_A0 = 64
};
@@ -86,6 +87,10 @@ xtensa_fill_gregset (struct regcache *regcache, void *buf)
collect_register (regcache, i, ptr);
ptr += register_size (tdesc, i);
}
+
+#if XCHAL_HAVE_THREADPTR
+ collect_register_by_name (regcache, "threadptr", (char*)&rset[R_THREADPTR]);
+#endif
}
static void
@@ -133,6 +138,10 @@ xtensa_store_gregset (struct regcache *regcache, const void *buf)
supply_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
supply_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
supply_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
+
+#if XCHAL_HAVE_THREADPTR
+ supply_register_by_name (regcache, "threadptr", (char*)&rset[R_THREADPTR]);
+#endif
}
/* Xtensa GNU/Linux PTRACE interface includes extended register set. */