This is the mail archive of the gdb-patches@sources.redhat.com 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]

[commit] Add safe_frame_unwind_memory, use in tramp-frame


This adds:

extern int safe_frame_unwind_memory (struct frame_info *this_frame,
                                     CORE_ADDR addr, void *buf, int len);

to the frame code and then uses it in tramp-frame.


Recent changes mean that GDB is sniffing frames _before_ breakpoints have been pulled. Using safe_frame_unwind_memory, and hence target_read_memory_nobpt, ensures that the sniffer sees the memory as it is ment to be and not as it is (i.e., possibly containing breakpoints).

Bug revealed by sigaltstack testcase that I recently posted.

committed,
Andrew
2004-04-02  Andrew Cagney  <cagney@redhat.com>

	* frame.c (safe_frame_unwind_memory): New function.
	* frame.h (safe_frame_unwind_memory): Declare.  Update description
	of /safe_/ methods.
	* tramp-frame.c (tramp_frame_start): Re-order parmeters, add
	"next_frame".  Use safe_frame_unwind_memory.
	(tramp_frame_sniffer): Update call to tramp_frame_start.

Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.167
diff -u -r1.167 frame.c
--- frame.c	31 Mar 2004 19:40:27 -0000	1.167
+++ frame.c	2 Apr 2004 19:42:51 -0000
@@ -2270,6 +2270,14 @@
   return read_memory_unsigned_integer (addr, len);
 }
 
+int
+safe_frame_unwind_memory (struct frame_info *this_frame,
+			  CORE_ADDR addr, void *buf, int len)
+{
+  /* NOTE: read_memory_nobpt returns zero on success!  */
+  return !read_memory_nobpt (addr, buf, len);
+}
+
 /* Architecture method.  */
 
 struct gdbarch *
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.123
diff -u -r1.123 frame.h
--- frame.h	31 Mar 2004 19:40:28 -0000	1.123
+++ frame.h	2 Apr 2004 19:42:51 -0000
@@ -40,8 +40,8 @@
    strongly hinting at its unsafeness)
 
    safe_....(): Safer version of various functions, doesn't throw an
-   error (leave this for later?).  Returns non-zero if the fetch
-   succeeds.   Return a freshly allocated error message?
+   error (leave this for later?).  Returns non-zero / non-NULL if the
+   request succeeds, zero / NULL otherwize.
 
    Suffixes:
 
@@ -460,6 +460,11 @@
 					CORE_ADDR memaddr, int len);
 extern ULONGEST get_frame_memory_unsigned (struct frame_info *this_frame,
 					   CORE_ADDR memaddr, int len);
+
+/* Same as above, but return non-zero when the entire memory read
+   succeeds, zero otherwize.  */
+extern int safe_frame_unwind_memory (struct frame_info *this_frame,
+				     CORE_ADDR addr, void *buf, int len);
 
 /* Return this frame's architecture.  */
 
Index: tramp-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/tramp-frame.c,v
retrieving revision 1.3
diff -u -r1.3 tramp-frame.c
--- tramp-frame.c	24 Mar 2004 23:14:39 -0000	1.3
+++ tramp-frame.c	2 Apr 2004 19:42:52 -0000
@@ -85,7 +85,8 @@
 }
 
 static CORE_ADDR
-tramp_frame_start (CORE_ADDR pc, const struct tramp_frame *tramp)
+tramp_frame_start (const struct tramp_frame *tramp,
+		   struct frame_info *next_frame, CORE_ADDR pc)
 {
   int ti;
   /* Search through the trampoline for one that matches the
@@ -100,8 +101,9 @@
 	  ULONGEST insn;
 	  if (tramp->insn[i] == TRAMP_SENTINEL_INSN)
 	    return func;
-	  if (target_read_memory (func + i * tramp->insn_size, buf,
-				  tramp->insn_size) != 0)
+	  if (!safe_frame_unwind_memory (next_frame,
+					 func + i * tramp->insn_size,
+					 buf, tramp->insn_size))
 	    break;
 	  insn = extract_unsigned_integer (buf, tramp->insn_size);
 	  if (tramp->insn[i] != insn)
@@ -133,7 +135,7 @@
   if (find_pc_section (pc) != NULL)
     return 0;
   /* Finally, check that the trampoline matches at PC.  */
-  func = tramp_frame_start (pc, tramp);
+  func = tramp_frame_start (tramp, next_frame, pc);
   if (func == 0)
     return 0;
   tramp_cache = FRAME_OBSTACK_ZALLOC (struct tramp_frame_cache);

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