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]

[PATCH] Fix `rerun_to_main'


Hi,

As mentioned in:

    http://sourceware.org/ml/gdb-patches/2012-05/msg00458.html

I believe `rerun_to_main' is wrong for native GDB.  It does not certify
that (a) there is a breakpoint on `main' and (b) this breakpoint is
hit.  The proposed patch fixes this by always inserting a temporary
breakpoint on `main' (even for GDBserver cases), and then checking that
this breakpoint has hit in a native GDB environment.

It doesn't cause any regression on Fedora 16 x86_64.  This patch also
fixes what <http://sourceware.org/ml/gdb-patches/2012-05/msg00458.html>
is fixing, but the latter is more correct since `rerun_to_main' is
useless in `stap-probe.exp' (as explained in the message).

OK to apply?

-- 
Sergio

gdb/testsuite/ChangeLog:
2012-05-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	* lib/gdb.exp (rerun_to_main): Always insert a temporary
	breakpoint on `main'.  Check that the mentioned breakpoint is hit
	for native GDB.

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1dfe564..380ade0 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3399,10 +3399,14 @@ proc gdb_continue_to_end {{mssg ""} {command continue} {allow_extra 0}} {
 proc rerun_to_main {} {
   global gdb_prompt use_gdb_stub
 
+  gdb_breakpoint "main" "temporary"
   if $use_gdb_stub {
     gdb_run_cmd
     gdb_expect {
-      -re ".*Breakpoint .*main .*$gdb_prompt $"\
+    # We insert a temporary breakpoint on `main', but if there is another,
+    # non-temporary breakpoint on `main' before, this breakpoint won't be
+    # hit.  That's why we check for \[Bb\] here.
+      -re ".*\[Bb\]reakpoint .*main .*$gdb_prompt $"\
 	      {pass "rerun to main" ; return 0}
       -re "$gdb_prompt $"\
 	      {fail "rerun to main" ; return 0}
@@ -3416,7 +3420,11 @@ proc rerun_to_main {} {
 	  exp_continue
       }
       -re "Starting program.*$gdb_prompt $"\
-	      {pass "rerun to main" ; return 0}
+	  { fail "rerun to main" ; return 0}
+      -re "Starting program.*"\
+	  exp_continue
+      -re ".*\[Bb\]reakpoint .*main .*$gdb_prompt $"\
+          { pass "rerun to main" ; return 0}
       -re "$gdb_prompt $"\
 	      {fail "rerun to main" ; return 0}
       timeout {fail "(timeout) rerun to main" ; return 0}


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