2002-11-18 Klee Dienes <kdienes@apple.com>
authorKlee Dienes <kdienes@apple.com>
Mon, 18 Nov 2002 19:14:10 +0000 (19:14 +0000)
committerKlee Dienes <kdienes@apple.com>
Mon, 18 Nov 2002 19:14:10 +0000 (19:14 +0000)
        * buildsym.h (pop_context): Convert to function, defined in
        buildsym.c.
        * buildsym.c: Include gdb_assert.h.
        (pop_context): Implement as C function.  Add check for stack
        underflow.
        * dbxread.c (process_one_symbol): Complain and stop processing
        that symbol if we are already at the top of the context stack for
        a function-end N_FUN (this would imply an umatched RBRAC).  Ditto
        when processing N_RBRAC.

gdb/ChangeLog
gdb/buildsym.c
gdb/buildsym.h
gdb/dbxread.c

index 607e89e..e16296b 100644 (file)
@@ -1,3 +1,15 @@
+2002-11-18  Klee Dienes  <kdienes@apple.com>
+
+        * buildsym.h (pop_context): Convert to function, defined in
+       buildsym.c.
+       * buildsym.c: Include gdb_assert.h.
+       (pop_context): Implement as C function.  Add check for stack
+       underflow.
+        * dbxread.c (process_one_symbol): Complain and stop processing
+       that symbol if we are already at the top of the context stack for
+       a function-end N_FUN (this would imply an umatched RBRAC).  Ditto
+       when processing N_RBRAC.
+
 2002-11-16  Daniel Jacobowitz  <drow@mvista.com>
 
        * config/pa/nm-hppah.h (CHILD_POST_FOLLOW_INFERIOR_BY_CLONE): Don't
index 09e8122..ae8929d 100644 (file)
@@ -33,6 +33,7 @@
 #include "symfile.h"
 #include "objfiles.h"
 #include "gdbtypes.h"
+#include "gdb_assert.h"
 #include "complaints.h"
 #include "gdb_string.h"
 #include "expression.h"                /* For "enum exp_opcode" used by... */
@@ -1100,6 +1101,14 @@ push_context (int desc, CORE_ADDR valu)
 
   return new;
 }
+
+struct context_stack *
+pop_context (void)
+{
+  gdb_assert (context_stack_depth > 0);
+  return (&context_stack[--context_stack_depth]);
+}
+
 \f
 
 /* Compute a small integer hash code for the given name. */
index 968a579..25fe9b1 100644 (file)
@@ -173,12 +173,6 @@ EXTERN int context_stack_depth;
 
 EXTERN int context_stack_size;
 
-/* Macro "function" for popping contexts from the stack.  Pushing is
-   done by a real function, push_context.  This returns a pointer to a
-   struct context_stack.  */
-
-#define        pop_context() (&context_stack[--context_stack_depth]);
-
 /* Non-zero if the context stack is empty.  */
 #define outermost_context_p() (context_stack_depth == 0)
 
@@ -272,6 +266,8 @@ extern void buildsym_init (void);
 
 extern struct context_stack *push_context (int desc, CORE_ADDR valu);
 
+extern struct context_stack *pop_context (void);
+
 extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
 
 extern void start_symtab (char *name, char *dirname, CORE_ADDR start_addr);
index 0cf7091..538f076 100644 (file)
@@ -2774,6 +2774,13 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
        {
          /* This N_FUN marks the end of a function.  This closes off the
             current block.  */
+
+         if (context_stack_depth <= 0)
+           {
+             complain (&lbrac_mismatch_complaint, symnum);
+             break;
+           }
+
          record_line (current_subfile, 0, function_start_offset + valu);
          within_function = 0;
          new = pop_context ();
@@ -2843,6 +2850,12 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
           N_SO, the linker did not relocate them (sigh).  */
        valu += last_source_start_addr;
 
+      if (context_stack_depth <= 0)
+       {
+         complain (&lbrac_mismatch_complaint, symnum);
+         break;
+       }
+
       new = pop_context ();
       if (desc != new->depth)
        complain (&lbrac_mismatch_complaint, symnum);