Sun Oct 24 20:16:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
authorJim Kingdon <jkingdon@engr.sgi.com>
Sun, 24 Oct 1993 23:42:02 +0000 (23:42 +0000)
committerJim Kingdon <jkingdon@engr.sgi.com>
Sun, 24 Oct 1993 23:42:02 +0000 (23:42 +0000)
* parse.c, parser-defs.h (write_exp_msymbol):  New function to write
the appropriate expression for a minimal symbol.
* c-exp.y, m2-exp.y:  Use it.

gdb/ChangeLog
gdb/c-exp.y
gdb/m2-exp.y
gdb/parse.c
gdb/parser-defs.h

index a265f5b4d178745740b7bd957a18f0b29cfff6e9..480e6f97d2349c949fdce000155ba817d58b4440 100644 (file)
@@ -1,3 +1,10 @@
+Sun Oct 24 20:16:38 1993  Peter Schauer  (pes@regent.e-technik.tu-muenchen.de)
+
+       * parse.c, parser-defs.h (write_exp_msymbol):  New function to write
+       the appropriate expression for a minimal symbol.  Taken from c-exp.y
+       and m2-exp.y but handles mst_file_*.
+       * c-exp.y, m2-exp.y:  Use it.
+
 Sun Oct 24 09:31:05 1993  Fred Fish  (fnf@lisa.cygnus.com)
 
        * elfread.c (elf_symtab_read):  Use bfd convention that both
index dd7de2d40bd535ff65b8c0a1ae26342cd1bfd4e2..d87f27ecbd2b78bcf1c973bc8f874e5160c49cc4 100644 (file)
@@ -38,8 +38,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include "defs.h"
 #include "expression.h"
-#include "parser-defs.h"
 #include "value.h"
+#include "parser-defs.h"
 #include "language.h"
 #include "c-lang.h"
 #include "bfd.h" /* Required by objfiles.h.  */
@@ -635,19 +635,9 @@ variable:  qualified_name
                                      (struct objfile *) NULL);
                          if (msymbol != NULL)
                            {
-                             write_exp_elt_opcode (OP_LONG);
-                             write_exp_elt_type (builtin_type_long);
-                             write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
-                             write_exp_elt_opcode (OP_LONG);
-                             write_exp_elt_opcode (UNOP_MEMVAL);
-                             if (msymbol -> type == mst_data ||
-                                 msymbol -> type == mst_bss)
-                               write_exp_elt_type (builtin_type_int);
-                             else if (msymbol -> type == mst_text)
-                               write_exp_elt_type (lookup_function_type (builtin_type_int));
-                             else
-                               write_exp_elt_type (builtin_type_char);
-                             write_exp_elt_opcode (UNOP_MEMVAL);
+                             write_exp_msymbol (msymbol,
+                                                lookup_function_type (builtin_type_int),
+                                                builtin_type_int);
                            }
                          else
                            if (!have_full_symbols () && !have_partial_symbols ())
@@ -701,19 +691,9 @@ variable:  name_not_typename
                                          (struct objfile *) NULL);
                              if (msymbol != NULL)
                                {
-                                 write_exp_elt_opcode (OP_LONG);
-                                 write_exp_elt_type (builtin_type_long);
-                                 write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
-                                 write_exp_elt_opcode (OP_LONG);
-                                 write_exp_elt_opcode (UNOP_MEMVAL);
-                                 if (msymbol -> type == mst_data ||
-                                     msymbol -> type == mst_bss)
-                                   write_exp_elt_type (builtin_type_int);
-                                 else if (msymbol -> type == mst_text)
-                                   write_exp_elt_type (lookup_function_type (builtin_type_int));
-                                 else
-                                   write_exp_elt_type (builtin_type_char);
-                                 write_exp_elt_opcode (UNOP_MEMVAL);
+                                 write_exp_msymbol (msymbol,
+                                                    lookup_function_type (builtin_type_int),
+                                                    builtin_type_int);
                                }
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error ("No symbol table is loaded.  Use the \"file\" command.");
index 07448b18a313c97ade6cf10110822513aab4fb5f..518f11a5f8257fec38431f810a753b378d4907ca 100644 (file)
@@ -623,23 +623,13 @@ variable: NAME
                              struct minimal_symbol *msymbol;
                              register char *arg = copy_name ($1);
 
-                             msymbol = lookup_minimal_symbol (arg,
-                                         (struct objfile *) NULL);
+                             msymbol = lookup_minimal_symbol (arg, NULL);
                              if (msymbol != NULL)
                                {
-                                 write_exp_elt_opcode (OP_LONG);
-                                 write_exp_elt_type (builtin_type_long);
-                                 write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
-                                 write_exp_elt_opcode (OP_LONG);
-                                 write_exp_elt_opcode (UNOP_MEMVAL);
-                                 if (msymbol -> type == mst_data ||
-                                     msymbol -> type == mst_bss)
-                                   write_exp_elt_type (builtin_type_int);
-                                 else if (msymbol -> type == mst_text)
-                                   write_exp_elt_type (lookup_function_type (builtin_type_int));
-                                 else
-                                   write_exp_elt_type (builtin_type_char);
-                                 write_exp_elt_opcode (UNOP_MEMVAL);
+                                 write_exp_msymbol
+                                   (msymbol,
+                                    lookup_function_type (builtin_type_int),
+                                    builtin_type_int);
                                }
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error ("No symbol table is loaded.  Use the \"symbol-file\" command.");
index 08f2b7e674842814b79dd56b76aedb6c05b3f635..0f3d35163046dd3d620846b240bf9a4cc613b13e 100644 (file)
@@ -338,6 +338,42 @@ write_exp_bitstring (str)
   expout_ptr += lenelt - 2;
   write_exp_elt_longcst ((LONGEST) bits);
 }
+
+/* Add the appropriate elements for a minimal symbol to the end of
+   the expression.  */
+
+void
+write_exp_msymbol (msymbol, text_symbol_type, data_symbol_type)
+     struct minimal_symbol *msymbol;
+     struct type *text_symbol_type;
+     struct type *data_symbol_type;
+{
+  write_exp_elt_opcode (OP_LONG);
+  write_exp_elt_type (builtin_type_long);
+  write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
+  write_exp_elt_opcode (OP_LONG);
+
+  write_exp_elt_opcode (UNOP_MEMVAL);
+  switch (msymbol -> type)
+    {
+    case mst_text:
+    case mst_file_text:
+      write_exp_elt_type (text_symbol_type);
+      break;
+
+    case mst_data:
+    case mst_file_data:
+    case mst_bss:
+    case mst_file_bss:
+      write_exp_elt_type (data_symbol_type);
+      break;
+
+    default:
+      write_exp_elt_type (builtin_type_char);
+      break;
+    }
+  write_exp_elt_opcode (UNOP_MEMVAL);
+}
 \f
 /* Return a null-terminated temporary copy of the name
    of a string token.  */
index 2e2b9e834b69d85e4e2d8b7a79fd6ba425c325f0..c03e1a2c344d3c7b0160ae809fd8a93eb8238f1d 100644 (file)
@@ -105,6 +105,9 @@ extern void write_exp_bitstring PARAMS ((struct stoken));
 
 extern void write_exp_elt_block PARAMS ((struct block *));
 
+extern void write_exp_msymbol PARAMS ((struct minimal_symbol *,
+                                      struct type *, struct type *));
+
 extern void
 start_arglist PARAMS ((void));