Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Handle stack underflow in dbxread.c
@ 2002-11-15  1:02 Klee Dienes
  2002-11-15 12:18 ` Jim Blandy
  0 siblings, 1 reply; 11+ messages in thread
From: Klee Dienes @ 2002-11-15  1:02 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 369 bytes --]

2002-11-15  Klee Dienes  <kdienes@apple.com>

         * buildsym.h (pop_context): 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.


[-- Attachment #2: pop-context.txt --]
[-- Type: text/plain, Size: 2654 bytes --]

2002-11-15  Klee Dienes  <kdienes@apple.com>
        
        * buildsym.h (pop_context): 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.

Index: dbxread.c
===================================================================
RCS file: /cvs/Darwin/src/live/cygnus/src/gdb/dbxread.c,v
retrieving revision 1.38
diff -u -r1.38 dbxread.c
--- dbxread.c	2002/10/26 09:20:14	1.38
+++ dbxread.c	2002/11/15 08:56:07
@@ -2946,6 +2946,11 @@
 	      complain (&fun_end_outside_fun_complaint);
 	      break;
 	    }
+	  if (context_stack_depth <= 0)
+	    {
+	      complain (&lbrac_mismatch_complaint, symnum);
+	      break;
+	    }
 	  
 	  saw_fun_start = 0;
 	  record_line (current_subfile, 0, last_function_start + valu);
@@ -3027,6 +3032,11 @@
 	valu += last_source_start_addr;
 #endif
 
+      if (context_stack_depth <= 0)
+	{
+	  complain (&lbrac_mismatch_complaint, symnum);
+	  break;
+	}
       new = pop_context ();
       if (desc != new->depth)
 	complain (&lbrac_mismatch_complaint, symnum);
Index: buildsym.h
===================================================================
RCS file: /cvs/Darwin/src/live/cygnus/src/gdb/buildsym.h,v
retrieving revision 1.5
diff -u -r1.5 buildsym.h
--- buildsym.h	2002/11/10 05:33:33	1.5
+++ buildsym.h	2002/11/15 08:56:07
@@ -22,6 +22,8 @@
 #if !defined (BUILDSYM_H)
 #define BUILDSYM_H 1
 
+#include "gdb_assert.h"
+
 /* This module provides definitions used for creating and adding to
    the symbol table.  These routines are called from various symbol-
    file-reading routines.
@@ -173,12 +175,6 @@
 
 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)
 
@@ -271,6 +267,13 @@
 extern void buildsym_init (void);
 
 extern struct context_stack *push_context (int desc, CORE_ADDR valu);
+
+/* 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() \
+  (gdb_assert (context_stack_depth > 0), &context_stack[--context_stack_depth]);
 
 extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-11-18 21:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-15  1:02 [RFA] Handle stack underflow in dbxread.c Klee Dienes
2002-11-15 12:18 ` Jim Blandy
2002-11-15 13:19   ` Klee Dienes
2002-11-18  9:57     ` Jim Blandy
2002-11-18 11:16       ` Klee Dienes
2002-11-18 12:42         ` Andrew Cagney
2002-11-18 13:06           ` Klee Dienes
2002-11-18 13:18             ` Andrew Cagney
2002-11-18 13:43               ` Klee Dienes
2002-11-18 13:18         ` Jim Blandy
2002-11-18 13:53           ` Klee Dienes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox