* h8300-dis.c: Fix formatting.
[binutils-gdb.git] / gdb / parse.c
index c28d28397f7f114dc7ea98360b8129b5bdfaaec0..a39c21dcfcb531a4601a36c91cd11ea9d575e2e5 100644 (file)
 #include "parser-defs.h"
 #include "gdbcmd.h"
 #include "symfile.h"           /* for overlay functions */
+\f
+/* Symbols which architectures can redefine.  */
+
+/* Some systems have routines whose names start with `$'.  Giving this
+   macro a non-zero value tells GDB's expression parser to check for
+   such routines when parsing tokens that begin with `$'.
+
+   On HP-UX, certain system routines (millicode) have names beginning
+   with `$' or `$$'.  For example, `$$dyncall' is a millicode routine
+   that handles inter-space procedure calls on PA-RISC.  */
+#ifndef SYMBOLS_CAN_START_WITH_DOLLAR
+#define SYMBOLS_CAN_START_WITH_DOLLAR (0)
+#endif
+
+
 \f
 /* Global variables declared in parser-defs.h (and commented there).  */
 struct expression *expout;
@@ -62,16 +77,14 @@ static int expressiondebug = 0;
 
 extern int hp_som_som_object_present;
 
-static void
-free_funcalls PARAMS ((void));
+static void free_funcalls (void *ignore);
 
-static void
-prefixify_expression PARAMS ((struct expression *));
+static void prefixify_expression (struct expression *);
 
 static void
-prefixify_subexp PARAMS ((struct expression *, struct expression *, int, int));
+prefixify_subexp (struct expression *, struct expression *, int, int);
 
-void _initialize_parse PARAMS ((void));
+void _initialize_parse (void);
 
 /* Data structure for saving values of arglist_len for function calls whose
    arguments contain other function calls.  */
@@ -162,7 +175,7 @@ end_arglist ()
    Used when there is an error inside parsing.  */
 
 static void
-free_funcalls ()
+free_funcalls (void *ignore)
 {
   register struct funcall *call, *next;
 
@@ -460,9 +473,6 @@ write_dollar_variable (str)
   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
      and $$digits (equivalent to $<-digits> if you could type that). */
 
-  struct symbol *sym = NULL;
-  struct minimal_symbol *msym = NULL;
-
   int negate = 0;
   int i = 1;
   /* Double dollar means negate the number and add -1 as well.
@@ -496,27 +506,36 @@ write_dollar_variable (str)
   if (i >= 0)
     goto handle_register;
 
-  /* On HP-UX, certain system routines (millicode) have names beginning
-     with $ or $$, e.g. $$dyncall, which handles inter-space procedure
-     calls on PA-RISC. Check for those, first. */
-
-  sym = lookup_symbol (copy_name (str), (struct block *) NULL,
-                      VAR_NAMESPACE, (int *) NULL, (struct symtab **) NULL);
-  if (sym)
+  if (SYMBOLS_CAN_START_WITH_DOLLAR)
     {
-      write_exp_elt_opcode (OP_VAR_VALUE);
-      write_exp_elt_block (block_found);       /* set by lookup_symbol */
-      write_exp_elt_sym (sym);
-      write_exp_elt_opcode (OP_VAR_VALUE);
-      return;
-    }
-  msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
-  if (msym)
-    {
-      write_exp_msymbol (msym,
-                        lookup_function_type (builtin_type_int),
-                        builtin_type_int);
-      return;
+      struct symbol *sym = NULL;
+      struct minimal_symbol *msym = NULL;
+
+      /* On HP-UX, certain system routines (millicode) have names beginning
+        with $ or $$, e.g. $$dyncall, which handles inter-space procedure
+        calls on PA-RISC. Check for those, first. */
+
+      /* This code is not enabled on non HP-UX systems, since worst case 
+        symbol table lookup performance is awful, to put it mildly. */
+
+      sym = lookup_symbol (copy_name (str), (struct block *) NULL,
+                          VAR_NAMESPACE, (int *) NULL, (struct symtab **) NULL);
+      if (sym)
+       {
+         write_exp_elt_opcode (OP_VAR_VALUE);
+         write_exp_elt_block (block_found);    /* set by lookup_symbol */
+         write_exp_elt_sym (sym);
+         write_exp_elt_opcode (OP_VAR_VALUE);
+         return;
+       }
+      msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
+      if (msym)
+       {
+         write_exp_msymbol (msym,
+                            lookup_function_type (builtin_type_int),
+                            builtin_type_int);
+         return;
+       }
     }
 
   /* Any other names starting in $ are debugger internal variables.  */
@@ -602,8 +621,6 @@ parse_nested_classes_for_hpacc (name, len, token, class_prefix, argptr)
   struct symbol *sym_class = NULL;
   struct symbol *sym_var = NULL;
   struct type *t;
-  register int i;
-  int colons_found = 0;
   int prefix_len = 0;
   int done = 0;
   char *q;
@@ -1146,7 +1163,7 @@ parse_exp_1 (stringptr, block, comma)
   if (lexptr == 0 || *lexptr == 0)
     error_no_arg ("expression to compute");
 
-  old_chain = make_cleanup ((make_cleanup_func) free_funcalls, 0);
+  old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
   funcall_chain = 0;
 
   expression_context_block = block ? block : get_selected_block ();
@@ -1157,7 +1174,7 @@ parse_exp_1 (stringptr, block, comma)
   expout = (struct expression *)
     xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
   expout->language_defn = current_language;
-  make_cleanup ((make_cleanup_func) free_current_contents, &expout);
+  make_cleanup (free_current_contents, &expout);
 
   if (current_language->la_parser ())
     current_language->la_error (NULL);
@@ -1296,7 +1313,7 @@ follow_types (follow_type)
   return follow_type;
 }
 \f
-static void build_parse PARAMS ((void));
+static void build_parse (void);
 static void
 build_parse ()
 {
@@ -1381,10 +1398,10 @@ _initialize_parse ()
   register_gdbarch_swap (NULL, 0, build_parse);
 
   add_show_from_set (
-           add_set_cmd ("expressiondebug", class_maintenance, var_zinteger,
+           add_set_cmd ("expression", class_maintenance, var_zinteger,
                         (char *) &expressiondebug,
                         "Set expression debugging.\n\
 When non-zero, the internal representation of expressions will be printed.",
-                        &setlist),
-                     &showlist);
+                        &setdebuglist),
+                     &showdebuglist);
 }