[v7.1,3/8] Use xml-syscall to compare syscall numbers in arm_linux_sigreturn_return-addr

Message ID 1450283042-28746-1-git-send-email-antoine.tremblay@ericsson.com
State New, archived
Headers

Commit Message

Antoine Tremblay Dec. 16, 2015, 4:24 p.m. UTC
  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

Yao Qi Dec. 17, 2015, 10:09 a.m. UTC | #1
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.
  
Pedro Alves Dec. 17, 2015, 10:17 a.m. UTC | #2
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
  
Antoine Tremblay Dec. 17, 2015, 12:51 p.m. UTC | #3
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
  
Yao Qi Dec. 17, 2015, 1:24 p.m. UTC | #4
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
  
Antoine Tremblay Dec. 17, 2015, 1:36 p.m. UTC | #5
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
  

Patch

diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 73e1271..56131e5 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -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)
 	{
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index 31a80a5..449539f 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -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 */
diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
index 55c9696..2930982 100644
--- a/gdb/xml-syscall.h
+++ b/gdb/xml-syscall.h
@@ -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 */