[commit/testsuite] Use of int8_t, etc in tests

Daniel Jacobowitz drow@false.org
Fri Nov 13 22:22:00 GMT 2009


Here's a weird one.  As the comment says:

+/* According to C99 <stdint.h> has to provide these identifiers as
+   types, but is also free to define macros shadowing the typedefs.
+   This is the case with some C library implementations.  Undefine
+   them to make sure the types are used and included in debug output.  */

We have such a target in our collection (the MIPS SDE library).
It does essentially this:

typedef __int32_t int32_t
#define int32_t __int32_t

I don't know why that particular choice.  This leads to find.c having
debug info that says variables are of type __int32_t instead of
int32_t.  Nothing uses the int32_t typedef.  So when the test tries an
explicit cast to int32_t, GDB reports that the type is unknown.

I've checked in this patch from Maciej, which we've been using for a
while.  This guarantees that the variables have the expected type.  We
haven't run into a system with a non-compliant stdint.h that defines
int32_t but does not provide the typedef.  If we someday do, we'll
have to teach the test to use ptype instead and cast to whatever type
GDB reports...

Tested on arm-none-eabi and x86_64-linux, checked in.

2009-11-13  Maciej W. Rozycki  <macro@codesourcery.com>

	* gdb.base/find.c (int8_t, int16_t, int32_t, int64_t): Undefine
	macros.

Index: gdb/testsuite/gdb.base/find.c
===================================================================
--- gdb/testsuite/gdb.base/find.c	(revision 225411)
+++ gdb/testsuite/gdb.base/find.c	(revision 225412)
@@ -22,6 +22,15 @@
 #include <stdlib.h>
 #include <stdint.h>
 
+/* According to C99 <stdint.h> has to provide these identifiers as
+   types, but is also free to define macros shadowing the typedefs.
+   This is the case with some C library implementations.  Undefine
+   them to make sure the types are used and included in debug output.  */
+#undef int8_t
+#undef int16_t
+#undef int32_t
+#undef int64_t
+
 #define CHUNK_SIZE 16000 /* same as findcmd.c's */
 #define BUF_SIZE (2 * CHUNK_SIZE) /* at least two chunks */
 

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb-patches mailing list