Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio
@ 2015-12-01 13:43 Yao Qi
  2015-12-03 13:10 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Yao Qi @ 2015-12-01 13:43 UTC (permalink / raw)
  To: gdb-patches

In my remote cross testing (x86_64 host and aarch64 target), the test
gdb.base/sizeof.exp is skipped because gdb,noinferiorio is defined in
my gdbserver board file.  Tests are skipped because the test checks
the expected value from the program's output, but I don't see why must
do it this way.  With my patch applied, we can save the result in variable
in the program, and check the variable then.  Then, the test doesn't rely
on inferiorio.  However, in check_valueof, the value is still checked by
printing from the program, because I don't know why do we test in this
way, so I leave them there.  With boards having gdb,noinferiorio, these
check_valueof tests are unsupported.  The rest of tests can be run
unconditionally.

gdb/testsuite:

2015-12-01  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/sizeof.c (main): New variable 'size'.  Remove printf.
	Assign return value to size.
	* gdb.base/sizeof.exp: Remove the checking to gdb,noinferiorio
	at the beginning.
	(check_sizeof): Check the result by printing variable 'size'.
	(check_valueof): Do the test if gdb,noinferiorio doesn't exist,
	otherwise mark the test unsupported.
---
 gdb/testsuite/gdb.base/sizeof.c   | 24 ++++++++++++------------
 gdb/testsuite/gdb.base/sizeof.exp | 28 +++++++++++-----------------
 2 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/gdb/testsuite/gdb.base/sizeof.c b/gdb/testsuite/gdb.base/sizeof.c
index eb21f22..86deff5 100644
--- a/gdb/testsuite/gdb.base/sizeof.c
+++ b/gdb/testsuite/gdb.base/sizeof.c
@@ -100,22 +100,22 @@ fill_structs (void)
 int
 main ()
 {
+  int size;
+
   gdb_unbuffer_output ();
 
   fill_structs ();
 
-  printf ("sizeof (char) == %d\n", (int) sizeof (char));
-  printf ("sizeof (short) == %d\n", (int) sizeof (short));
-  printf ("sizeof (int) == %d\n", (int) sizeof (int));
-  printf ("sizeof (long) == %d\n", (int) sizeof (long));
-  printf ("sizeof (long long) == %d\n", (int) sizeof (long long));
-
-  printf ("sizeof (void *) == %d\n", (int) sizeof (void*));
-  printf ("sizeof (void (*)(void)) == %d\n", (int) sizeof (void (*)(void)));
-
-  printf ("sizeof (float) == %d\n", (int) sizeof (float));
-  printf ("sizeof (double) == %d\n", (int) sizeof (double));
-  printf ("sizeof (long double) == %d\n", (int) sizeof (long double));
+  size = (int) sizeof (char);
+  size = (int) sizeof (short);
+  size = (int) sizeof (int);
+  size = (int) sizeof (long);
+  size = (int) sizeof (long long);
+  size = (int) sizeof (void*);
+  size = (int) sizeof (void (*)(void));
+  size = (int) sizeof (float);
+  size = (int) sizeof (double);
+  size = (int) sizeof (long double);
 
   /* Signed char?  */
   printf ("valueof ('\\377') == %d\n", '\377');
diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index ce6b7ed..776fc9b 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -15,11 +15,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if [target_info exists gdb,noinferiorio] {
-    verbose "Skipping sizeof.exp because of no fileio capabilities."
-    continue
-}
-
 #
 # test running programs
 #
@@ -68,12 +63,8 @@ set sizeof_long_double [get_sizeof "long double" 8]
 #
 
 proc check_sizeof { type size } {
-    global gdb_prompt
-
-    set pat [string_to_regexp "sizeof (${type}) == ${size}\r\n"]
-    gdb_test_stdio "next" "${pat}" \
-	"\[0-9\].*" \
-	"check sizeof \"$type\""
+    gdb_test "next" "" ""
+    gdb_test "p size" " = ${size}" "check sizeof \"$type\""
 }
 
 check_sizeof "char" ${sizeof_char}
@@ -90,12 +81,15 @@ check_sizeof "double" ${sizeof_double}
 check_sizeof "long double" ${sizeof_long_double}
 
 proc check_valueof { exp val } {
-    global gdb_prompt
-
-    set pat [string_to_regexp "valueof (${exp}) == ${val}\r\n"]
-    gdb_test_stdio "next" "${pat}" \
-	"\[0-9\].*" \
-	"check valueof \"$exp\""
+    if [target_info exists gdb,noinferiorio] {
+	gdb_test "next" "" ""
+	unsupported "check valueof \"$exp\""
+    } else {
+	set pat [string_to_regexp "valueof (${exp}) == ${val}\r\n"]
+	gdb_test_stdio "next" "${pat}" \
+	    "\[0-9\].*" \
+	    "check valueof \"$exp\""
+    }
 }
 
 # Check that GDB and the target agree over the sign of a character.
-- 
1.9.1


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

* Re: [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio
  2015-12-01 13:43 [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio Yao Qi
@ 2015-12-03 13:10 ` Pedro Alves
  2015-12-03 15:49   ` Yao Qi
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2015-12-03 13:10 UTC (permalink / raw)
  To: Yao Qi, gdb-patches

On 12/01/2015 01:43 PM, Yao Qi wrote:
> In my remote cross testing (x86_64 host and aarch64 target), the test
> gdb.base/sizeof.exp is skipped because gdb,noinferiorio is defined in
> my gdbserver board file.  Tests are skipped because the test checks
> the expected value from the program's output, but I don't see why must
> do it this way.  With my patch applied, we can save the result in variable
> in the program, and check the variable then.  Then, the test doesn't rely
> on inferiorio.  However, in check_valueof, the value is still checked by
> printing from the program, because I don't know why do we test in this
> way, so I leave them there.

We're checking whether gdb [1] and the compiler agree on the signness of "char":

These casts are evaluated by gdb:

  set signof_char [get_integer_valueof "(int) (char) -1" -1]

While these are evaluated by the compiler:

  printf ("valueof ((int) (char) -1) == %d\n", (int) (char) -1);

If char is unsigned, that prints 0xff; if char is signed, it prints -1.

I think we can replace that like you did for sizeof.

  value = (int) (char) -1;

etc., and then check "p value = ${val}", just like you did for
the sizeof checks.

[1] - This is gdbarch_char_signed.

Thanks,
Pedro Alves


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

* Re: [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio
  2015-12-03 13:10 ` Pedro Alves
@ 2015-12-03 15:49   ` Yao Qi
  2015-12-03 15:50     ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Yao Qi @ 2015-12-03 15:49 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Yao Qi, gdb-patches

Pedro Alves <palves@redhat.com> writes:

> I think we can replace that like you did for sizeof.
>
>   value = (int) (char) -1;
>
> etc., and then check "p value = ${val}", just like you did for
> the sizeof checks.

OK, how about this?

-- 
Yao (齐尧)

From bc000d9874eb1275c837e50043bc31d3ebe6fed4 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Fri, 20 Nov 2015 12:29:12 +0000
Subject: [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio

In my remote cross testing (x86_64 host and aarch64 target), the test
gdb.base/sizeof.exp is skipped because gdb,noinferiorio is defined in
my gdbserver board file.  Tests are skipped because the test checks
the expected value from the program's output, but I don't see why must
do it this way.  With my patch applied, we can save the result in variable
in the program, and check the variable then.  Then, the test doesn't rely
on inferiorio.

gdb/testsuite:

2015-12-03  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/sizeof.c: Don't include stdio.h and
	../lib/unbuffer_output.c.
	(main): New variable 'size' and 'value'.  Remove printf and
	gdb_unbuffer_output.  Assign return value to size and value.
	* gdb.base/sizeof.exp: Remove the checking to gdb,noinferiorio
	at the beginning.
	(check_sizeof): Check the result by printing variable 'size'.
	(check_valueof): Check the result by printing variable 'value'.

diff --git a/gdb/testsuite/gdb.base/sizeof.c b/gdb/testsuite/gdb.base/sizeof.c
index eb21f22..fde5213 100644
--- a/gdb/testsuite/gdb.base/sizeof.c
+++ b/gdb/testsuite/gdb.base/sizeof.c
@@ -1,7 +1,3 @@
-#include <stdio.h>
-
-#include "../lib/unbuffer_output.c"
-
 typedef char padding[16];
 
 struct {
@@ -100,28 +96,26 @@ fill_structs (void)
 int
 main ()
 {
-  gdb_unbuffer_output ();
+  int size, value;
 
   fill_structs ();
 
-  printf ("sizeof (char) == %d\n", (int) sizeof (char));
-  printf ("sizeof (short) == %d\n", (int) sizeof (short));
-  printf ("sizeof (int) == %d\n", (int) sizeof (int));
-  printf ("sizeof (long) == %d\n", (int) sizeof (long));
-  printf ("sizeof (long long) == %d\n", (int) sizeof (long long));
-
-  printf ("sizeof (void *) == %d\n", (int) sizeof (void*));
-  printf ("sizeof (void (*)(void)) == %d\n", (int) sizeof (void (*)(void)));
-
-  printf ("sizeof (float) == %d\n", (int) sizeof (float));
-  printf ("sizeof (double) == %d\n", (int) sizeof (double));
-  printf ("sizeof (long double) == %d\n", (int) sizeof (long double));
+  size = (int) sizeof (char);
+  size = (int) sizeof (short);
+  size = (int) sizeof (int);
+  size = (int) sizeof (long);
+  size = (int) sizeof (long long);
+  size = (int) sizeof (void*);
+  size = (int) sizeof (void (*)(void));
+  size = (int) sizeof (float);
+  size = (int) sizeof (double);
+  size = (int) sizeof (long double);
 
   /* Signed char?  */
-  printf ("valueof ('\\377') == %d\n", '\377');
-  printf ("valueof ((int) (char) -1) == %d\n", (int) (char) -1);
-  printf ("valueof ((int) (signed char) -1) == %d\n", (int) (signed char) -1);
-  printf ("valueof ((int) (unsigned char) -1) == %d\n", (int) (unsigned char) -1);
+  value = '\377';
+  value = (int) (char) -1;
+  value = (int) (signed char) -1;
+  value = (int) (unsigned char) -1;
 
   return 0;
 }
diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index ce6b7ed..550f80d 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -15,11 +15,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if [target_info exists gdb,noinferiorio] {
-    verbose "Skipping sizeof.exp because of no fileio capabilities."
-    continue
-}
-
 #
 # test running programs
 #
@@ -48,7 +43,7 @@ if ![runto_main] then {
 # Query GDB for the size of various types
 #
 
-gdb_test "next 2"
+gdb_test "next"
 
 set sizeof_char [get_sizeof "char" 1]
 set sizeof_short [get_sizeof "short" 2]
@@ -68,12 +63,8 @@ set sizeof_long_double [get_sizeof "long double" 8]
 #
 
 proc check_sizeof { type size } {
-    global gdb_prompt
-
-    set pat [string_to_regexp "sizeof (${type}) == ${size}\r\n"]
-    gdb_test_stdio "next" "${pat}" \
-	"\[0-9\].*" \
-	"check sizeof \"$type\""
+    gdb_test "next" "" ""
+    gdb_test "p size" " = ${size}" "check sizeof \"$type\""
 }
 
 check_sizeof "char" ${sizeof_char}
@@ -90,12 +81,8 @@ check_sizeof "double" ${sizeof_double}
 check_sizeof "long double" ${sizeof_long_double}
 
 proc check_valueof { exp val } {
-    global gdb_prompt
-
-    set pat [string_to_regexp "valueof (${exp}) == ${val}\r\n"]
-    gdb_test_stdio "next" "${pat}" \
-	"\[0-9\].*" \
-	"check valueof \"$exp\""
+    gdb_test "next" "" ""
+    gdb_test "p value" " = ${val}" "check valueof \"$exp\""
 }
 
 # Check that GDB and the target agree over the sign of a character.


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

* Re: [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio
  2015-12-03 15:49   ` Yao Qi
@ 2015-12-03 15:50     ` Pedro Alves
  2015-12-03 17:13       ` Yao Qi
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2015-12-03 15:50 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 12/03/2015 03:49 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
> 
>> I think we can replace that like you did for sizeof.
>>
>>   value = (int) (char) -1;
>>
>> etc., and then check "p value = ${val}", just like you did for
>> the sizeof checks.
> 
> OK, how about this?
> 

LGTM.

Thanks,
Pedro Alves


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

* Re: [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio
  2015-12-03 15:50     ` Pedro Alves
@ 2015-12-03 17:13       ` Yao Qi
  0 siblings, 0 replies; 5+ messages in thread
From: Yao Qi @ 2015-12-03 17:13 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Yao Qi, gdb-patches

Pedro Alves <palves@redhat.com> writes:

>> OK, how about this?
>> 
>
> LGTM.

Patch is pushed in.

-- 
Yao (齐尧)


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

end of thread, other threads:[~2015-12-03 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 13:43 [PATCH] Run gdb.base/sizeof.exp with board having gdb,noinferiorio Yao Qi
2015-12-03 13:10 ` Pedro Alves
2015-12-03 15:49   ` Yao Qi
2015-12-03 15:50     ` Pedro Alves
2015-12-03 17:13       ` Yao Qi

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