Add support for --start option in -exec-run GDB/MI command.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / charset.c
index af52de99988cd51240390ae95e437bde5e668ad3..57eaff6e028b3d284ad334ea79e337d80c2d426b 100644 (file)
@@ -1,6 +1,6 @@
 /* This testcase is part of GDB, the GNU debugger.
 
-   Copyright 2001, 2004, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 2001-2013 Free Software Foundation, Inc.
 
    Contributed by Red Hat, originally written by Jim Blandy.
 
    Please email any bugs, comments, and/or additions to this file to:
    bug-gdb@gnu.org  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
 /* X_string is a null-terminated string in the X charset whose
    elements are as follows.  X should be the name the `set charset'
    command uses for the character set, in lower-case, with any
@@ -54,6 +49,33 @@ char iso_8859_1_string[NUM_CHARS];
 char ebcdic_us_string[NUM_CHARS];
 char ibm1047_string[NUM_CHARS];
 
+/* We make a phony wchar_t and then pretend that this platform uses
+   UTF-32 (or UTF-16, depending on the size -- same difference for the
+   purposes of this test).  */
+typedef unsigned int wchar_t;
+wchar_t utf_32_string[NUM_CHARS];
+
+/* We also define a couple phony types for testing the u'' and U''
+   support.  It is ok if these have the wrong size on some platforms
+   -- the test case will skip the tests in that case.  */
+typedef unsigned short char16_t;
+typedef unsigned int char32_t;
+
+/* Make sure to use the typedefs.  */
+char16_t uvar;
+char32_t Uvar;
+
+char16_t *String16;
+char32_t *String32;
+
+/* A typedef to a typedef should also work.  */
+typedef wchar_t my_wchar_t;
+my_wchar_t myvar;
+
+/* Some arrays for simple assignment tests.  */
+short short_array[3];
+int int_array[3];
+long long_array[3];
 
 void
 init_string (char string[],
@@ -62,7 +84,10 @@ init_string (char string[],
              char line_feed, char carriage_return, char horizontal_tab,
              char vertical_tab, char cent, char misc_ctrl)
 {
-  memset (string, x, NUM_CHARS);
+  int i;
+
+  for (i = 0; i < NUM_CHARS; ++i)
+    string[i] = x;
   string[0] = alert;
   string[1] = backspace;
   string[2] = form_feed;
@@ -85,13 +110,22 @@ fill_run (char string[], int start, int len, int first)
 }
 
 
+void
+init_utf32 ()
+{
+  int i;
+
+  for (i = 0; i < NUM_CHARS; ++i)
+    utf_32_string[i] = iso_8859_1_string[i] & 0xff;
+}
+
+extern void malloc_stub (void);
+
 int main ()
 {
-#ifdef usestubs
-  set_debug_traps();
-  breakpoint();
-#endif
-  (void) malloc (1);
+
+  malloc_stub ();
+
   /* Initialize ascii_string.  */
   init_string (ascii_string,
                120,
@@ -146,5 +180,9 @@ int main ()
   /* The digits, at least, are contiguous.  */
   fill_run (ibm1047_string, 59, 10, 240);
 
-  puts ("All set!");            /* all strings initialized */
+  init_utf32 ();
+
+  myvar = utf_32_string[7];
+
+  return 0;            /* all strings initialized */
 }
This page took 0.028769 seconds and 4 git commands to generate.