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 gdb_internal_error_resync, use


Hello,

Just encountered a need for something like:
http://sources.redhat.com/ml/gdb-patches/2002-11/msg00117.html
The attached makes Fernando's requested changes plus adds a loop/counter to stop an infinite loop.


The patch also modifies maint.exp so that it uses this procedure when recovering from that intentional internal error - that way I know that the procedure works :-)

committed,
Andrew

PS: The patch is in two parts - I missed a case but then fixed it.
2003-11-20  Andrew Cagney  <cagney@redhat.com>

	* lib/gdb.exp (gdb_internal_error_resync): Issue a perror when the
	resync count exceeded.
	
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.39
diff -u -r1.39 gdb.exp
--- lib/gdb.exp	20 Nov 2003 15:36:34 -0000	1.39
+++ lib/gdb.exp	20 Nov 2003 15:46:14 -0000
@@ -407,6 +407,8 @@
 	    }
 	}
     }
+    perror "Could not resync from internal error (resync count exceeded)"
+    return 0
 }
 
 
2003-11-20  Andrew Cagney  <cagney@redhat.com>

	* gdb.base/maint.exp: Use gdb_internal_error_resync to recover
	from the internal error.
	* lib/gdb.exp (gdb_internal_error_resync): New procedure.
	Original from Jim Blandy.
	(gdb_test_multiple): Use gdb_internal_error_resync.
	
Index: gdb.base/maint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/maint.exp,v
retrieving revision 1.19
diff -u -r1.19 maint.exp
--- gdb.base/maint.exp	5 May 2003 18:33:11 -0000	1.19
+++ gdb.base/maint.exp	20 Nov 2003 15:34:21 -0000
@@ -650,34 +650,22 @@
         }
 
 send_gdb "maint internal-error\n"
-gdb_expect  {
-    -re "Quit this debugging session.*\\(y or n\\) $" {
-	send_gdb "n\n"
-	gdb_expect {
-	    -re "Create a core file.*\\(y or n\\) $" {
-		send_gdb "n\n"
-		gdb_expect {
-		    -re ".*$gdb_prompt $" {
-			pass "maint internal-error"
-		    }
-		    timeout {
-			fail "(timeout)  maint internal-error"
-		    }
-		}
-	    }
-	    -re ".*$gdb_prompt $" {
-		fail "maint internal-error"
-	    }
-	    timeout {
-		fail "(timeout)  maint internal-error"
-	    }
+gdb_expect {
+    -re "A problem internal to GDB has been detected" {
+	pass "maint internal-error"
+	if [gdb_internal_error_resync] {
+	    pass "internal-error resync"
+	} else {
+	    fail "internal-error resync"
 	}
     }
     -re ".*$gdb_prompt $" {
 	fail "maint internal-error"
+	untested "internal-error resync"
     }
     timeout {
-	fail "(timeout) maint internal-error"
+	fail "maint internal-error (timeout)"
+	untested "internal-error resync"
     }
 }
 
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.38
diff -u -r1.38 gdb.exp
--- lib/gdb.exp	17 Nov 2003 15:00:20 -0000	1.38
+++ lib/gdb.exp	20 Nov 2003 15:34:21 -0000
@@ -360,6 +360,55 @@
 }
 
 
+# gdb_internal_error_resync:
+#
+# Answer the questions GDB asks after it reports an internal error
+# until we get back to a GDB prompt.  Decline to quit the debugging
+# session, and decline to create a core file.  Return non-zero if the
+# resync succeeds.
+#
+# This procedure just answers whatever questions come up until it sees
+# a GDB prompt; it doesn't require you to have matched the input up to
+# any specific point.  However, it only answers questions it sees in
+# the output itself, so if you've matched a question, you had better
+# answer it yourself before calling this.
+#
+# You can use this function thus:
+#
+# gdb_expect {
+#     ...
+#     -re ".*A problem internal to GDB has been detected" {
+#         gdb_internal_error_resync
+#     }
+#     ...
+# }
+#
+proc gdb_internal_error_resync {} {
+    global gdb_prompt
+
+    set count 0
+    while {$count < 10} {
+	gdb_expect {
+	    -re "Quit this debugging session\\? \\(y or n\\) $" {
+		send_gdb "n\n"
+		incr count
+	    }
+	    -re "Create a core file of GDB\\? \\(y or n\\) $" {
+		send_gdb "n\n"
+		incr count
+	    }
+	    -re "$gdb_prompt $" {
+		# We're resynchronized.
+		return 1
+	    }
+	    timeout {
+		perror "Could not resync from internal error (timeout)"
+		return 0
+	    }
+	}
+    }
+}
+
 
 # gdb_test_multiple COMMAND MESSAGE EXPECT_ARGUMENTS
 # Send a command to gdb; test the result.
@@ -511,6 +560,10 @@
     }
 
     set code {
+         -re ".*A problem internal to GDB has been detected" {
+             fail "$message (GDB internal error)"
+             gdb_internal_error_resync
+         }
 	 -re "\\*\\*\\* DOSEXIT code.*" {
 	     if { $message != "" } {
 		 fail "$message";

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