* alpha-tdep.c (alpha_gdbarch_init): Use set_gdbarch_print_insn ...
[deliverable/binutils-gdb.git] / gdb / c-lang.c
index 9ee92ad8b8c81494793a227cd503f99b028b4652..bdbbb54172c59a602a04c18d2bdd2cbecb9139b8 100644 (file)
 #include "valprint.h"
 #include "macroscope.h"
 #include "gdb_assert.h"
+#include "charset.h"
+#include "gdb_string.h"
+#include "demangle.h"
+#include "cp-support.h"
 
 extern void _initialize_c_language (void);
 static void c_emit_char (int c, struct ui_file * stream, int quoter);
@@ -40,52 +44,30 @@ static void c_emit_char (int c, struct ui_file * stream, int quoter);
 static void
 c_emit_char (register int c, struct ui_file *stream, int quoter)
 {
+  const char *escape;
+  int host_char;
+
   c &= 0xFF;                   /* Avoid sign bit follies */
 
-  if (PRINT_LITERAL_FORM (c))
+  escape = c_target_char_has_backslash_escape (c);
+  if (escape)
     {
-      if (c == '\\' || c == quoter)
-       {
-         fputs_filtered ("\\", stream);
-       }
-      fprintf_filtered (stream, "%c", c);
+      if (quoter == '"' && strcmp (escape, "0") == 0)
+       /* Print nulls embedded in double quoted strings as \000 to
+          prevent ambiguity.  */
+       fprintf_filtered (stream, "\\000");
+      else
+       fprintf_filtered (stream, "\\%s", escape);
     }
-  else
+  else if (target_char_to_host (c, &host_char)
+           && host_char_print_literally (host_char))
     {
-      switch (c)
-       {
-       case '\n':
-         fputs_filtered ("\\n", stream);
-         break;
-       case '\b':
-         fputs_filtered ("\\b", stream);
-         break;
-       case '\t':
-         fputs_filtered ("\\t", stream);
-         break;
-       case '\f':
-         fputs_filtered ("\\f", stream);
-         break;
-       case '\r':
-         fputs_filtered ("\\r", stream);
-         break;
-        case '\013':
-          fputs_filtered ("\\v", stream);
-          break;
-       case '\033':
-         fputs_filtered ("\\e", stream);
-         break;
-       case '\007':
-         fputs_filtered ("\\a", stream);
-         break;
-        case '\0':
-          fputs_filtered ("\\0", stream);
-          break;
-       default:
-         fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
-         break;
-       }
+      if (host_char == '\\' || host_char == quoter)
+        fputs_filtered ("\\", stream);
+      fprintf_filtered (stream, "%c", host_char);
     }
+  else
+    fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
 }
 
 void
@@ -110,7 +92,6 @@ c_printstr (struct ui_file *stream, char *string, unsigned int length,
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
-  extern int inspect_it;
 
   /* If the string was not truncated due to `set print elements', and
      the last byte of it is a null, we don't print that, in traditional C
@@ -572,6 +553,10 @@ const struct language_defn c_language_defn =
   c_print_type,                        /* Print a type using appropriate syntax */
   c_val_print,                 /* Print a value using appropriate syntax */
   c_value_print,               /* Print a top-level value */
+  NULL,                                /* Language specific skip_trampoline */
+  NULL,                                /* value_of_this */
+  basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
+  NULL,                                /* Language specific symbol demangler */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -624,6 +609,10 @@ const struct language_defn cplus_language_defn =
   c_print_type,                        /* Print a type using appropriate syntax */
   c_val_print,                 /* Print a value using appropriate syntax */
   c_value_print,               /* Print a top-level value */
+  NULL,                                /* Language specific skip_trampoline */
+  value_of_this,               /* value_of_this */
+  cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
+  cplus_demangle,              /* Language specific symbol demangler */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -653,6 +642,48 @@ const struct language_defn asm_language_defn =
   c_print_type,                        /* Print a type using appropriate syntax */
   c_val_print,                 /* Print a value using appropriate syntax */
   c_value_print,               /* Print a top-level value */
+  NULL,                                /* Language specific skip_trampoline */
+  NULL,                                /* value_of_this */
+  basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
+  NULL,                                /* Language specific symbol demangler */
+  {"", "", "", ""},            /* Binary format info */
+  {"0%lo", "0", "o", ""},      /* Octal format info */
+  {"%ld", "", "d", ""},                /* Decimal format info */
+  {"0x%lx", "0x", "x", ""},    /* Hex format info */
+  c_op_print_tab,              /* expression operators for printing */
+  1,                           /* c-style arrays */
+  0,                           /* String lower bound */
+  &builtin_type_char,          /* Type of string elements */
+  LANG_MAGIC
+};
+
+/* The following language_defn does not represent a real language.
+   It just provides a minimal support a-la-C that should allow users
+   to do some simple operations when debugging applications that use
+   a language currently not supported by GDB.  */
+
+const struct language_defn minimal_language_defn =
+{
+  "minimal",                   /* Language name */
+  language_minimal,
+  c_builtin_types,
+  range_check_off,
+  type_check_off,
+  case_sensitive_on,
+  c_preprocess_and_parse,
+  c_error,
+  evaluate_subexp_standard,
+  c_printchar,                 /* Print a character constant */
+  c_printstr,                  /* Function to print string constant */
+  c_emit_char,                 /* Print a single char */
+  c_create_fundamental_type,   /* Create fundamental type in this language */
+  c_print_type,                        /* Print a type using appropriate syntax */
+  c_val_print,                 /* Print a value using appropriate syntax */
+  c_value_print,               /* Print a top-level value */
+  NULL,                                /* Language specific skip_trampoline */
+  NULL,                                /* value_of_this */
+  basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
+  NULL,                                /* Language specific symbol demangler */
   {"", "", "", ""},            /* Binary format info */
   {"0%lo", "0", "o", ""},      /* Octal format info */
   {"%ld", "", "d", ""},                /* Decimal format info */
@@ -670,4 +701,5 @@ _initialize_c_language (void)
   add_language (&c_language_defn);
   add_language (&cplus_language_defn);
   add_language (&asm_language_defn);
+  add_language (&minimal_language_defn);
 }
This page took 0.025513 seconds and 4 git commands to generate.