]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* hppa-tdep.c: Remove all uses of use_unwind and `set use_unwind'
authorJim Kingdon <jkingdon@engr.sgi.com>
Mon, 26 Jul 1993 22:16:09 +0000 (22:16 +0000)
committerJim Kingdon <jkingdon@engr.sgi.com>
Mon, 26 Jul 1993 22:16:09 +0000 (22:16 +0000)
command.  Now we use unwind info by default if we can find it.

* config/sparc: Move VARIABLES_INSIDE_BLOCK and SUN_FIXED_LBRAC_BUG
to tm-sparc.h so they are shared between Solaris and SunOS4.
* dbxread.c (process_one_symbol): Deal with SunOS4 acc N_STSYM and
N_GSYM functions.

gdb/ChangeLog
gdb/config/sparc/tm-sparc.h
gdb/config/sparc/tm-sun4os4.h
gdb/config/sparc/tm-sun4sol2.h
gdb/dbxread.c
gdb/hppa-tdep.c

index ffca0779aed1fd0b854ba3e66a32bb483dd41340..8fdf5e08e2b6e51bf35117a2d7dd877bd568ad4c 100644 (file)
@@ -1,5 +1,13 @@
 Mon Jul 26 13:17:36 1993  Jim Kingdon  (kingdon@lioth.cygnus.com)
 
+       * hppa-tdep.c: Remove all uses of use_unwind and `set use_unwind'
+       command.  Now we use unwind info by default if we can find it.
+
+       * config/sparc: Move VARIABLES_INSIDE_BLOCK and SUN_FIXED_LBRAC_BUG
+       to tm-sparc.h so they are shared between Solaris and SunOS4.
+       * dbxread.c (process_one_symbol): Deal with SunOS4 acc N_STSYM and
+       N_GSYM functions.
+
        * config/pa/tm-hppa.h (REGISTER_NAMES): Use "fr" rather than "fp"
        for floating point registers.
 
index c0499566061991a1c1a7aab743ec548ee8964651..70f1f20c4ab7fd7f801197dd6b2af81f24b7d43f 100644 (file)
@@ -47,6 +47,31 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* OK, I've added code to dbxread.c to deal with this case.  */
 #define BELIEVE_PCC_PROMOTION_TYPE
 
+/* For acc, there's no need to correct LBRAC entries by guessing how
+   they should work.  In fact, this is harmful because the LBRAC
+   entries now all appear at the end of the function, not intermixed
+   with the SLINE entries.  n_opt_found detects acc for Solaris binaries;
+   function_stab_type detects acc for SunOS4 binaries.
+
+   For binary from SunOS4 /bin/cc, need to correct LBRAC's.
+
+   For gcc, like acc, don't correct.  */
+
+#define        SUN_FIXED_LBRAC_BUG \
+  (n_opt_found \
+   || function_stab_type == N_STSYM \
+   || function_stab_type == N_GSYM \
+   || processing_gcc_compilation)
+
+/* Do variables in the debug stabs occur after the N_LBRAC or before it?
+   acc: after, gcc: before, SunOS4 /bin/cc: before.  */
+
+#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) \
+  (!(gcc_p) \
+   && (n_opt_found \
+       || function_stab_type == N_STSYM \
+       || function_stab_type == N_GSYM))
+
 /* Offset from address of function to start of its code.
    Zero on most machines.  */
 
index 52d2d139ee09f97f5e1f414447d21cb9c9fe4d53..613ed774c1e15747975f80d59c8a63e11506d298 100644 (file)
@@ -20,22 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "sparc/tm-sparc.h"
 #include "tm-sunos.h"
 
-/* Do variables in the debug stabs occur after the N_LBRAC or before it?
-   acc: after, gcc: before, SunOS4 /bin/cc: before.  */
-
-#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!(gcc_p) && n_opt_found)
-
-/* For acc, there's no need to correct LBRAC entries by guessing how
-   they should work.  In fact, this is harmful because the LBRAC
-   entries now all appear at the end of the function, not intermixed
-   with the SLINE entries.
-
-   For binary from SunOS4 /bin/cc, need to correct LBRAC's.
-
-   For gcc, doesn't matter, attempting the correction is harmless.  */
-
-#define        SUN_FIXED_LBRAC_BUG (n_opt_found)
-
 /* Offsets into jmp_buf.  Not defined by Sun, but at least documented in a
    comment in <machine/setjmp.h>! */
 
index 0cf93209e2bacdc7b490a673156652288daf4c84..0c3b7c146805ed8511dda054c078ae8b93bd431c 100644 (file)
@@ -23,22 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #undef IN_SOLIB_TRAMPOLINE
 #define IN_SOLIB_TRAMPOLINE(pc, name)  in_solib_trampoline((pc), (name))
 
-/* Do variables in the debug stabs occur after the N_LBRAC or before it?
-   acc: after, gcc: before, SunOS4 /bin/cc: before.  */
-
-#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!(gcc_p) && n_opt_found)
-
-/* For acc, there's no need to correct LBRAC entries by guessing how
-   they should work.  In fact, this is harmful because the LBRAC
-   entries now all appear at the end of the function, not intermixed
-   with the SLINE entries.
-
-   For binary from SunOS4 /bin/cc, need to correct LBRAC's.
-
-   For gcc, like acc, don't correct.  */
-
-#define        SUN_FIXED_LBRAC_BUG (n_opt_found || processing_gcc_compilation)
-
 #if 0  /* FIXME Setjmp/longjmp are not as well doc'd in SunOS 5.x yet */
 
 /* Offsets into jmp_buf.  Not defined by Sun, but at least documented in a
index 06636feda0744050b80eb582c18d3f8024888383..5a249fb70d6993314b2d66222c25ff531e39eb56 100644 (file)
@@ -423,19 +423,60 @@ record_minimal_symbol (name, address, type, objfile)
 {
   enum minimal_symbol_type ms_type;
 
-  switch (type &~ N_EXT) {
-    case N_TEXT:  ms_type = mst_text; break;
-    case N_DATA:  ms_type = mst_data; break;
-    case N_BSS:   ms_type = mst_bss;  break;
-    case N_ABS:   ms_type = mst_abs;  break;
+  switch (type)
+    {
+    case N_TEXT | N_EXT:  ms_type = mst_text; break;
+    case N_DATA | N_EXT:  ms_type = mst_data; break;
+    case N_BSS | N_EXT:   ms_type = mst_bss;  break;
+    case N_ABS | N_EXT:   ms_type = mst_abs;  break;
 #ifdef N_SETV
-    case N_SETV:  ms_type = mst_data; break;
+    case N_SETV | N_EXT:  ms_type = mst_data; break;
+    case N_SETV:
+      /* I don't think this type actually exists; since a N_SETV is the result
+        of going over many .o files, it doesn't make sense to have one
+        file local.  */
+      ms_type = mst_file_data;
+      break;
 #endif
+    case N_NBTEXT:
+    case N_FN:
+    case N_FN_SEQ:
+    case N_TEXT:
+      ms_type = mst_file_text;
+      break;
+
+    case N_DATA:
+      ms_type = mst_file_data;
+
+      /* Check for __DYNAMIC, which is used by Sun shared libraries. 
+        Record it as global even if it's local, not global, so
+        lookup_minimal_symbol can find it.
+        FIXME:  this might want to check for _DYNAMIC and the current
+        symbol_leading_char.  */
+      if (name[8] == 'C' && STREQ ("__DYNAMIC", name))
+       ms_type = mst_data;
+
+      /* Same with virtual function tables, both global and static.  */
+      {
+       char *tempstring = name;
+       if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd))
+         ++tempstring;
+       if (VTBL_PREFIX_P ((tempstring)))
+         ms_type = mst_data;
+      }
+      break;
+
+    case N_BSS:
+      ms_type = mst_file_bss;
+      break;
+
     default:      ms_type = mst_unknown; break;
   }
 
-  prim_record_minimal_symbol (obsavestring (name, strlen (name), &objfile -> symbol_obstack),
-                            address, ms_type);
+  prim_record_minimal_symbol
+    (obsavestring (name, strlen (name), &objfile -> symbol_obstack),
+     address,
+     ms_type);
 }
 \f
 /* Scan and build partial symbols for a symbol file.
@@ -1486,16 +1527,19 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
      other than Solaris 2, this just holds the SECT_OFF_TEXT value, and is
      used to relocate these symbol types rather than SECTION_OFFSETS.  */
   static CORE_ADDR function_start_offset;
-  char *colon_pos;
 
   /* If this is nonzero, N_LBRAC, N_RBRAC, and N_SLINE entries are relative
      to the function start address.  */
   int block_address_function_relative;
 
   /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this source
-     file.  */
+     file.  Used to detect the SunPRO solaris compiler.  */
   int n_opt_found;
 
+  /* The stab type used for the definition of the last function.
+     N_STSYM or N_GSYM for SunOS4 acc; N_FUN for other compilers.  */
+  static int function_stab_type = 0;
+
   /* This is true for Solaris (and all other stabs-in-elf systems, hopefully,
      since it would be silly to do things differently from Solaris), and
      false for SunOS4 and other a.out file formats.  */
@@ -1523,65 +1567,9 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     {
     case N_FUN:
     case N_FNAME:
-#if 0
-      /* The Sun acc compiler, under SunOS4, puts out functions with N_GSYM
-        or N_STSYM.  The problem is that the address of the symbol is no
-        good (for N_GSYM it doesn't even attept an address; for N_STSYM
-        it puts out an address but then it gets relocated relative to the
-        data segment, not the text segment), so we would have to keep track of
-        where we would use the address (e.g. to close off the block for
-        the previous function), and patch it later (we already do this for
-        some symbols, e.g. 'G', but in that case we just need to patch the
-        symbol, not other data structures).  */
-    case N_GSYM:
-    case N_STSYM:
-#endif /* 0 */
-
       /* Relocate for dynamic loading */
       valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
-
-      /* Either of these types of symbols indicates the start of
-        a new function.  We must process its "name" normally for dbx,
-        but also record the start of a new lexical context, and possibly
-        also the end of the lexical context for the previous function.  */
-      /* This is not always true.  This type of symbol may indicate a
-         text segment variable.  */
-
-      colon_pos = strchr (name, ':');
-      if (!colon_pos++
-         || (*colon_pos != 'f' && *colon_pos != 'F'))
-       {
-         define_symbol (valu, name, desc, type, objfile);
-         break;
-       }
-
-#ifdef SUN_FIXED_LBRAC_BUG
-      last_pc_address = valu;  /* Save for SunOS bug circumcision */
-#endif
-
-      if (block_address_function_relative)
-       /* On Solaris 2.0 compilers, the block addresses and N_SLINE's
-          are relative to the start of the function.  On normal systems,
-          and when using gcc on Solaris 2.0, these addresses are just
-          absolute, or relative to the N_SO, depending on
-          BLOCK_ADDRESS_ABSOLUTE.  */
-       function_start_offset = valu;   
-
-      within_function = 1;
-      if (context_stack_depth > 0)
-       {
-         new = pop_context ();
-         /* Make a block for the local symbols within.  */
-         finish_block (new->name, &local_symbols, new->old_blocks,
-                       new->start_addr, valu, objfile);
-       }
-      /* Stack must be empty now.  */
-      if (context_stack_depth != 0)
-       complain (&lbrac_unmatched_complaint, symnum);
-
-      new = push_context (0, valu);
-      new->name = define_symbol (valu, name, desc, type, objfile);
-      break;
+      goto define_a_symbol;
 
     case N_LBRAC:
       /* This "symbol" just indicates the start of an inner lexical
@@ -1881,18 +1869,83 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     case N_LENG:               /* Length of preceding symbol type */
       if (name)
        {
-         struct symbol *sym;
-         sym = define_symbol (valu, name, desc, type, objfile);
-         if (sym != NULL && SYMBOL_CLASS (sym) == LOC_BLOCK)
+         int deftype;
+         char *colon_pos = strchr (name, ':');
+         if (colon_pos == NULL)
+           deftype = '\0';
+         else
+           deftype = colon_pos[1];
+
+         switch (deftype)
            {
-             /* We're not prepared to deal with this case; we won't
-                patch up the SYMBOL_BLOCK_VALUE in finish_block.
-                Setting the class to LOC_STATIC isn't particularly useful,
-                but at least we won't dump core.  */
-             static struct complaint msg = {
-               "function encountered with unexpected n_type", 0, 0};
-             complain (&msg);
-             SYMBOL_CLASS (sym) = LOC_STATIC;
+           case 'f':
+           case 'F':
+             function_stab_type = type;
+
+             /* The Sun acc compiler, under SunOS4, puts out
+                functions with N_GSYM or N_STSYM.  The problem is
+                that the address of the symbol is no good (for N_GSYM
+                it doesn't even attept an address; for N_STSYM it
+                puts out an address but then it gets relocated
+                relative to the data segment, not the text segment).
+                Currently we can't fix this up later as we do for
+                some types of symbol in scan_file_globals.
+                Fortunately we do have a way of finding the address -
+                we know that the value in last_pc_address is either
+                the one we want (if we're dealing with the first
+                function in an object file), or somewhere in the
+                previous function. This means that we can use the
+                minimal symbol table to get the address.  */
+
+             if (type == N_GSYM || type == N_STSYM)
+               {
+                 struct minimal_symbol *m;
+                 int l = colon_pos - name;
+
+                 m = lookup_minimal_symbol_by_pc (last_pc_address);
+                 if (m && STREQN (SYMBOL_NAME (m), name, l))
+                   /* last_pc_address was in this function */
+                   valu = SYMBOL_VALUE (m);
+                 else if (m && STREQN (SYMBOL_NAME (m+1), name, l))
+                   /* last_pc_address was in last function */
+                   valu = SYMBOL_VALUE (m+1);
+                 else
+                   /* Not found - use last_pc_address (for finish_block) */
+                   valu = last_pc_address;
+               }
+
+#ifdef SUN_FIXED_LBRAC_BUG
+             last_pc_address = valu;   /* Save for SunOS bug circumcision */
+#endif
+
+             if (block_address_function_relative)
+               /* For Solaris 2.0 compilers, the block addresses and
+                  N_SLINE's are relative to the start of the
+                  function.  On normal systems, and when using gcc on
+                  Solaris 2.0, these addresses are just absolute, or
+                  relative to the N_SO, depending on
+                  BLOCK_ADDRESS_ABSOLUTE.  */
+               function_start_offset = valu;   
+
+             within_function = 1;
+             if (context_stack_depth > 0)
+               {
+                 new = pop_context ();
+                 /* Make a block for the local symbols within.  */
+                 finish_block (new->name, &local_symbols, new->old_blocks,
+                               new->start_addr, valu, objfile);
+               }
+             /* Stack must be empty now.  */
+             if (context_stack_depth != 0)
+               complain (&lbrac_unmatched_complaint, symnum);
+
+             new = push_context (0, valu);
+             new->name = define_symbol (valu, name, desc, type, objfile);
+             break;
+
+           default:
+             define_symbol (valu, name, desc, type, objfile);
+             break;
            }
        }
       break;
index 5b11159af4b65c43e7013f24763397f38bbe123d..90dfa001fd075a239e7763e32af9110da3ae0ab8 100644 (file)
@@ -242,8 +242,6 @@ extract_17 (word)
                      (word & 0x1) << 16, 17) << 2;
 }
 \f
-static int use_unwind = 0;
-
 /* Lookup the unwind (stack backtrace) info for the given PC.  We search all
    of the objfiles seeking the unwind table entry for this PC.  Each objfile
    contains a sorted list of struct unwind_table_entry.  Since we do a binary
@@ -391,9 +389,6 @@ find_proc_framesize(pc)
 {
   struct unwind_table_entry *u;
 
-  if (!use_unwind)
-    return -1;
-
   u = find_unwind_entry (pc);
 
   if (!u)
@@ -443,20 +438,14 @@ int
 frameless_function_invocation (frame)
      FRAME frame;
 {
+  struct unwind_table_entry *u;
 
-  if (use_unwind)
-    {
-      struct unwind_table_entry *u;
-
-      u = find_unwind_entry (frame->pc);
-
-      if (u == 0)
-       return 0;
+  u = find_unwind_entry (frame->pc);
 
-      return (u->Total_frame_size == 0);
-    }
-  else
+  if (u == 0)
     return frameless_look_for_prologue (frame);
+
+  return (u->Total_frame_size == 0);
 }
 
 CORE_ADDR
@@ -556,37 +545,25 @@ frame_chain_valid (chain, thisframe)
   if (!chain)
     return 0;
 
-  if (use_unwind)
-    {
-
-      struct unwind_table_entry *u;
+  struct unwind_table_entry *u;
 
-      u = find_unwind_entry (thisframe->pc);
+  u = find_unwind_entry (thisframe->pc);
 
-      if (u == NULL)
-       /* FIXME, we should probably fall back to some other technique,
-          if we want to deal gracefully with stripped executables or others
-          without unwind info.  */
-       return 0;
+  msym = lookup_minimal_symbol_by_pc (FRAME_SAVED_PC (thisframe));
+  if (msym
+      && (strcmp (SYMBOL_NAME (msym), "_start") == 0))
+    return 0;
 
-      if (u->Save_SP || u->Total_frame_size)
-       return 1;
+  if (u == NULL)
+    return 1;
 
-      if (pc_in_linker_stub (thisframe->pc))
-       return 1;
+  if (u->Save_SP || u->Total_frame_size)
+    return 1;
 
-      return 0;
-    }
-  else
-    {
-      msym = lookup_minimal_symbol_by_pc (FRAME_SAVED_PC (thisframe));
+  if (pc_in_linker_stub (thisframe->pc))
+    return 1;
 
-      if (msym
-         && (strcmp (SYMBOL_NAME (msym), "_start") == 0))
-       return 0;
-      else
-       return 1;
-    }
+  return 0;
 }
 
 /*
@@ -1058,14 +1035,3 @@ unwind_command (exp, from_tty)
   printf ("%08x\n%08X\n%08X\n%08X\n", xxx.foo[0], xxx.foo[1], xxx.foo[2],
          xxx.foo[3]);
 }
-
-void
-_initialize_hppa_tdep ()
-{
-  add_com ("unwind", class_obscure, unwind_command, "Print unwind info\n");
-  add_show_from_set
-    (add_set_cmd ("use_unwind", class_obscure, var_boolean,
-                 (char *)&use_unwind,
-                 "Set the usage of unwind info", &setlist),
-     &showlist);
-}