2001-09-20 Michael Snyder <msnyder@redhat.com>
[binutils-gdb.git] / gdb / parse.c
index 166446a4016547312c6a2bbb131da3bdbaef38da..64966edf2b5aa543f5a9decda9619a8196cb6a44 100644 (file)
@@ -1,5 +1,6 @@
 /* Parse expressions for GDB.
 /* Parse expressions for GDB.
-   Copyright (C) 1986, 89, 90, 91, 94, 98, 1999 Free Software Foundation, Inc.
+   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+   1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    Modified from expread.y by the Department of Computer Science at the
    State University of New York at Buffalo, 1991.
 
    Modified from expread.y by the Department of Computer Science at the
    State University of New York at Buffalo, 1991.
 
@@ -45,6 +46,7 @@
 #include "symfile.h"           /* for overlay functions */
 #include "inferior.h"          /* for NUM_PSEUDO_REGS.  NOTE: replace 
                                   with "gdbarch.h" when appropriate.  */
 #include "symfile.h"           /* for overlay functions */
 #include "inferior.h"          /* for NUM_PSEUDO_REGS.  NOTE: replace 
                                   with "gdbarch.h" when appropriate.  */
+#include "doublest.h"
 
 \f
 /* Symbols which architectures can redefine.  */
 
 \f
 /* Symbols which architectures can redefine.  */
@@ -176,7 +178,7 @@ end_arglist (void)
   register struct funcall *call = funcall_chain;
   funcall_chain = call->next;
   arglist_len = call->arglist_len;
   register struct funcall *call = funcall_chain;
   funcall_chain = call->next;
   arglist_len = call->arglist_len;
-  free ((PTR) call);
+  xfree (call);
   return val;
 }
 
   return val;
 }
 
@@ -191,7 +193,7 @@ free_funcalls (void *ignore)
   for (call = funcall_chain; call; call = next)
     {
       next = call->next;
   for (call = funcall_chain; call; call = next)
     {
       next = call->next;
-      free ((PTR) call);
+      xfree (call);
     }
 }
 \f
     }
 }
 \f
@@ -402,13 +404,15 @@ static struct type *msym_data_symbol_type;
 static struct type *msym_unknown_symbol_type;
 
 void
 static struct type *msym_unknown_symbol_type;
 
 void
-write_exp_msymbol (struct minimal_symbol *msymbol,
-                  struct type *text_symbol_type, struct type *data_symbol_type)
+write_exp_msymbol (struct minimal_symbol *msymbol, 
+                  struct type *text_symbol_type, 
+                  struct type *data_symbol_type)
 {
   CORE_ADDR addr;
 
   write_exp_elt_opcode (OP_LONG);
 {
   CORE_ADDR addr;
 
   write_exp_elt_opcode (OP_LONG);
-  write_exp_elt_type (lookup_pointer_type (builtin_type_void));
+  /* Let's make the type big enough to hold a 64-bit address.  */
+  write_exp_elt_type (builtin_type_CORE_ADDR);
 
   addr = SYMBOL_VALUE_ADDRESS (msymbol);
   if (overlay_debugging)
 
   addr = SYMBOL_VALUE_ADDRESS (msymbol);
   if (overlay_debugging)
@@ -1251,6 +1255,8 @@ struct type *
 follow_types (struct type *follow_type)
 {
   int done = 0;
 follow_types (struct type *follow_type)
 {
   int done = 0;
+  int make_const = 0;
+  int make_volatile = 0;
   int array_size;
   struct type *range_type;
 
   int array_size;
   struct type *range_type;
 
@@ -1259,12 +1265,40 @@ follow_types (struct type *follow_type)
       {
       case tp_end:
        done = 1;
       {
       case tp_end:
        done = 1;
+       if (make_const)
+         follow_type = make_cv_type (make_const, 
+                                     TYPE_VOLATILE (follow_type), 
+                                     follow_type, 0);
+       if (make_volatile)
+         follow_type = make_cv_type (TYPE_CONST (follow_type), 
+                                     make_volatile, 
+                                     follow_type, 0);
+       break;
+      case tp_const:
+       make_const = 1;
+       break;
+      case tp_volatile:
+       make_volatile = 1;
        break;
       case tp_pointer:
        follow_type = lookup_pointer_type (follow_type);
        break;
       case tp_pointer:
        follow_type = lookup_pointer_type (follow_type);
+       if (make_const)
+         follow_type = make_cv_type (make_const, 
+                                     TYPE_VOLATILE (follow_type), 
+                                     follow_type, 0);
+       if (make_volatile)
+         follow_type = make_cv_type (TYPE_CONST (follow_type), 
+                                     make_volatile, 
+                                     follow_type, 0);
+       make_const = make_volatile = 0;
        break;
       case tp_reference:
        follow_type = lookup_reference_type (follow_type);
        break;
       case tp_reference:
        follow_type = lookup_reference_type (follow_type);
+       if (make_const)
+         follow_type = make_cv_type (make_const, TYPE_VOLATILE (follow_type), follow_type, 0);
+       if (make_volatile)
+         follow_type = make_cv_type (TYPE_CONST (follow_type), make_volatile, follow_type, 0);
+       make_const = make_volatile = 0;
        break;
       case tp_array:
        array_size = pop_type_int ();
        break;
       case tp_array:
        array_size = pop_type_int ();
@@ -1331,24 +1365,36 @@ build_parse (void)
   i = 0;
   /* fill it in */
 #ifdef PC_REGNUM
   i = 0;
   /* fill it in */
 #ifdef PC_REGNUM
-  std_regs[i].name = "pc";
-  std_regs[i].regnum = PC_REGNUM;
-  i++;
+  if (PC_REGNUM >= 0)
+    {
+      std_regs[i].name = "pc";
+      std_regs[i].regnum = PC_REGNUM;
+      i++;
+    }
 #endif
 #ifdef FP_REGNUM
 #endif
 #ifdef FP_REGNUM
-  std_regs[i].name = "fp";
-  std_regs[i].regnum = FP_REGNUM;
-  i++;
+  if (FP_REGNUM >= 0)
+    {
+      std_regs[i].name = "fp";
+      std_regs[i].regnum = FP_REGNUM;
+      i++;
+    }
 #endif
 #ifdef SP_REGNUM
 #endif
 #ifdef SP_REGNUM
-  std_regs[i].name = "sp";
-  std_regs[i].regnum = SP_REGNUM;
-  i++;
+  if (SP_REGNUM >= 0)
+    {
+      std_regs[i].name = "sp";
+      std_regs[i].regnum = SP_REGNUM;
+      i++;
+    }
 #endif
 #ifdef PS_REGNUM
 #endif
 #ifdef PS_REGNUM
-  std_regs[i].name = "ps";
-  std_regs[i].regnum = PS_REGNUM;
-  i++;
+  if (PS_REGNUM >= 0)
+    {
+      std_regs[i].name = "ps";
+      std_regs[i].regnum = PS_REGNUM;
+      i++;
+    }
 #endif
   memset (&std_regs[i], 0, sizeof (std_regs[i]));
 }
 #endif
   memset (&std_regs[i], 0, sizeof (std_regs[i]));
 }