* findvar.c, value.h (symbol_read_needs_frame): New function.
authorJim Kingdon <jkingdon@engr.sgi.com>
Fri, 8 Oct 1993 20:33:22 +0000 (20:33 +0000)
committerJim Kingdon <jkingdon@engr.sgi.com>
Fri, 8 Oct 1993 20:33:22 +0000 (20:33 +0000)
* c-exp.y, m2-exp.y: Call it instead of having our own switch on
the symbol's class.
* valops.c (value_of_variable): Use symbol_read_needs_frame to
decide whether we care about finding a frame.

gdb/ChangeLog
gdb/c-exp.y
gdb/findvar.c
gdb/m2-exp.y
gdb/valops.c

index 13ba1afd4bd8a2fb1f2def59d3e5db27db73b64e..db42c5a31dc7cc2d257d66f3a4c4d0ea9bfb87a0 100644 (file)
@@ -1,3 +1,11 @@
+Fri Oct  8 14:56:21 1993  Jim Kingdon  (kingdon@lioth.cygnus.com)
+
+       * findvar.c, value.h (symbol_read_needs_frame): New function.
+       * c-exp.y, m2-exp.y: Call it instead of having our own switch on
+       the symbol's class.
+       * valops.c (value_of_variable): Use symbol_read_needs_frame to
+       decide whether we care about finding a frame.
+
 Fri Oct  8 02:34:21 1993  Peter Schauer  (pes@regent.e-technik.tu-muenchen.de)
 
        * blockframe.c (get_frame_block):  Do not adjust pc if the frame
index 1ab991c14c205ba060400c68bc82fc8e8117ffa0..37a00d2cd6bf85f7403a51d35e663490f12f1a82 100644 (file)
@@ -659,41 +659,14 @@ variable: name_not_typename
 
                          if (sym)
                            {
-                             switch (SYMBOL_CLASS (sym))
+                             if (symbol_read_needs_frame (sym))
                                {
-                               case LOC_REGISTER:
-                               case LOC_ARG:
-                               case LOC_REF_ARG:
-                               case LOC_REGPARM:
-                               case LOC_REGPARM_ADDR:
-                               case LOC_LOCAL:
-                               case LOC_LOCAL_ARG:
-                               case LOC_BASEREG:
-                               case LOC_BASEREG_ARG:
                                  if (innermost_block == 0 ||
                                      contained_in (block_found, 
                                                    innermost_block))
                                    innermost_block = block_found;
-                               case LOC_UNDEF:
-                               case LOC_CONST:
-                               case LOC_STATIC:
-                               case LOC_TYPEDEF:
-                               case LOC_LABEL:
-                               case LOC_BLOCK:
-                               case LOC_CONST_BYTES:
-                               case LOC_OPTIMIZED_OUT:
-
-                                 /* In this case the expression can
-                                    be evaluated regardless of what
-                                    frame we are in, so there is no
-                                    need to check for the
-                                    innermost_block.  These cases are
-                                    listed so that gcc -Wall will
-                                    report types that may not have
-                                    been considered.  */
-
-                                 break;
                                }
+
                              write_exp_elt_opcode (OP_VAR_VALUE);
                              /* We want to use the selected frame, not
                                 another more inner frame which happens to
index 36c72f6e65aa1008f7d759174a5c0979d0e9d8d2..50d5da6bf8753e5d216fd28fac3b75776acf2b76 100644 (file)
@@ -467,7 +467,7 @@ read_register (regno)
 void
 write_register (regno, val)
      int regno;
-     long val;
+     LONGEST val;
 {
   PTR buf;
   int size;
@@ -518,6 +518,45 @@ supply_register (regno, val)
 #endif
 }
 \f
+/* Will calling read_var_value or locate_var_value on SYM end
+   up caring what frame it is being evaluated relative to?  SYM must
+   be non-NULL.  */
+int
+symbol_read_needs_frame (sym)
+     struct symbol *sym;
+{
+  switch (SYMBOL_CLASS (sym))
+    {
+      /* All cases listed explicitly so that gcc -Wall will detect it if
+        we failed to consider one.  */
+    case LOC_REGISTER:
+    case LOC_ARG:
+    case LOC_REF_ARG:
+    case LOC_REGPARM:
+    case LOC_REGPARM_ADDR:
+    case LOC_LOCAL:
+    case LOC_LOCAL_ARG:
+    case LOC_BASEREG:
+    case LOC_BASEREG_ARG:
+      return 1;
+
+    case LOC_UNDEF:
+    case LOC_CONST:
+    case LOC_STATIC:
+    case LOC_TYPEDEF:
+
+    case LOC_LABEL:
+      /* Getting the address of a label can be done independently of the block,
+        even if some *uses* of that address wouldn't work so well without
+        the right frame.  */
+
+    case LOC_BLOCK:
+    case LOC_CONST_BYTES:
+    case LOC_OPTIMIZED_OUT:
+      return 0;
+    }
+}
+
 /* Given a struct symbol for a variable,
    and a stack frame id, read the value of the variable
    and return a (pointer to a) struct value containing the value. 
index ee6799cea45393660a838e0eb02ebbaf342a2346..cc4001fa984cd432d1fb21cd6ff913e4a7156be9 100644 (file)
@@ -599,35 +599,14 @@ variable: NAME
                                               NULL);
                          if (sym)
                            {
-                             switch (sym->class)
+                             if (symbol_read_needs_frame (sym))
                                {
-                               case LOC_REGISTER:
-                               case LOC_ARG:
-                               case LOC_LOCAL:
-                               case LOC_REF_ARG:
-                               case LOC_REGPARM:
-                               case LOC_REGPARM_ADDR:
-                               case LOC_LOCAL_ARG:
-                               case LOC_BASEREG:
-                               case LOC_BASEREG_ARG:
                                  if (innermost_block == 0 ||
-                                     contained_in (block_found,
+                                     contained_in (block_found, 
                                                    innermost_block))
                                    innermost_block = block_found;
-                                 break;
-
-                               case LOC_UNDEF:
-                               case LOC_CONST:
-                               case LOC_STATIC:
-                               case LOC_TYPEDEF:
-                               case LOC_LABEL: /* maybe should go above? */
-                               case LOC_BLOCK:
-                               case LOC_CONST_BYTES:
-                               case LOC_OPTIMIZED_OUT:
-                                 /* These are listed so gcc -Wall will reveal
-                                    un-handled cases.  */
-                                 break;
                                }
+
                              write_exp_elt_opcode (OP_VAR_VALUE);
                              /* We want to use the selected frame, not
                                 another more inner frame which happens to
index 82d0f58991f481c64e5c742c1d3d2276b55d7d3a..1c7e3b92685d09066d2a64ea2eb680658438dfde 100644 (file)
@@ -511,7 +511,7 @@ value_of_variable (var, b)
   else
     {
       fr = block_innermost_frame (b);
-      if (fr == NULL)
+      if (fr == NULL && symbol_read_needs_frame (var))
        {
          if (BLOCK_FUNCTION (b) != NULL
              && SYMBOL_NAME (BLOCK_FUNCTION (b)) != NULL)
This page took 0.038445 seconds and 4 git commands to generate.