Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA 7/8] New port: TI C6x:  test case fixes
@ 2011-07-20  2:12 Yao Qi
  2011-07-25 11:37 ` Yao Qi
  0 siblings, 1 reply; 9+ messages in thread
From: Yao Qi @ 2011-07-20  2:12 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

Two changes in this patch are related to c6x, while the other two are
not related to c6x very much, which are about uclinx on NON-MMU machine.

Both gdb.base/savedregs.exp and gdb.mi/mi-syn-frame.exp expects to get
an exception when access memory of address 0x0.  It doesn't work on
NON-MMU machine.

Actually, this has been discussed in this thread,

  http://sourceware.org/ml/gdb-patches/2011-06/msg00124.html
  [patch, testsuite] gdb.base/savedregs.exp: SIGSEGV -> SIGILL

The final conclusion is that we use SIGILL for NON-MMU machine, and
continue to use SIGSEGV for MMU machine.  Changes in this patch is
implemented in this way.

-- 
Yao (齐尧)

[-- Attachment #2: 0007-test-case.patch --]
[-- Type: text/x-patch, Size: 4308 bytes --]


        gdb/testsuite/
        * gdb.base/maint.exp: set data_section to ".neardata".
        * gdb.base/savedregs.c (thrower): Trigger SIGILL on NO-MMU machine.
        * gdb.base/savedregs.exp: Handle SIGILL.
        (process_saved_regs): Don't check saved register on tic6x-*-*
        * gdb.mi/mi-syn-frame.c (bar): Trigger SIGILL on NO-MMU machine.
---
 gdb/testsuite/gdb.base/maint.exp     |    4 ++++
 gdb/testsuite/gdb.base/savedregs.c   |   22 ++++++++++++++++++++++
 gdb/testsuite/gdb.base/savedregs.exp |    9 +++++++++
 gdb/testsuite/gdb.mi/mi-syn-frame.c  |   21 ++++++++++++++++++++-
 4 files changed, 55 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 61ad439..9ef84af 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -394,6 +394,10 @@ gdb_test_multiple "maint info sections" "maint info sections" {
 	set data_section ER_RW
 	pass "maint info sections"
     }
+    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
+	# c6x doesn't have .data section.  It has .neardata and .fardata section.
+	set data_section ".neardata"
+    }
     -re "Exec file:\r\n.*break($EXEEXT)?., file type.*$gdb_prompt $" {
 	pass "maint info sections"
     }
diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c
index 9f302a0..582afc4 100644
--- a/gdb/testsuite/gdb.base/savedregs.c
+++ b/gdb/testsuite/gdb.base/savedregs.c
@@ -22,6 +22,12 @@
 #include <signal.h>
 #include <sys/time.h>
 
+#ifdef __UCLIBC__
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#define HAS_NOMMU
+#endif
+#endif
+
 static volatile int done;
 
 extern int
@@ -45,11 +51,27 @@ catcher (int sig)
 static void
 thrower (void)
 {
+#if defined(HAS_NOMMU)
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  /* 0x56454314 is also an invalid insn but it causes SIGTRAP in kernel.  */
+  asm(".word 0x56454313");
+#else
+#error Please write an invalid instruction here for your target
+#endif
+#else /* defined(HAS_NOMMU) */
   *(char *)0 = 0;
+#endif /* defined(HAS_NOMMU) */
 }
 
 main ()
 {
+#if defined(HAS_NOMMU)
+  signal (SIGILL, catcher);
+#else
   signal (SIGSEGV, catcher);
+#endif
+
   thrower ();
 }
diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
index eeee0ff..4408137 100644
--- a/gdb/testsuite/gdb.base/savedregs.exp
+++ b/gdb/testsuite/gdb.base/savedregs.exp
@@ -84,6 +84,14 @@ proc process_saved_regs { current inner outer } {
 		# Sigtramp frames don't yet print <signal trampoline>.
 		set pat "Stack frame at .* Saved registers:.*"
 	    }
+	    thrower {
+		if { [istarget tic6x-*-*] } {
+		    # On tic6x, there is no register saved in function thrower.
+		    set pat "Stack frame at .* in $func .*"
+		} else {
+		    set pat "Stack frame at .* in $func .* Saved registers:.*"
+		}
+	    }
 	    default {
 		set pat "Stack frame at .* in $func .* Saved registers:.*"
 	    }
@@ -143,6 +151,7 @@ process_saved_regs thrower { main } { }
 # Continue to the signal catcher, check main's saved-reg info, capture
 # catcher's saved-reg info.
 gdb_test "handle SIGSEGV pass print nostop"
+gdb_test "handle SIGILL pass print nostop"
 gdb_test "advance catcher" "catcher .* at .*"
 process_saved_regs catcher { sigtramp thrower } { main }
 
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.c b/gdb/testsuite/gdb.mi/mi-syn-frame.c
index ddfc08e..cffc5e0 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.c
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.c
@@ -2,6 +2,12 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+#ifdef __UCLIBC__
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#define HAS_NOMMU
+#endif
+#endif
+
 void foo (void);
 void bar (void);
 
@@ -25,9 +31,22 @@ foo (void)
 void 
 bar (void)
 {
-  char *nuller = 0;
+#if defined(HAS_NOMMU)
+
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  /* 0x56454314 is also an invalid insn but it causes SIGTRAP in kernel.  */
+  asm(".word 0x56454313");
+#else
+#error Please write an invalid instruction here for your target
+#endif
 
+#else /* defined(HAS_NOMMU) */
+  char *nuller = 0;
   *nuller = 'a';      /* try to cause a segfault */
+#endif
+
 }
 
 void
-- 
1.7.0.4


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-07-20  2:12 [RFA 7/8] New port: TI C6x: test case fixes Yao Qi
@ 2011-07-25 11:37 ` Yao Qi
  2011-08-09 14:22   ` Pedro Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Yao Qi @ 2011-07-25 11:37 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

On 07/20/2011 10:10 AM, Yao Qi wrote:
> Two changes in this patch are related to c6x, while the other two are
> not related to c6x very much, which are about uclinx on NON-MMU machine.
> 

Another change is included in this patch related to c6x.  It is in
gdb.xml/tdesc-regs.exp, since C6x port starts to understand xml target
description sent from gdbserver.

-- 
Yao (齐尧)

[-- Attachment #2: 0008-test-case.patch --]
[-- Type: text/x-patch, Size: 4838 bytes --]


        gdb/testsuite/
        * gdb.base/maint.exp: set data_section to ".neardata".
        * gdb.base/savedregs.c (thrower): Trigger SIGILL on NO-MMU machine.
        * gdb.base/savedregs.exp: Handle SIGILL.
        (process_saved_regs): Don't check saved register on tic6x-*-*
        * gdb.mi/mi-syn-frame.c (bar): Trigger SIGILL on NO-MMU machine.
	* gdb.xml/tdesc-regs.exp: Set core-regs for tic6x-*-*.
---
 gdb/testsuite/gdb.base/maint.exp     |    4 ++++
 gdb/testsuite/gdb.base/savedregs.c   |   22 ++++++++++++++++++++++
 gdb/testsuite/gdb.base/savedregs.exp |    9 +++++++++
 gdb/testsuite/gdb.mi/mi-syn-frame.c  |   21 ++++++++++++++++++++-
 gdb/testsuite/gdb.xml/tdesc-regs.exp |    3 +++
 5 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 61ad439..9ef84af 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -394,6 +394,10 @@ gdb_test_multiple "maint info sections" "maint info sections" {
 	set data_section ER_RW
 	pass "maint info sections"
     }
+    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
+	# c6x doesn't have .data section.  It has .neardata and .fardata section.
+	set data_section ".neardata"
+    }
     -re "Exec file:\r\n.*break($EXEEXT)?., file type.*$gdb_prompt $" {
 	pass "maint info sections"
     }
diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c
index 9f302a0..582afc4 100644
--- a/gdb/testsuite/gdb.base/savedregs.c
+++ b/gdb/testsuite/gdb.base/savedregs.c
@@ -22,6 +22,12 @@
 #include <signal.h>
 #include <sys/time.h>
 
+#ifdef __UCLIBC__
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#define HAS_NOMMU
+#endif
+#endif
+
 static volatile int done;
 
 extern int
@@ -45,11 +51,27 @@ catcher (int sig)
 static void
 thrower (void)
 {
+#if defined(HAS_NOMMU)
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  /* 0x56454314 is also an invalid insn but it causes SIGTRAP in kernel.  */
+  asm(".word 0x56454313");
+#else
+#error Please write an invalid instruction here for your target
+#endif
+#else /* defined(HAS_NOMMU) */
   *(char *)0 = 0;
+#endif /* defined(HAS_NOMMU) */
 }
 
 main ()
 {
+#if defined(HAS_NOMMU)
+  signal (SIGILL, catcher);
+#else
   signal (SIGSEGV, catcher);
+#endif
+
   thrower ();
 }
diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
index eeee0ff..4408137 100644
--- a/gdb/testsuite/gdb.base/savedregs.exp
+++ b/gdb/testsuite/gdb.base/savedregs.exp
@@ -84,6 +84,14 @@ proc process_saved_regs { current inner outer } {
 		# Sigtramp frames don't yet print <signal trampoline>.
 		set pat "Stack frame at .* Saved registers:.*"
 	    }
+	    thrower {
+		if { [istarget tic6x-*-*] } {
+		    # On tic6x, there is no register saved in function thrower.
+		    set pat "Stack frame at .* in $func .*"
+		} else {
+		    set pat "Stack frame at .* in $func .* Saved registers:.*"
+		}
+	    }
 	    default {
 		set pat "Stack frame at .* in $func .* Saved registers:.*"
 	    }
@@ -143,6 +151,7 @@ process_saved_regs thrower { main } { }
 # Continue to the signal catcher, check main's saved-reg info, capture
 # catcher's saved-reg info.
 gdb_test "handle SIGSEGV pass print nostop"
+gdb_test "handle SIGILL pass print nostop"
 gdb_test "advance catcher" "catcher .* at .*"
 process_saved_regs catcher { sigtramp thrower } { main }
 
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.c b/gdb/testsuite/gdb.mi/mi-syn-frame.c
index ddfc08e..cffc5e0 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.c
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.c
@@ -2,6 +2,12 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+#ifdef __UCLIBC__
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#define HAS_NOMMU
+#endif
+#endif
+
 void foo (void);
 void bar (void);
 
@@ -25,9 +31,22 @@ foo (void)
 void 
 bar (void)
 {
-  char *nuller = 0;
+#if defined(HAS_NOMMU)
+
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  /* 0x56454314 is also an invalid insn but it causes SIGTRAP in kernel.  */
+  asm(".word 0x56454313");
+#else
+#error Please write an invalid instruction here for your target
+#endif
 
+#else /* defined(HAS_NOMMU) */
+  char *nuller = 0;
   *nuller = 'a';      /* try to cause a segfault */
+#endif
+
 }
 
 void
diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp
index 224c082..6a12dba 100644
--- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
@@ -53,6 +53,9 @@ switch -glob -- [istarget] {
 	unsupported "register tests"
 	return 0
     }
+    "tic6x-*-*" {
+	set core-regs {tic6x-core.xml}
+    }
     "i?86-*-*" {
 	set architecture "i386"
 	set regdir "i386/"
-- 
1.7.0.4


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-07-25 11:37 ` Yao Qi
@ 2011-08-09 14:22   ` Pedro Alves
  2011-08-09 15:03     ` Yao Qi
  0 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2011-08-09 14:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Yao Qi

On Monday 25 July 2011 08:26:57, Yao Qi wrote:

> diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
> index 61ad439..9ef84af 100644
> --- a/gdb/testsuite/gdb.base/maint.exp
> +++ b/gdb/testsuite/gdb.base/maint.exp
> @@ -394,6 +394,10 @@ gdb_test_multiple "maint info sections" "maint info sections" {
>         set data_section ER_RW
>         pass "maint info sections"
>      }
> +    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
> +       # c6x doesn't have .data section.  It has .neardata and .fardata section.
> +       set data_section ".neardata"

Missing "pass" ?

Otherwise okay.

-- 
Pedro Alves


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-08-09 14:22   ` Pedro Alves
@ 2011-08-09 15:03     ` Yao Qi
  2011-08-09 15:17       ` Mark Kettenis
  0 siblings, 1 reply; 9+ messages in thread
From: Yao Qi @ 2011-08-09 15:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

On 08/09/2011 10:22 PM, Pedro Alves wrote:
>> > diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
>> > index 61ad439..9ef84af 100644
>> > --- a/gdb/testsuite/gdb.base/maint.exp
>> > +++ b/gdb/testsuite/gdb.base/maint.exp
>> > @@ -394,6 +394,10 @@ gdb_test_multiple "maint info sections" "maint info sections" {
>> >         set data_section ER_RW
>> >         pass "maint info sections"
>> >      }
>> > +    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
>> > +       # c6x doesn't have .data section.  It has .neardata and .fardata section.
>> > +       set data_section ".neardata"
> Missing "pass" ?

Oh, yes.  Fixed.

-- 
Yao (齐尧)

[-- Attachment #2: 0008-test-case.patch --]
[-- Type: text/x-patch, Size: 4868 bytes --]


        gdb/testsuite/
        * gdb.base/maint.exp: set data_section to ".neardata".
        * gdb.base/savedregs.c (thrower): Trigger SIGILL on NO-MMU machine.
        * gdb.base/savedregs.exp: Handle SIGILL.
        (process_saved_regs): Don't check saved register on tic6x-*-*
        * gdb.mi/mi-syn-frame.c (bar): Trigger SIGILL on NO-MMU machine.
	* gdb.xml/tdesc-regs.exp: Set core-regs for tic6x-*-*.
---
 gdb/testsuite/gdb.base/maint.exp     |    5 +++++
 gdb/testsuite/gdb.base/savedregs.c   |   22 ++++++++++++++++++++++
 gdb/testsuite/gdb.base/savedregs.exp |    9 +++++++++
 gdb/testsuite/gdb.mi/mi-syn-frame.c  |   21 ++++++++++++++++++++-
 gdb/testsuite/gdb.xml/tdesc-regs.exp |    3 +++
 5 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 61ad439..2bd2593 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -394,6 +394,11 @@ gdb_test_multiple "maint info sections" "maint info sections" {
 	set data_section ER_RW
 	pass "maint info sections"
     }
+    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
+	# c6x doesn't have .data section.  It has .neardata and .fardata section.
+	set data_section ".neardata"
+	pass "maint info sections"
+    }
     -re "Exec file:\r\n.*break($EXEEXT)?., file type.*$gdb_prompt $" {
 	pass "maint info sections"
     }
diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c
index 9f302a0..582afc4 100644
--- a/gdb/testsuite/gdb.base/savedregs.c
+++ b/gdb/testsuite/gdb.base/savedregs.c
@@ -22,6 +22,12 @@
 #include <signal.h>
 #include <sys/time.h>
 
+#ifdef __UCLIBC__
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#define HAS_NOMMU
+#endif
+#endif
+
 static volatile int done;
 
 extern int
@@ -45,11 +51,27 @@ catcher (int sig)
 static void
 thrower (void)
 {
+#if defined(HAS_NOMMU)
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  /* 0x56454314 is also an invalid insn but it causes SIGTRAP in kernel.  */
+  asm(".word 0x56454313");
+#else
+#error Please write an invalid instruction here for your target
+#endif
+#else /* defined(HAS_NOMMU) */
   *(char *)0 = 0;
+#endif /* defined(HAS_NOMMU) */
 }
 
 main ()
 {
+#if defined(HAS_NOMMU)
+  signal (SIGILL, catcher);
+#else
   signal (SIGSEGV, catcher);
+#endif
+
   thrower ();
 }
diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
index eeee0ff..4408137 100644
--- a/gdb/testsuite/gdb.base/savedregs.exp
+++ b/gdb/testsuite/gdb.base/savedregs.exp
@@ -84,6 +84,14 @@ proc process_saved_regs { current inner outer } {
 		# Sigtramp frames don't yet print <signal trampoline>.
 		set pat "Stack frame at .* Saved registers:.*"
 	    }
+	    thrower {
+		if { [istarget tic6x-*-*] } {
+		    # On tic6x, there is no register saved in function thrower.
+		    set pat "Stack frame at .* in $func .*"
+		} else {
+		    set pat "Stack frame at .* in $func .* Saved registers:.*"
+		}
+	    }
 	    default {
 		set pat "Stack frame at .* in $func .* Saved registers:.*"
 	    }
@@ -143,6 +151,7 @@ process_saved_regs thrower { main } { }
 # Continue to the signal catcher, check main's saved-reg info, capture
 # catcher's saved-reg info.
 gdb_test "handle SIGSEGV pass print nostop"
+gdb_test "handle SIGILL pass print nostop"
 gdb_test "advance catcher" "catcher .* at .*"
 process_saved_regs catcher { sigtramp thrower } { main }
 
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.c b/gdb/testsuite/gdb.mi/mi-syn-frame.c
index ddfc08e..cffc5e0 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.c
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.c
@@ -2,6 +2,12 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+#ifdef __UCLIBC__
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#define HAS_NOMMU
+#endif
+#endif
+
 void foo (void);
 void bar (void);
 
@@ -25,9 +31,22 @@ foo (void)
 void 
 bar (void)
 {
-  char *nuller = 0;
+#if defined(HAS_NOMMU)
+
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  /* 0x56454314 is also an invalid insn but it causes SIGTRAP in kernel.  */
+  asm(".word 0x56454313");
+#else
+#error Please write an invalid instruction here for your target
+#endif
 
+#else /* defined(HAS_NOMMU) */
+  char *nuller = 0;
   *nuller = 'a';      /* try to cause a segfault */
+#endif
+
 }
 
 void
diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp
index 224c082..6a12dba 100644
--- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
@@ -53,6 +53,9 @@ switch -glob -- [istarget] {
 	unsupported "register tests"
 	return 0
     }
+    "tic6x-*-*" {
+	set core-regs {tic6x-core.xml}
+    }
     "i?86-*-*" {
 	set architecture "i386"
 	set regdir "i386/"
-- 
1.7.0.4


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-08-09 15:03     ` Yao Qi
@ 2011-08-09 15:17       ` Mark Kettenis
  2011-08-09 15:25         ` Yao Qi
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Kettenis @ 2011-08-09 15:17 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> Date: Tue, 09 Aug 2011 23:03:37 +0800
> From: Yao Qi <yao@codesourcery.com>

I really think your approach is rather fragile...

> diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c
> index 9f302a0..582afc4 100644
> --- a/gdb/testsuite/gdb.base/savedregs.c
> +++ b/gdb/testsuite/gdb.base/savedregs.c
> @@ -22,6 +22,12 @@
>  #include <signal.h>
>  #include <sys/time.h>
>  
> +#ifdef __UCLIBC__
> +#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
> +#define HAS_NOMMU
> +#endif
> +#endif
> +
>  static volatile int done;
>  
>  extern int
> @@ -45,11 +51,27 @@ catcher (int sig)
>  static void
>  thrower (void)
>  {
> +#if defined(HAS_NOMMU)
> +#if defined(__arm__)
> +  asm(".word 0xf8f00000");
> +#elif defined(__TMS320C6X__)
> +  /* 0x56454314 is also an invalid insn but it causes SIGTRAP in kernel.  */
> +  asm(".word 0x56454313");
> +#else
> +#error Please write an invalid instruction here for your target
> +#endif
> +#else /* defined(HAS_NOMMU) */
>    *(char *)0 = 0;
> +#endif /* defined(HAS_NOMMU) */
>  }
>  
>  main ()
>  {
> +#if defined(HAS_NOMMU)
> +  signal (SIGILL, catcher);
> +#else
>    signal (SIGSEGV, catcher);
> +#endif
> +
>    thrower ();
>  }


Why depend on this NOMMU-magic?  Just install the signal handler for
bth SIGSEGV and SIGILL, try a store to (or perhaps a read from)
address 0, and then fall through to executing an illegal instruction.


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-08-09 15:17       ` Mark Kettenis
@ 2011-08-09 15:25         ` Yao Qi
  2011-08-10 12:28           ` Mark Kettenis
  0 siblings, 1 reply; 9+ messages in thread
From: Yao Qi @ 2011-08-09 15:25 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On 08/09/2011 11:15 PM, Mark Kettenis wrote:
> Why depend on this NOMMU-magic?  Just install the signal handler for
> bth SIGSEGV and SIGILL, try a store to (or perhaps a read from)
> address 0, and then fall through to executing an illegal instruction.

Because I want to reduce the scope of using invalid instruction.  We
only need to know the invalid instruction for HAS_NOMMU arch, and emit
error if we forget to define an invalid instruction for a new NOMMU
port.  Do it make sense?

-- 
Yao (齐尧)


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-08-09 15:25         ` Yao Qi
@ 2011-08-10 12:28           ` Mark Kettenis
  2011-08-10 14:05             ` Yao Qi
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Kettenis @ 2011-08-10 12:28 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> Date: Tue, 09 Aug 2011 23:25:06 +0800
> From: Yao Qi <yao@codesourcery.com>
> 
> On 08/09/2011 11:15 PM, Mark Kettenis wrote:
> > Why depend on this NOMMU-magic?  Just install the signal handler for
> > bth SIGSEGV and SIGILL, try a store to (or perhaps a read from)
> > address 0, and then fall through to executing an illegal instruction.
> 
> Because I want to reduce the scope of using invalid instruction.  We
> only need to know the invalid instruction for HAS_NOMMU arch, and emit
> error if we forget to define an invalid instruction for a new NOMMU
> port.  Do it make sense?

I don't really think that's an issue.  If the test is run on an
mmu-less machine for which no illegal instruction is defined, the test
will fail.  That should prompt someone to look at the test and add the
missing instruction.

I really just want to avoid the #ifdef maze you're creating which
makes the code more complicated and the test less generic.  I think
you're too much focussed on reducing the number of FAILs for your
particular target to zero instead of improving the tests such that
they become more generally useful.  For example:

> diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
> index eeee0ff..4408137 100644
> --- a/gdb/testsuite/gdb.base/savedregs.exp
> +++ b/gdb/testsuite/gdb.base/savedregs.exp
> @@ -84,6 +84,14 @@ proc process_saved_regs { current inner outer } {
>  		# Sigtramp frames don't yet print <signal trampoline>.
>  		set pat "Stack frame at .* Saved registers:.*"
>  	    }
> +	    thrower {
> +		if { [istarget tic6x-*-*] } {
> +		    # On tic6x, there is no register saved in function thrower.
> +		    set pat "Stack frame at .* in $func .*"
> +		} else {
> +		    set pat "Stack frame at .* in $func .* Saved registers:.*"
> +		}

Why are you special-casing tic6x here?  Is the architecture really
that special that there are no saved registers?  I suspect it isn't
and that this can happen on other architectures as well, depending on
how much optimization the compiler is doing.


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-08-10 12:28           ` Mark Kettenis
@ 2011-08-10 14:05             ` Yao Qi
  2011-08-14 16:24               ` Yao Qi
  0 siblings, 1 reply; 9+ messages in thread
From: Yao Qi @ 2011-08-10 14:05 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 3119 bytes --]

On 08/10/2011 08:27 PM, Mark Kettenis wrote:
>> Date: Tue, 09 Aug 2011 23:25:06 +0800
>> From: Yao Qi <yao@codesourcery.com>
>>
>> On 08/09/2011 11:15 PM, Mark Kettenis wrote:
>>> Why depend on this NOMMU-magic?  Just install the signal handler for
>>> bth SIGSEGV and SIGILL, try a store to (or perhaps a read from)
>>> address 0, and then fall through to executing an illegal instruction.
>>
>> Because I want to reduce the scope of using invalid instruction.  We
>> only need to know the invalid instruction for HAS_NOMMU arch, and emit
>> error if we forget to define an invalid instruction for a new NOMMU
>> port.  Do it make sense?
> 
> I don't really think that's an issue.  If the test is run on an
> mmu-less machine for which no illegal instruction is defined, the test
> will fail.  That should prompt someone to look at the test and add the
> missing instruction.
> 

If you don't think that is an issue, I am OK with it.  Updated my patch
for it.

> I really just want to avoid the #ifdef maze you're creating which
> makes the code more complicated and the test less generic.  I think
> you're too much focussed on reducing the number of FAILs for your
> particular target to zero instead of improving the tests such that
> they become more generally useful.  For example:
> 

I don't know how did you get such impression, but I really want to
convert/refactor test cases as general as they can be.  gdb-patches@
archive can show my recent work is about this.

>> diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
>> index eeee0ff..4408137 100644
>> --- a/gdb/testsuite/gdb.base/savedregs.exp
>> +++ b/gdb/testsuite/gdb.base/savedregs.exp
>> @@ -84,6 +84,14 @@ proc process_saved_regs { current inner outer } {
>>  		# Sigtramp frames don't yet print <signal trampoline>.
>>  		set pat "Stack frame at .* Saved registers:.*"
>>  	    }
>> +	    thrower {
>> +		if { [istarget tic6x-*-*] } {
>> +		    # On tic6x, there is no register saved in function thrower.
>> +		    set pat "Stack frame at .* in $func .*"
>> +		} else {
>> +		    set pat "Stack frame at .* in $func .* Saved registers:.*"
>> +		}
> 
> Why are you special-casing tic6x here?  Is the architecture really
> that special that there are no saved registers?  I suspect it isn't
> and that this can happen on other architectures as well, depending on
> how much optimization the compiler is doing.

Leave tic6x alone at first, it is the test case's problem here to expect
"save registers in a frame", because it is possible there is no register
saved on a certain frame.  IMO, tic6x port exposes such problem, and my
fix in this patch is to make tests "more generally useful".  If we see
"no registers saved" on other ports, we can put these targets together
in this condition checking, like,

if { [istarget tic6x-*-*] || [istarget foo-*-*] || [istarget bar-*-*]} {
    # On tic6x/foo/bar, there is no register saved in function thrower.
    set pat "Stack frame at .* in $func .*"
} else {
    set pat "Stack frame at .* in $func .* Saved registers:.*"
}

Is it OK to you?

-- 
Yao (齐尧)

[-- Attachment #2: 0008-test-case.patch --]
[-- Type: text/x-patch, Size: 4361 bytes --]


        gdb/testsuite/
        * gdb.base/maint.exp: set data_section to ".neardata".
        * gdb.base/savedregs.c (thrower): Trigger SIGILL on NO-MMU machine.
        * gdb.base/savedregs.exp: Handle SIGILL.
        (process_saved_regs): Don't check saved register on tic6x-*-*
        * gdb.mi/mi-syn-frame.c (bar): Trigger SIGILL on NO-MMU machine.
	* gdb.xml/tdesc-regs.exp: Set core-regs for tic6x-*-*.
---
 gdb/testsuite/gdb.base/maint.exp     |    5 +++++
 gdb/testsuite/gdb.base/savedregs.c   |   14 ++++++++++++++
 gdb/testsuite/gdb.base/savedregs.exp |    9 +++++++++
 gdb/testsuite/gdb.mi/mi-syn-frame.c  |   13 +++++++++++--
 gdb/testsuite/gdb.xml/tdesc-regs.exp |    3 +++
 5 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 61ad439..2bd2593 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -394,6 +394,11 @@ gdb_test_multiple "maint info sections" "maint info sections" {
 	set data_section ER_RW
 	pass "maint info sections"
     }
+    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
+	# c6x doesn't have .data section.  It has .neardata and .fardata section.
+	set data_section ".neardata"
+	pass "maint info sections"
+    }
     -re "Exec file:\r\n.*break($EXEEXT)?., file type.*$gdb_prompt $" {
 	pass "maint info sections"
     }
diff --git a/gdb/testsuite/gdb.base/savedregs.c b/gdb/testsuite/gdb.base/savedregs.c
index 9f302a0..4f962ac 100644
--- a/gdb/testsuite/gdb.base/savedregs.c
+++ b/gdb/testsuite/gdb.base/savedregs.c
@@ -45,11 +45,25 @@ catcher (int sig)
 static void
 thrower (void)
 {
+  /* Trigger a SIGSEGV.  */
   *(char *)0 = 0;
+
+  /* On MMU-less system, previous memory access to address zero doesn't
+     trigger a SIGSEGV.  Trigger a SIGILL.  Each arch should define its
+     own illegal instruction here.  */
+
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  asm(".word 0x56454313");
+#else
+#endif
+
 }
 
 main ()
 {
+  signal (SIGILL, catcher);
   signal (SIGSEGV, catcher);
   thrower ();
 }
diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
index eeee0ff..4408137 100644
--- a/gdb/testsuite/gdb.base/savedregs.exp
+++ b/gdb/testsuite/gdb.base/savedregs.exp
@@ -84,6 +84,14 @@ proc process_saved_regs { current inner outer } {
 		# Sigtramp frames don't yet print <signal trampoline>.
 		set pat "Stack frame at .* Saved registers:.*"
 	    }
+	    thrower {
+		if { [istarget tic6x-*-*] } {
+		    # On tic6x, there is no register saved in function thrower.
+		    set pat "Stack frame at .* in $func .*"
+		} else {
+		    set pat "Stack frame at .* in $func .* Saved registers:.*"
+		}
+	    }
 	    default {
 		set pat "Stack frame at .* in $func .* Saved registers:.*"
 	    }
@@ -143,6 +151,7 @@ process_saved_regs thrower { main } { }
 # Continue to the signal catcher, check main's saved-reg info, capture
 # catcher's saved-reg info.
 gdb_test "handle SIGSEGV pass print nostop"
+gdb_test "handle SIGILL pass print nostop"
 gdb_test "advance catcher" "catcher .* at .*"
 process_saved_regs catcher { sigtramp thrower } { main }
 
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.c b/gdb/testsuite/gdb.mi/mi-syn-frame.c
index ddfc08e..332f246 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.c
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.c
@@ -25,9 +25,18 @@ foo (void)
 void 
 bar (void)
 {
-  char *nuller = 0;
+  *(char *)0 = 0;    /* try to cause a segfault */
+
+  /* On MMU-less system, previous memory access to address zero doesn't
+     trigger a SIGSEGV.  Trigger a SIGILL.  Each arch should define its
+     own illegal instruction here.  */
+#if defined(__arm__)
+  asm(".word 0xf8f00000");
+#elif defined(__TMS320C6X__)
+  asm(".word 0x56454313");
+#else
+#endif
 
-  *nuller = 'a';      /* try to cause a segfault */
 }
 
 void
diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp
index 224c082..6a12dba 100644
--- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
@@ -53,6 +53,9 @@ switch -glob -- [istarget] {
 	unsupported "register tests"
 	return 0
     }
+    "tic6x-*-*" {
+	set core-regs {tic6x-core.xml}
+    }
     "i?86-*-*" {
 	set architecture "i386"
 	set regdir "i386/"
-- 
1.7.0.4


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

* Re: [RFA 7/8] New port: TI C6x:  test case fixes
  2011-08-10 14:05             ` Yao Qi
@ 2011-08-14 16:24               ` Yao Qi
  0 siblings, 0 replies; 9+ messages in thread
From: Yao Qi @ 2011-08-14 16:24 UTC (permalink / raw)
  To: gdb-patches

On 08/10/2011 10:04 PM, Yao Qi wrote:
>>> >> diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
>>> >> index eeee0ff..4408137 100644
>>> >> --- a/gdb/testsuite/gdb.base/savedregs.exp
>>> >> +++ b/gdb/testsuite/gdb.base/savedregs.exp
>>> >> @@ -84,6 +84,14 @@ proc process_saved_regs { current inner outer } {
>>> >>  		# Sigtramp frames don't yet print <signal trampoline>.
>>> >>  		set pat "Stack frame at .* Saved registers:.*"
>>> >>  	    }
>>> >> +	    thrower {
>>> >> +		if { [istarget tic6x-*-*] } {
>>> >> +		    # On tic6x, there is no register saved in function thrower.
>>> >> +		    set pat "Stack frame at .* in $func .*"
>>> >> +		} else {
>>> >> +		    set pat "Stack frame at .* in $func .* Saved registers:.*"
>>> >> +		}
>> > 
>> > Why are you special-casing tic6x here?  Is the architecture really
>> > that special that there are no saved registers?  I suspect it isn't
>> > and that this can happen on other architectures as well, depending on
>> > how much optimization the compiler is doing.
> Leave tic6x alone at first, it is the test case's problem here to expect
> "save registers in a frame", because it is possible there is no register
> saved on a certain frame.  IMO, tic6x port exposes such problem, and my
> fix in this patch is to make tests "more generally useful".  If we see
> "no registers saved" on other ports, we can put these targets together
> in this condition checking, like,
> 
> if { [istarget tic6x-*-*] || [istarget foo-*-*] || [istarget bar-*-*]} {
>     # On tic6x/foo/bar, there is no register saved in function thrower.
>     set pat "Stack frame at .* in $func .*"
> } else {
>     set pat "Stack frame at .* in $func .* Saved registers:.*"
> }
> 

The patch of test cases fix is checked in, except for this chunk.

http://sourceware.org/ml/gdb-cvs/2011-08/msg00072.html

-- 
Yao (齐尧)


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

end of thread, other threads:[~2011-08-14 16:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-20  2:12 [RFA 7/8] New port: TI C6x: test case fixes Yao Qi
2011-07-25 11:37 ` Yao Qi
2011-08-09 14:22   ` Pedro Alves
2011-08-09 15:03     ` Yao Qi
2011-08-09 15:17       ` Mark Kettenis
2011-08-09 15:25         ` Yao Qi
2011-08-10 12:28           ` Mark Kettenis
2011-08-10 14:05             ` Yao Qi
2011-08-14 16:24               ` Yao Qi

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