This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] gdbserver/tracepoint.c, eval_agent_expr, prevent stack underflow.


Pedro,

Correct me if I'm wrong, but it looks to me as if this function will detect stack underflow only after it has happened, and an invalid stack element has been used. This change sets aside the zeroeth element of the stack as a sentinel, to prevent that.

OK?

2011-03-08  Michael Snyder  <msnyder@msnyder-server.eng.vmware.com>

	* gdbserver/tracepoint.c (eval_agent_expr): Use zeroeth stack
	element as a sentinal to prevent stack underflow.

Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/tracepoint.c,v
retrieving revision 1.21
diff -u -p -r1.21 tracepoint.c
--- tracepoint.c	24 Feb 2011 07:38:42 -0000	1.21
+++ tracepoint.c	9 Mar 2011 01:23:38 -0000
@@ -4227,7 +4227,7 @@ eval_agent_expr (struct tracepoint_hit_c
   int pc = 0;
 #define STACK_MAX 100
   ULONGEST stack[STACK_MAX], top;
-  int sp = 0;
+  int sp = 1;
   unsigned char op;
   int arg;
 
@@ -4600,7 +4600,7 @@ eval_agent_expr (struct tracepoint_hit_c
 	  return expr_eval_stack_overflow;
 	}
 
-      if (sp < 0)
+      if (sp <= 0)
 	{
 	  trace_debug ("Expression stack underflow");
 	  return expr_eval_stack_underflow;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]