* Rename remote-es1800.c to remote-es.c
[deliverable/binutils-gdb.git] / gdb / mipsread.c
index 9b8a240f59c760e6a2dafa2dad2494b2400c3795..294f923e612133453abb71da1c330105217f1243 100644 (file)
@@ -45,9 +45,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    This module can read all four of the known byte-order combinations,
    on any type of host.  */
 
-#define        TM_FILE_OVERRIDE
 #include "defs.h"
-#include "tm-mips.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcore.h"
@@ -58,6 +56,25 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "stabsread.h"
 #include "complaints.h"
 
+/* These are needed if the tm.h file does not contain the necessary
+   mips specific definitions.  */
+
+#ifndef MIPS_EFI_SYMBOL_NAME
+#define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
+#include "coff/sym.h"
+#include "coff/symconst.h"
+typedef struct mips_extra_func_info {
+        long    numargs;
+        PDR     pdr;
+} *mips_extra_func_info_t;
+#ifndef RA_REGNUM
+#define RA_REGNUM 0
+#endif
+#ifndef FP0_REGNUM
+#define FP0_REGNUM 0
+#endif
+#endif
+
 #ifdef USG
 #include <sys/types.h>
 #define L_SET 0
@@ -180,6 +197,9 @@ struct complaint pdr_for_nonsymbol_complaint =
 struct complaint pdr_static_symbol_complaint =
 {"can't handle PDR for static proc at 0x%x", 0, 0};
 
+struct complaint bad_setjmp_pdr_complaint =
+{"fixing bad setjmp PDR from libc", 0, 0};
+
 /* Macros and extra defs */
 
 /* Already-parsed symbols are marked specially */
@@ -330,6 +350,8 @@ static void
 mipscoff_new_init (ignore)
      struct objfile *ignore;
 {
+  stabsread_new_init ();
+  buildsym_new_init ();
 }
 
 static void
@@ -410,8 +432,6 @@ mipscoff_psymtab_to_symtab (pst)
       printf_filtered ("Reading in symbols for %s...", pst->filename);
       fflush (stdout);
     }
-  /* Get the BFD and list of pending typedefs */
-  cur_bfd = CUR_BFD (pst);
 
   next_symbol_text_func = mips_next_symbol_text;
 
@@ -1581,6 +1601,16 @@ parse_procedure (pr, have_stabs, first_off)
       e->pdr = *pr;
       e->pdr.isym = (long) s;
       e->pdr.adr += cur_fdr->adr - first_off;
+
+      /* Correct incorrect setjmp procedure descriptor from the library
+        to make backtrace through setjmp work.  */
+      if (e->pdr.pcreg == 0 && strcmp (sh_name, "setjmp") == 0)
+       {
+         complain (&bad_setjmp_pdr_complaint, 0);
+         e->pdr.pcreg = RA_REGNUM;
+         e->pdr.regmask = 0x80000000;
+         e->pdr.regoffset = -4;
+       }
     }
 }
 
@@ -2377,8 +2407,15 @@ psymtab_to_symtab_1 (pst, filename)
                             pst->dependencies[i]->filename);
       }
 
+  /* Do nothing if this is a dummy psymtab.  */
+
+  if (pst->n_global_syms == 0 && pst->n_static_syms == 0
+      && pst->textlow == 0 && pst->texthigh == 0)
+    return;
+
   /* Now read the symbols for this symtab */
 
+  cur_bfd = CUR_BFD (pst);
   current_objfile = pst->objfile;
   cur_fd = FDR_IDX (pst);
   fh = (cur_fd == -1) ? (FDR *) NULL : ecoff_data (cur_bfd)->fdr + cur_fd;
@@ -2459,10 +2496,13 @@ psymtab_to_symtab_1 (pst, filename)
              /* Handle encoded stab line number. */
              record_line (current_subfile, sh.index, valu);
            }
+         else if (sh.st == stProc || sh.st == stStaticProc || sh.st == stEnd)
+           /* These are generated by gcc-2.x, do not complain */
+           ;
          else
            complain (&stab_unknown_complaint, name);
        }
-      st = end_symtab (pst->texthigh, 0, 0, pst->objfile);
+      st = end_symtab (pst->texthigh, 0, 0, pst->objfile, SECT_OFF_TEXT);
       end_stabs ();
 
       /* Sort the symbol table now, we are done adding symbols to it.
@@ -2819,7 +2859,18 @@ add_block (b, s)
 
 /* Add a new linenumber entry (LINENO,ADR) to a linevector LT.
    MIPS' linenumber encoding might need more than one byte
-   to describe it, LAST is used to detect these continuation lines */
+   to describe it, LAST is used to detect these continuation lines.
+
+   Combining lines with the same line number seems like a bad idea.
+   E.g: There could be a line number entry with the same line number after the
+   prologue and GDB should not ignore it (this is a better way to find
+   a prologue than mips_skip_prologue).
+   But due to the compressed line table format there are line number entries
+   for the same line which are needed to bridge the gap to the next
+   line number entry. These entries have a bogus address info with them
+   and we are unable to tell them from intended duplicate line number
+   entries.
+   This is another reason why -ggdb debugging format is preferable.  */
 
 static int
 add_line (lt, lineno, adr, last)
@@ -2853,7 +2904,7 @@ compare_blocks (arg1, arg2)
 
   addr_diff = (BLOCK_START ((*b1))) - (BLOCK_START ((*b2)));
   if (addr_diff == 0)
-    return (BLOCK_END ((*b1))) - (BLOCK_END ((*b2)));
+    return (BLOCK_END ((*b2))) - (BLOCK_END ((*b1)));
   return addr_diff;
 }
 
@@ -3102,19 +3153,20 @@ fixup_sigtramp ()
 
   sigtramp_address = -1;
 
-  /* We know it is sold as sigvec */
+  /* We have to handle the following cases here:
+     a) The Mips library has a sigtramp label within sigvec.
+     b) Irix has a _sigtramp which we want to use, but it also has sigvec.  */
   s = lookup_symbol ("sigvec", 0, VAR_NAMESPACE, 0, NULL);
-
-  /* Most programs do not play with signals */
-  if (s == 0)
-    s = lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE, 0, NULL);
-  else
+  if (s != 0)
     {
       b0 = SYMBOL_BLOCK_VALUE (s);
-
-      /* A label of sigvec, to be more precise */
       s = lookup_symbol ("sigtramp", b0, VAR_NAMESPACE, 0, NULL);
     }
+  if (s == 0)
+    {
+      /* No sigvec or no sigtramp inside sigvec, try _sigtramp.  */
+      s = lookup_symbol ("_sigtramp", 0, VAR_NAMESPACE, 0, NULL);
+    }
 
   /* But maybe this program uses its own version of sigvec */
   if (s == 0)
@@ -3165,11 +3217,12 @@ fixup_sigtramp ()
     /* align_longword(sigcontext + SIGFRAME) */
     e->pdr.frameoffset = 0x150;
     e->pdr.framereg = SP_REGNUM;
-    e->pdr.pcreg = 31;
+    /* read_next_frame_reg provides the true pc at the time of signal */
+    e->pdr.pcreg = PC_REGNUM;
     e->pdr.regmask = -2;
     e->pdr.regoffset = -(41 * sizeof (int));
     e->pdr.fregmask = -1;
-    e->pdr.fregoffset = -(37 * sizeof (int));
+    e->pdr.fregoffset = -(7 * sizeof (int));
     e->pdr.isym = (long) s;
 
     current_objfile = st->objfile;     /* Keep new_symbol happy */
This page took 0.02546 seconds and 4 git commands to generate.