[v7.1,3/8] Use xml-syscall to compare syscall numbers in arm_linux_sigreturn_return-addr
Commit Message
In this v7.1:
Use xml_get_syscall_number to return the number and compare with that.
Note the subsequent patches in the series have been updated with that change.
---
This patch changes checks for sigreturn and rt_sigreturn syscalls in
arm-linux-tdep.c from magic numbers to numbers computed from
syscall/arm-linux.xml.
It also adds a new function to xml-syscall.h/c to get the syscall number
called get_syscall_number.
No regressions, tested on ubuntu 14.04 ARMv7 and x86.
With gdbserver-{native,extended} / { -marm -mthumb }
gdb/ChangeLog:
* arm-linux-tdep.c (arm_linux_sigreturn_return_addr): Use
get_syscall_number.
* xml-syscall.c (get_syscall_number): New function.
* xml-syscall.h (get_syscall_number): New declaration.
---
gdb/arm-linux-tdep.c | 5 ++++-
gdb/xml-syscall.c | 8 ++++++++
gdb/xml-syscall.h | 6 ++++++
3 files changed, 18 insertions(+), 1 deletion(-)
Comments
Antoine Tremblay <antoine.tremblay@ericsson.com> writes:
> +int get_syscall_number (struct gdbarch *gdbarch,
> + const char *syscall_name)
get_syscall_number should be written in the next line.
> +{
> + init_syscalls_info (gdbarch);
> +
> + return xml_get_syscall_number (gdbarch, syscall_name);
> +}
Patch is good to me otherwise.
You also need a dummy version of the function under
#ifndef HAVE_LIBEXPAT
in order to avoid breaking the build when expat is not available.
BTW, I think this patch now makes libexpat a hard requirement
for basic ARM Linux debugging.
Thanks,
Pedro Alves
On 12/17/2015 05:17 AM, Pedro Alves wrote:
>
> You also need a dummy version of the function under
>
> #ifndef HAVE_LIBEXPAT
>
> in order to avoid breaking the build when expat is not available.
>
Right indeed thx.
> BTW, I think this patch now makes libexpat a hard requirement
> for basic ARM Linux debugging.
>
OK I had not considered that at first, that sounds wrong to me compared
to the option of having a #define and no hard requirement on expat.
On the other hand expat is needed for debugging with GDBServer...
Yao, had you considered this ?
Is it not better to have a #define considering this ?
Thanks,
Antoine
Antoine Tremblay <antoine.tremblay@ericsson.com> writes:
> On the other hand expat is needed for debugging with GDBServer...
>
Not really, we can build gdb with expat disabled, and it can still talks
with GDBserver.
> Yao, had you considered this ?
>
> Is it not better to have a #define considering this ?
Looks it is not easy to use xml-syscall for syscall numbers, probably we
can roll back to define these syscall number in macro and avoid using
xml things, like
#define ARM_SIGRETURN 119
On 12/17/2015 08:24 AM, Yao Qi wrote:
> Antoine Tremblay <antoine.tremblay@ericsson.com> writes:
>
>> On the other hand expat is needed for debugging with GDBServer...
>>
>
> Not really, we can build gdb with expat disabled, and it can still talks
> with GDBserver.
>
Humm really ? I thought it failed to read the target description and
failed with errors like :
warning: while parsing target description (at line 10): Target
description specified unknown architecture "arm"
warning: Could not load XML target description; ignoring
Remote 'g' packet reply is too long: 0...
>> Yao, had you considered this ?
>>
>> Is it not better to have a #define considering this ?
>
> Looks it is not easy to use xml-syscall for syscall numbers, probably we
> can roll back to define these syscall number in macro and avoid using
> xml things, like
>
> #define ARM_SIGRETURN 119
>
Yes I'll repost with that, I'll keep the __NR_sigreturn macros for
GDBServer however.
Thanks,
Antoine
@@ -788,8 +788,11 @@ arm_linux_sigreturn_return_addr (struct frame_info *frame,
unsigned long svc_number,
CORE_ADDR *pc, int *is_thumb)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+
/* Is this a sigreturn or rt_sigreturn syscall? */
- if (svc_number == 119 || svc_number == 173)
+ if (get_syscall_number (gdbarch, "sigreturn") == svc_number
+ || get_syscall_number (gdbarch, "rt_sigreturn") == svc_number)
{
if (get_frame_type (frame) == SIGTRAMP_FRAME)
{
@@ -422,4 +422,12 @@ get_syscall_names (struct gdbarch *gdbarch)
return xml_list_of_syscalls (gdbarch);
}
+int get_syscall_number (struct gdbarch *gdbarch,
+ const char *syscall_name)
+{
+ init_syscalls_info (gdbarch);
+
+ return xml_get_syscall_number (gdbarch, syscall_name);
+}
+
#endif /* ! HAVE_LIBEXPAT */
@@ -50,4 +50,10 @@ void get_syscall_by_name (struct gdbarch *gdbarch,
const char **get_syscall_names (struct gdbarch *gdbarch);
+/* Return the syscall number associated with the SYSCALL_NAME given in
+ argument. */
+
+int get_syscall_number (struct gdbarch *gdbarch,
+ const char *syscall_name);
+
#endif /* XML_SYSCALL_H */