Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
@ 2013-09-23 13:04 Jose E. Marchesi
  2013-09-23 13:33 ` Tedeschi, Walfred
  2013-09-23 14:36 ` Mark Kettenis
  0 siblings, 2 replies; 7+ messages in thread
From: Jose E. Marchesi @ 2013-09-23 13:04 UTC (permalink / raw)
  To: gdb-patches


ping.  Could someone please take a look to this patch?  Thanks.

From: jose.marchesi@oracle.com (Jose E. Marchesi)
To: gdb-patches@sourceware.org
Subject: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
Date: Tue, 10 Sep 2013 20:29:33 +0200

Hi.

This small patch makes sparc64_linux_step_trap to return 0 when a
breakpoint is set in a `ta 0x6d' which is not a sigreturn syscall.  In
these cases no rt_frame exists in the stack and thus the read PC is
wrong.

2013-09-10  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc64-linux-tdep.c (sparc64_linux_step_trap): Make sure the
	trap is a sigreturn syscall.

Index: gdb/sparc64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-linux-tdep.c,v
retrieving revision 1.31
diff -u -r1.31 sparc64-linux-tdep.c
--- gdb/sparc64-linux-tdep.c	1 Jan 2013 06:32:51 -0000	1.31
+++ gdb/sparc64-linux-tdep.c	10 Sep 2013 18:17:25 -0000
@@ -111,7 +111,9 @@
 static CORE_ADDR
 sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn)
 {
-  if (insn == 0x91d0206d)
+  /* __NR_rt_sigreturn is 101  */
+  if ((insn == 0x91d0206d)
+      && (get_frame_register_unsigned (frame, SPARC_G1_REGNUM) == 101))
     {
       struct gdbarch *gdbarch = get_frame_arch (frame);
       enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
  2013-09-23 13:04 [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn Jose E. Marchesi
@ 2013-09-23 13:33 ` Tedeschi, Walfred
  2013-09-23 14:02   ` Jose E. Marchesi
  2013-09-23 14:36 ` Mark Kettenis
  1 sibling, 1 reply; 7+ messages in thread
From: Tedeschi, Walfred @ 2013-09-23 13:33 UTC (permalink / raw)
  To: Jose E. Marchesi, gdb-patches

Hi Jose,

Have you observed some failure to submit this patch? If so could you also provide a test case?

Regards,
-Fred

-----Original Message-----
From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Jose E. Marchesi
Sent: Monday, September 23, 2013 3:07 PM
To: gdb-patches@sourceware.org
Subject: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn


ping.  Could someone please take a look to this patch?  Thanks.

From: jose.marchesi@oracle.com (Jose E. Marchesi)
To: gdb-patches@sourceware.org
Subject: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
Date: Tue, 10 Sep 2013 20:29:33 +0200

Hi.

This small patch makes sparc64_linux_step_trap to return 0 when a breakpoint is set in a `ta 0x6d' which is not a sigreturn syscall.  In these cases no rt_frame exists in the stack and thus the read PC is wrong.

2013-09-10  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc64-linux-tdep.c (sparc64_linux_step_trap): Make sure the
	trap is a sigreturn syscall.

Index: gdb/sparc64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-linux-tdep.c,v
retrieving revision 1.31
diff -u -r1.31 sparc64-linux-tdep.c
--- gdb/sparc64-linux-tdep.c	1 Jan 2013 06:32:51 -0000	1.31
+++ gdb/sparc64-linux-tdep.c	10 Sep 2013 18:17:25 -0000
@@ -111,7 +111,9 @@
 static CORE_ADDR
 sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn)  {
-  if (insn == 0x91d0206d)
+  /* __NR_rt_sigreturn is 101  */
+  if ((insn == 0x91d0206d)
+      && (get_frame_register_unsigned (frame, SPARC_G1_REGNUM) == 101))
     {
       struct gdbarch *gdbarch = get_frame_arch (frame);
       enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);

Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
  2013-09-23 13:33 ` Tedeschi, Walfred
@ 2013-09-23 14:02   ` Jose E. Marchesi
  2013-10-04 11:22     ` Pedro Alves
  0 siblings, 1 reply; 7+ messages in thread
From: Jose E. Marchesi @ 2013-09-23 14:02 UTC (permalink / raw)
  To: Tedeschi, Walfred; +Cc: gdb-patches


Hi.
    
    Have you observed some failure to submit this patch? If so could you
    also provide a test case?

I noticed that watchpoints were not surviving ld.so.  Consider this test
program:

  int jorl;

  int main ()
  {
    jorl = 20;
    return 0;
  }

If you set a watchpoint to watch writes to the variable 'jorl' and then

  [jemarch@jemarch1 ~]$ gdb foo
  GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.0.2.el6)
  Copyright (C) 2010 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later
  <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.  Type "show
  copying"
  and "show warranty" for details.
  This GDB was configured as "sparc64-redhat-linux-gnu".
  For bug reporting instructions, please see:
  <http://www.gnu.org/software/gdb/bugs/>...
  Reading symbols from /home/jemarch/foo...(no debugging symbols
  found)...done.
  (gdb) watch jorl
  Watchpoint 1: jorl
  (gdb) run
  Starting program: /home/jemarch/foo
  0xfffff8010001c444 in mmap64 () from /lib64/ld-linux.so.2
  Could not insert single-step breakpoint at 0x1
  (gdb)

As described in the patch the problem is that single-stepping over 'ta
0x6d' instructions is not working properly.  And the reason is that
sparc64_linux_step_trap is only intended to be useful when
single-stepping sigreturn syscalls and must return zero in any other
case.

Do you want a test for gdb/testsuite?  In that case, what would be the
best place where to add the test?  gdb.base?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
  2013-09-23 13:04 [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn Jose E. Marchesi
  2013-09-23 13:33 ` Tedeschi, Walfred
@ 2013-09-23 14:36 ` Mark Kettenis
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Kettenis @ 2013-09-23 14:36 UTC (permalink / raw)
  To: jose.marchesi; +Cc: gdb-patches

> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
> Sender: gdb-patches-owner@sourceware.org
> 
> ping.  Could someone please take a look to this patch?  Thanks.

Diff looks reasonable to me, but I'm not really familliar with Linux'
system call interface on SPARC.  Best to make sure David S. Miller
takes a look at this.

> From: jose.marchesi@oracle.com (Jose E. Marchesi)
> To: gdb-patches@sourceware.org
> Subject: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
> Date: Tue, 10 Sep 2013 20:29:33 +0200
> 
> Hi.
> 
> This small patch makes sparc64_linux_step_trap to return 0 when a
> breakpoint is set in a `ta 0x6d' which is not a sigreturn syscall.  In
> these cases no rt_frame exists in the stack and thus the read PC is
> wrong.
> 
> 2013-09-10  Jose E. Marchesi  <jose.marchesi@oracle.com>
> 
> 	* sparc64-linux-tdep.c (sparc64_linux_step_trap): Make sure the
> 	trap is a sigreturn syscall.
> 
> Index: gdb/sparc64-linux-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/sparc64-linux-tdep.c,v
> retrieving revision 1.31
> diff -u -r1.31 sparc64-linux-tdep.c
> --- gdb/sparc64-linux-tdep.c	1 Jan 2013 06:32:51 -0000	1.31
> +++ gdb/sparc64-linux-tdep.c	10 Sep 2013 18:17:25 -0000
> @@ -111,7 +111,9 @@
>  static CORE_ADDR
>  sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn)
>  {
> -  if (insn == 0x91d0206d)
> +  /* __NR_rt_sigreturn is 101  */
> +  if ((insn == 0x91d0206d)
> +      && (get_frame_register_unsigned (frame, SPARC_G1_REGNUM) == 101))
>      {
>        struct gdbarch *gdbarch = get_frame_arch (frame);
>        enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
  2013-09-23 14:02   ` Jose E. Marchesi
@ 2013-10-04 11:22     ` Pedro Alves
  0 siblings, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2013-10-04 11:22 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: Tedeschi, Walfred, gdb-patches

Hi Jose!

On 09/23/2013 03:04 PM, Jose E. Marchesi wrote:

> 
> I noticed that watchpoints were not surviving ld.so.  Consider this test
> program:
> 
>   int jorl;
> 
>   int main ()
>   {
>     jorl = 20;
>     return 0;
>   }
> 
> If you set a watchpoint to watch writes to the variable 'jorl' and then
> 
>   [jemarch@jemarch1 ~]$ gdb foo
>   GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.0.2.el6)
>   Copyright (C) 2010 Free Software Foundation, Inc.
>   License GPLv3+: GNU GPL version 3 or later
>   <http://gnu.org/licenses/gpl.html>
>   This is free software: you are free to change and redistribute it.
>   There is NO WARRANTY, to the extent permitted by law.  Type "show
>   copying"
>   and "show warranty" for details.
>   This GDB was configured as "sparc64-redhat-linux-gnu".
>   For bug reporting instructions, please see:
>   <http://www.gnu.org/software/gdb/bugs/>...
>   Reading symbols from /home/jemarch/foo...(no debugging symbols
>   found)...done.
>   (gdb) watch jorl
>   Watchpoint 1: jorl
>   (gdb) run
>   Starting program: /home/jemarch/foo
>   0xfffff8010001c444 in mmap64 () from /lib64/ld-linux.so.2
>   Could not insert single-step breakpoint at 0x1
>   (gdb)
> 
> As described in the patch the problem is that single-stepping over 'ta
> 0x6d' instructions is not working properly.  And the reason is that
> sparc64_linux_step_trap is only intended to be useful when
> single-stepping sigreturn syscalls and must return zero in any other
> case.
> 
> Do you want a test for gdb/testsuite?

This sounds really like a basic use case -- set a watchpoint
on a global, before running the program, and then run the program,
with hardware watchpoints disabled, so that gdb uses software
watchpoints all the way, or IOW, GDB single-steps all the way through
the program's execution, starting at the entry point, up until the
watchpoint triggers.

I'm surprised the testsuite doesn't trip on this already.  E.g.,
gdb.base/watchpoint.exp.  But maybe all tests are only creating
watchpoints after running to main?
If indeed this isn't covered already, then yeah, a test like
that looks to be quite useful to have.  Basically, the test would
just need to make sure hardware watchpoints are disabled, with
"set can-use-hw-watchpoints 0" (or it'd create a watchpoint on something
not memory, like watch $some_convenience_var), and it shouldn't
use "run" directly, so that it works with gdbserver/"target remote"
as well.  I think it could use gdb_start_cmd for the latter.
Actually, gdb.base/watchpoint-hw.exp looks quite almost like what
you'd aim for, except well, it's skipped on software watchpoint targets.

> In that case, what would be the best place where to add the test?  gdb.base?

Yep, that's fine.  You can also adapt or add to an existing case,
if it makes sense.

Thanks,
-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
@ 2013-09-16  9:46 Jose E. Marchesi
  0 siblings, 0 replies; 7+ messages in thread
From: Jose E. Marchesi @ 2013-09-16  9:46 UTC (permalink / raw)
  To: gdb-patches


ping...

From: jose.marchesi@oracle.com (Jose E. Marchesi)
To: gdb-patches@sourceware.org
Subject: [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
Date: Tue, 10 Sep 2013 20:29:33 +0200

Hi.

This small patch makes sparc64_linux_step_trap to return 0 when a
breakpoint is set in a `ta 0x6d' which is not a sigreturn syscall.  In
these cases no rt_frame exists in the stack and thus the read PC is
wrong.

2013-09-10  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc64-linux-tdep.c (sparc64_linux_step_trap): Make sure the
	trap is a sigreturn syscall.

Index: gdb/sparc64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-linux-tdep.c,v
retrieving revision 1.31
diff -u -r1.31 sparc64-linux-tdep.c
--- gdb/sparc64-linux-tdep.c	1 Jan 2013 06:32:51 -0000	1.31
+++ gdb/sparc64-linux-tdep.c	10 Sep 2013 18:17:25 -0000
@@ -111,7 +111,9 @@
 static CORE_ADDR
 sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn)
 {
-  if (insn == 0x91d0206d)
+  /* __NR_rt_sigreturn is 101  */
+  if ((insn == 0x91d0206d)
+      && (get_frame_register_unsigned (frame, SPARC_G1_REGNUM) == 101))
     {
       struct gdbarch *gdbarch = get_frame_arch (frame);
       enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn
@ 2013-09-10 18:28 Jose E. Marchesi
  0 siblings, 0 replies; 7+ messages in thread
From: Jose E. Marchesi @ 2013-09-10 18:28 UTC (permalink / raw)
  To: gdb-patches


Hi.

This small patch makes sparc64_linux_step_trap to return 0 when a
breakpoint is set in a `ta 0x6d' which is not a sigreturn syscall.  In
these cases no rt_frame exists in the stack and thus the read PC is
wrong.

2013-09-10  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* sparc64-linux-tdep.c (sparc64_linux_step_trap): Make sure the
	trap is a sigreturn syscall.

Index: gdb/sparc64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-linux-tdep.c,v
retrieving revision 1.31
diff -u -r1.31 sparc64-linux-tdep.c
--- gdb/sparc64-linux-tdep.c	1 Jan 2013 06:32:51 -0000	1.31
+++ gdb/sparc64-linux-tdep.c	10 Sep 2013 18:17:25 -0000
@@ -111,7 +111,9 @@
 static CORE_ADDR
 sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn)
 {
-  if (insn == 0x91d0206d)
+  /* __NR_rt_sigreturn is 101  */
+  if ((insn == 0x91d0206d)
+      && (get_frame_register_unsigned (frame, SPARC_G1_REGNUM) == 101))
     {
       struct gdbarch *gdbarch = get_frame_arch (frame);
       enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-10-04 11:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-23 13:04 [PATCH][SPARC64] Fix breakpointing in syscalls other than sigreturn Jose E. Marchesi
2013-09-23 13:33 ` Tedeschi, Walfred
2013-09-23 14:02   ` Jose E. Marchesi
2013-10-04 11:22     ` Pedro Alves
2013-09-23 14:36 ` Mark Kettenis
  -- strict thread matches above, loose matches on Subject: below --
2013-09-16  9:46 Jose E. Marchesi
2013-09-10 18:28 Jose E. Marchesi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox