This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] testsuite: Skip over function prologue in runto and runto_main
- From: "Pierre Muller" <muller at ics dot u-strasbg dot fr>
- To: "'Pedro Alves'" <pedro_alves at portugalmail dot pt>, <gdb-patches at sourceware dot org>
- Date: Wed, 5 Dec 2007 10:22:27 +0100
- Subject: [RFC] testsuite: Skip over function prologue in runto and runto_main
- References: <47112285.2080100@portugalmail.pt>
I was rereading the thread:
http://sourceware.org/ml/gdb-patches/2007-10/msg00361.html
but if I understood things correctly, it would mean
that if your patch goes in, and I use the
'start' command, I would end up
past the call to __main.
This might be an annoying change for people
used, like me, to either 'step' or 'next'
after 'start' depending on if they want to analyze
what is going on in the startup code.
Thus, I am asking:
Why do you consider this as broken?
Is it just because this is the reason of a lot of
cygwin testsuite failures?
If this is the reason, I would propose another route
to solve this:
Modify gdb.exp runto_main function
so that if it ends up at a line
containing only an open brace, it will
know that there is some implicit code
that needs to be executed and just issue a 'next' command
to reach the point that is reached directly in
other systems.
I just tested that change,
and the results are not bad:
+266 PASS
-104 FAIL
$ head gdbexp-testsuite-results.diff
--- gdb-cvs-gdbexp.sum 2007-12-04 18:18:56.171875000 +0100
+++ gdb-gdbexp.sum 2007-12-05 09:56:57.687500000 +0100
@@ -1,4 +1,4 @@
-Test Run By Pierre on Tue Dec 4 17:29:46 2007
+Test Run By Pierre on Tue Dec 4 18:32:45 2007
Native configuration is i686-pc-cygwin
$ tail -20 gdbexp-testsuite-results.diff
PASS: gdb.trace/while-dyn.exp: Current target does not support trace
Running ../../../purecvs/gdb/testsuite/gdb.trace/while-stepping.exp ...
PASS: gdb.trace/while-stepping.exp: 5.12: set a tracepoint, stepcount is
zero
@@ -11473,12 +11634,12 @@
=== gdb Summary ===
-# of expected passes 10288
-# of unexpected failures 503
+# of expected passes 10554
+# of unexpected failures 399
# of expected failures 59
# of known failures 29
-# of unresolved testcases 38
+# of unresolved testcases 37
# of untested testcases 15
-# of unsupported tests 17
+# of unsupported tests 18
/usr/local/src/cvs/purebuild/gdb/testsuite/../../gdb/gdb version
6.7.50.200712
03-cvs -nx
Here is the proposed patch:
It basically defines two new globals variables in gdb.exp:
1) skip_function_prologue
that should be "yes" if gdb should execute a 'next' statement
if after the 'runto' procedure it arrives at a line that contains
only an opening brace.
2) skip_main_function_prologue
Which does the same, but only within runto_main procedure.
This variable is set to "yes" if EXEEXT env is different from "".
But this is probably not the right condition.
I have no good idea how to set that variable, but
maybe setting it unconditionally would be OK too.
The main problem is that the pattern used to figure out if
we are still in the function prologue is probably not optimal
and requires that we do put the open brace alone on a separate
line, but that seems to be always the case (at least for the main function)
in all the test sources.
Is it a coding style requirement?
The global skip_function_prologue could be used for a
more general approach, like if we test programs that have been
compiled with profiling on.
Comments greatly appreciated.
Pierre Muller
ChangeLog entry:
* lib/gdb.exp (skip_function_prologue, skip_main_function_prologue):
New variables.
(runto): Execute a 'next' command if the breakpoint
is at the line containing only an open brace if
skip_function_prologue is "yes".
(runto_main): Idem if skip_main_function_prologue is "yes".
$ cat gdbexp.patch
Index: gdb/testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.92
diff -u -p -r1.92 gdb.exp
--- gdb/testsuite/lib/gdb.exp 30 Oct 2007 19:23:18 -0000 1.92
+++ gdb/testsuite/lib/gdb.exp 5 Dec 2007 09:13:02 -0000
@@ -29,7 +29,6 @@ if {$tool == ""} {
load_lib libgloss.exp
global GDB
-
if [info exists TOOL_EXECUTABLE] {
set GDB $TOOL_EXECUTABLE;
}
@@ -48,6 +47,16 @@ if ![info exists GDBFLAGS] {
}
verbose "using GDBFLAGS = $GDBFLAGS" 2
+global skip_function_prologue
+if ![info exists skip_function_prologue] {
+ set skip_function_prologue "no"
+}
+global skip_main_function_prologue
+if ![info exists skip_main_function_prologue] {
+ set skip_main_function_prologue "no"
+}
+
+
# The variable gdb_prompt is a regexp which matches the gdb prompt.
# Set it if it is not already set.
global gdb_prompt
@@ -83,6 +92,9 @@ if ![info exists env(EXEEXT)] {
set EXEEXT ""
} else {
set EXEEXT $env(EXEEXT)
+ if ( "$EXEEXT" != "" ) {
+ set skip_main_function_prologue "yes"
+ }
}
### Only procedures should come after this point.
@@ -371,6 +383,7 @@ proc gdb_breakpoint { function args } {
proc runto { function args } {
global gdb_prompt
global decimal
+ global skip_function_prologue
delete_breakpoints
@@ -383,6 +396,23 @@ proc runto { function args } {
# the "at foo.c:36" output we get with -g.
# the "in func" output we get without -g.
gdb_expect 30 {
+ -re "Break.* at .*:$decimal.*\{\[\r\n\]*$gdb_prompt $" {
+ # we are in the function prologue, let's skip it
+ if { "$skip_function_prologue" == "yes" } {
+ verbose "Skipping function prologue for $function"
+ gdb_test "next"
+ }
+ return 2
+ }
+ -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*\{\[\r\n\]*$gdb_prompt
$" {
+ # we are in the function prologue, let's skip it
+ if { "$skip_function_prologue" == "yes" } {
+ verbose "Skipping function prologue for $function"
+ gdb_test "next"
+ }
+ return 2
+ }
+
-re "Break.* at .*:$decimal.*$gdb_prompt $" {
return 1
}
@@ -410,9 +440,15 @@ proc runto { function args } {
proc runto_main { } {
global gdb_prompt
global decimal
+ global skip_function_prologue
+ global skip_main_function_prologue
if ![target_info exists gdb_stub] {
- return [runto main]
+ set saved_skip "$skip_function_prologue"
+ set skip_function_prologue "$skip_main_function_prologue"
+ set res [runto main]
+ set skip_function_prologue "$saved_skip"
+ return $res
}
delete_breakpoints
@@ -725,7 +761,7 @@ proc gdb_test_multiple { command message
}
-re "\r\n$gdb_prompt $" {
if ![string match "" $message] then {
- fail "$message"
+ fail "$message (gdb prompt found alone)"
}
set result 1
}
@@ -1802,6 +1838,7 @@ proc gdb_expect { args } {
}
}
}
+ global verbose;
global suppress_flag;
global remote_suppress_flag;
if [info exists remote_suppress_flag] {
@@ -1814,6 +1851,11 @@ proc gdb_expect { args } {
}
set code [catch \
{uplevel remote_expect host $gtimeout $expcode} string];
+ if $verbose>4 then {
+ send_user "Expcode is \"$expcode\""
+ send_user "Returned string is \"$string\""
+ }
+
if [info exists old_val] {
set remote_suppress_flag $old_val;
} else {