+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'.
+
2015-12-01 Yao Qi <yao.qi@linaro.org>
* gdb.base/disp-step-syscall.exp: Define syscall instruction
-#include <stdio.h>
-
-#include "../lib/unbuffer_output.c"
-
typedef char padding[16];
struct {
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;
}
# 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
#
# 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]
#
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}
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.