* cris.h (R_CRIS_32_IE): New relocation.
[deliverable/binutils-gdb.git] / gdb / c-lang.c
index ebe781b3796297d7261149b65af8a3530022a10d..dc7b059c82861d42f10fefe68ba54b6fb47b1a87 100644 (file)
@@ -86,7 +86,8 @@ c_printchar (int c, struct ui_file *stream)
 
 void
 c_printstr (struct ui_file *stream, const gdb_byte *string,
-           unsigned int length, int width, int force_ellipses)
+           unsigned int length, int width, int force_ellipses,
+           const struct value_print_options *options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -108,7 +109,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
       return;
     }
 
-  for (i = 0; i < length && things_printed < print_max; ++i)
+  for (i = 0; i < length && things_printed < options->print_max; ++i)
     {
       /* Position of the character we are examining
          to see whether it is repeated.  */
@@ -137,11 +138,11 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
          ++reps;
        }
 
-      if (reps > repeat_count_threshold)
+      if (reps > options->repeat_count_threshold)
        {
          if (in_quotes)
            {
-             if (inspect_it)
+             if (options->inspect_it)
                fputs_filtered ("\\\", ", stream);
              else
                fputs_filtered ("\", ", stream);
@@ -150,14 +151,14 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
          LA_PRINT_CHAR (current_char, stream);
          fprintf_filtered (stream, _(" <repeats %u times>"), reps);
          i = rep1 - 1;
-         things_printed += repeat_count_threshold;
+         things_printed += options->repeat_count_threshold;
          need_comma = 1;
        }
       else
        {
          if (!in_quotes)
            {
-             if (inspect_it)
+             if (options->inspect_it)
                fputs_filtered ("\\\"", stream);
              else
                fputs_filtered ("\"", stream);
@@ -171,7 +172,7 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
   /* Terminate the quotes if necessary.  */
   if (in_quotes)
     {
-      if (inspect_it)
+      if (options->inspect_it)
        fputs_filtered ("\\\"", stream);
       else
        fputs_filtered ("\"", stream);
@@ -184,111 +185,6 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
 /* Preprocessing and parsing C and C++ expressions.  */
 
 
-/* When we find that lexptr (the global var defined in parse.c) is
-   pointing at a macro invocation, we expand the invocation, and call
-   scan_macro_expansion to save the old lexptr here and point lexptr
-   into the expanded text.  When we reach the end of that, we call
-   end_macro_expansion to pop back to the value we saved here.  The
-   macro expansion code promises to return only fully-expanded text,
-   so we don't need to "push" more than one level.
-
-   This is disgusting, of course.  It would be cleaner to do all macro
-   expansion beforehand, and then hand that to lexptr.  But we don't
-   really know where the expression ends.  Remember, in a command like
-
-     (gdb) break *ADDRESS if CONDITION
-
-   we evaluate ADDRESS in the scope of the current frame, but we
-   evaluate CONDITION in the scope of the breakpoint's location.  So
-   it's simply wrong to try to macro-expand the whole thing at once.  */
-static char *macro_original_text;
-static char *macro_expanded_text;
-
-
-void
-scan_macro_expansion (char *expansion)
-{
-  /* We'd better not be trying to push the stack twice.  */
-  gdb_assert (! macro_original_text);
-  gdb_assert (! macro_expanded_text);
-
-  /* Save the old lexptr value, so we can return to it when we're done
-     parsing the expanded text.  */
-  macro_original_text = lexptr;
-  lexptr = expansion;
-
-  /* Save the expanded text, so we can free it when we're finished.  */
-  macro_expanded_text = expansion;
-}
-
-
-int
-scanning_macro_expansion (void)
-{
-  return macro_original_text != 0;
-}
-
-
-void 
-finished_macro_expansion (void)
-{
-  /* There'd better be something to pop back to, and we better have
-     saved a pointer to the start of the expanded text.  */
-  gdb_assert (macro_original_text);
-  gdb_assert (macro_expanded_text);
-
-  /* Pop back to the original text.  */
-  lexptr = macro_original_text;
-  macro_original_text = 0;
-
-  /* Free the expanded text.  */
-  xfree (macro_expanded_text);
-  macro_expanded_text = 0;
-}
-
-
-static void
-scan_macro_cleanup (void *dummy)
-{
-  if (macro_original_text)
-    finished_macro_expansion ();
-}
-
-
-/* We set these global variables before calling c_parse, to tell it
-   how it to find macro definitions for the expression at hand.  */
-macro_lookup_ftype *expression_macro_lookup_func;
-void *expression_macro_lookup_baton;
-
-
-static int
-c_preprocess_and_parse (void)
-{
-  /* Set up a lookup function for the macro expander.  */
-  struct macro_scope *scope = 0;
-  struct cleanup *back_to = make_cleanup (free_current_contents, &scope);
-
-  if (expression_context_block)
-    scope = sal_macro_scope (find_pc_line (expression_context_pc, 0));
-  else
-    scope = default_macro_scope ();
-  if (! scope)
-    scope = user_macro_scope ();
-
-  expression_macro_lookup_func = standard_macro_lookup;
-  expression_macro_lookup_baton = (void *) scope;
-
-  gdb_assert (! macro_original_text);
-  make_cleanup (scan_macro_cleanup, 0);
-
-  {
-    int result = c_parse ();
-    do_cleanups (back_to);
-    return result;
-  }
-}
-
-
 \f
 /* Table mapping opcodes into strings for printing operators
    and precedences of the operators.  */
@@ -392,14 +288,16 @@ const struct language_defn c_language_defn =
   type_check_off,
   case_sensitive_on,
   array_row_major,
+  macro_expansion_c,
   &exp_descriptor_standard,
-  c_preprocess_and_parse,
+  c_parse,
   c_error,
   null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
   c_print_type,                        /* Print a type using appropriate syntax */
+  c_print_typedef,             /* Print a typedef 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 */
@@ -508,14 +406,16 @@ const struct language_defn cplus_language_defn =
   type_check_off,
   case_sensitive_on,
   array_row_major,
+  macro_expansion_c,
   &exp_descriptor_standard,
-  c_preprocess_and_parse,
+  c_parse,
   c_error,
   null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
   c_print_type,                        /* Print a type using appropriate syntax */
+  c_print_typedef,             /* Print a typedef using appropriate syntax */
   c_val_print,                 /* Print a value using appropriate syntax */
   c_value_print,               /* Print a top-level value */
   cplus_skip_trampoline,       /* Language specific skip_trampoline */
@@ -543,14 +443,16 @@ const struct language_defn asm_language_defn =
   type_check_off,
   case_sensitive_on,
   array_row_major,
+  macro_expansion_c,
   &exp_descriptor_standard,
-  c_preprocess_and_parse,
+  c_parse,
   c_error,
   null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
   c_print_type,                        /* Print a type using appropriate syntax */
+  c_print_typedef,             /* Print a typedef 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 */
@@ -583,14 +485,16 @@ const struct language_defn minimal_language_defn =
   type_check_off,
   case_sensitive_on,
   array_row_major,
+  macro_expansion_c,
   &exp_descriptor_standard,
-  c_preprocess_and_parse,
+  c_parse,
   c_error,
   null_post_parser,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_emit_char,                 /* Print a single char */
   c_print_type,                        /* Print a type using appropriate syntax */
+  c_print_typedef,             /* Print a typedef 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 */
This page took 0.026412 seconds and 4 git commands to generate.