2007-10-25 Wu Zhou <woodzltc@cn.ibm.com>
[deliverable/binutils-gdb.git] / gdb / parse.c
index 3284af3cdfb677f84cd3b24ccfa9cb645a612d6c..8841e598a0e3b20474737b791f4e2224aef82005 100644 (file)
@@ -10,7 +10,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -19,9 +19,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Parse an expression from text in a string,
    and return the result as a  struct expression  pointer.
@@ -249,6 +247,18 @@ write_exp_elt_dblcst (DOUBLEST expelt)
   write_exp_elt (tmp);
 }
 
+void
+write_exp_elt_decfloatcst (gdb_byte expelt[16])
+{
+  union exp_element tmp;
+  int index;
+
+  for (index = 0; index < 16; index++)
+    tmp.decfloatconst[index] = expelt[index];
+
+  write_exp_elt (tmp);
+}
+
 void
 write_exp_elt_type (struct type *expelt)
 {
@@ -384,16 +394,12 @@ write_exp_bitstring (struct stoken str)
    based on the language, but they no longer have names like "int", so
    the initial rationale is gone.  */
 
-static struct type *msym_text_symbol_type;
-static struct type *msym_data_symbol_type;
-static struct type *msym_unknown_symbol_type;
-static struct type *msym_tls_symbol_type;
-
 void
 write_exp_msymbol (struct minimal_symbol *msymbol, 
                   struct type *text_symbol_type, 
                   struct type *data_symbol_type)
 {
+  struct gdbarch *gdbarch = current_gdbarch;
   CORE_ADDR addr;
 
   write_exp_elt_opcode (OP_LONG);
@@ -419,7 +425,7 @@ write_exp_msymbol (struct minimal_symbol *msymbol,
 
       write_exp_elt_opcode (UNOP_MEMVAL_TLS);
       write_exp_elt_objfile (ofp);
-      write_exp_elt_type (msym_tls_symbol_type);
+      write_exp_elt_type (builtin_type (gdbarch)->nodebug_tls_symbol);
       write_exp_elt_opcode (UNOP_MEMVAL_TLS);
       return;
     }
@@ -430,18 +436,18 @@ write_exp_msymbol (struct minimal_symbol *msymbol,
     case mst_text:
     case mst_file_text:
     case mst_solib_trampoline:
-      write_exp_elt_type (msym_text_symbol_type);
+      write_exp_elt_type (builtin_type (gdbarch)->nodebug_text_symbol);
       break;
 
     case mst_data:
     case mst_file_data:
     case mst_bss:
     case mst_file_bss:
-      write_exp_elt_type (msym_data_symbol_type);
+      write_exp_elt_type (builtin_type (gdbarch)->nodebug_data_symbol);
       break;
 
     default:
-      write_exp_elt_type (msym_unknown_symbol_type);
+      write_exp_elt_type (builtin_type (gdbarch)->nodebug_unknown_symbol);
       break;
     }
   write_exp_elt_opcode (UNOP_MEMVAL);
@@ -475,6 +481,7 @@ write_dollar_variable (struct stoken str)
 {
   struct symbol *sym = NULL;
   struct minimal_symbol *msym = NULL;
+  struct internalvar *isym = NULL;
 
   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
      and $$digits (equivalent to $<-digits> if you could type that). */
@@ -513,6 +520,17 @@ write_dollar_variable (struct stoken str)
   if (i >= 0)
     goto handle_register;
 
+  /* Any names starting with $ are probably debugger internal variables.  */
+
+  isym = lookup_only_internalvar (copy_name (str) + 1);
+  if (isym)
+    {
+      write_exp_elt_opcode (OP_INTERNALVAR);
+      write_exp_elt_intern (isym);
+      write_exp_elt_opcode (OP_INTERNALVAR);
+      return;
+    }
+
   /* On some systems, such as HP-UX and hppa-linux, certain system routines 
      have names beginning with $ or $$.  Check for those, first. */
 
@@ -535,10 +553,10 @@ write_dollar_variable (struct stoken str)
       return;
     }
 
-  /* Any other names starting in $ are debugger internal variables.  */
+  /* Any other names are assumed to be debugger internal variables.  */
 
   write_exp_elt_opcode (OP_INTERNALVAR);
-  write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1));
+  write_exp_elt_intern (create_internalvar (copy_name (str) + 1));
   write_exp_elt_opcode (OP_INTERNALVAR);
   return;
 handle_last:
@@ -548,7 +566,9 @@ handle_last:
   return;
 handle_register:
   write_exp_elt_opcode (OP_REGISTER);
-  write_exp_elt_longcst (i);
+  str.length--;
+  str.ptr++;
+  write_exp_string (str);
   write_exp_elt_opcode (OP_REGISTER);
   return;
 }
@@ -710,6 +730,7 @@ operator_length_standard (struct expression *expr, int endpos,
 
     case OP_LONG:
     case OP_DOUBLE:
+    case OP_DECFLOAT:
     case OP_VAR_VALUE:
       oplen = 4;
       break;
@@ -717,7 +738,6 @@ operator_length_standard (struct expression *expr, int endpos,
     case OP_TYPE:
     case OP_BOOL:
     case OP_LAST:
-    case OP_REGISTER:
     case OP_INTERNALVAR:
       oplen = 3;
       break;
@@ -772,6 +792,7 @@ operator_length_standard (struct expression *expr, int endpos,
     case STRUCTOP_PTR:
       args = 1;
       /* fall through */
+    case OP_REGISTER:
     case OP_M2_STRING:
     case OP_STRING:
     case OP_OBJC_NSSTRING:     /* Objective C Foundation Class NSString constant */
@@ -1175,30 +1196,6 @@ follow_types (struct type *follow_type)
   return follow_type;
 }
 \f
-static void build_parse (void);
-static void
-build_parse (void)
-{
-  int i;
-
-  msym_text_symbol_type =
-    init_type (TYPE_CODE_FUNC, 1, 0, "<text variable, no debug info>", NULL);
-  TYPE_TARGET_TYPE (msym_text_symbol_type) = builtin_type_int;
-  msym_data_symbol_type =
-    init_type (TYPE_CODE_INT, 
-              gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT, 0,
-              "<data variable, no debug info>", NULL);
-  msym_unknown_symbol_type =
-    init_type (TYPE_CODE_INT, 1, 0,
-              "<variable (not text or data), no debug info>",
-              NULL);
-
-  msym_tls_symbol_type =
-    init_type (TYPE_CODE_INT, 
-              gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT, 0,
-              "<thread local variable, no debug info>", NULL);
-}
-
 /* This function avoids direct calls to fprintf 
    in the parser generated debug code.  */
 void
@@ -1224,16 +1221,6 @@ _initialize_parse (void)
   type_stack = (union type_stack_elt *)
     xmalloc (type_stack_size * sizeof (*type_stack));
 
-  build_parse ();
-
-  /* FIXME - For the moment, handle types by swapping them in and out.
-     Should be using the per-architecture data-pointer and a large
-     struct. */
-  DEPRECATED_REGISTER_GDBARCH_SWAP (msym_text_symbol_type);
-  DEPRECATED_REGISTER_GDBARCH_SWAP (msym_data_symbol_type);
-  DEPRECATED_REGISTER_GDBARCH_SWAP (msym_unknown_symbol_type);
-  deprecated_register_gdbarch_swap (NULL, 0, build_parse);
-
   add_setshow_zinteger_cmd ("expression", class_maintenance,
                            &expressiondebug, _("\
 Set expression debugging."), _("\
This page took 0.027753 seconds and 4 git commands to generate.