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]

Avoid timeouts in call-sc.exp


The test "call-sc.exp" will attemt to "finish" from main if the prevous 
"return foo" failed.  Here is what happens:

257		gdb_test_multiple "return foo" "${test}" {

If this works, then we are in "main".  If it doesn't work (say, due to a gdb 
bug) then we are left in the function "fun".

334		 gdb_test "advance fun" \

If the "return foo" worked, then this positions us at the start of fun().  If 
it didn't work, then this acts like "finish" and we return from the current 
function.

356		gdb_test_multiple "finish" "${test}" {

if the "return foo" worked, then we just finish fun().  If not, then we are 
attemting to "finish" from main() and the program under test is in an 
infinite loop (due to the way it's coded).

This patch fixes this problem by checking to see if the "return foo" worked or 
not.  If it worked, fine: things are as before.  But if it didn't work, the 
"finish" is skipped.

-=# Paul #=-

PS:  Trying this by hand, the "finish" would complain something like:
"can't 'finish' from the outer most block"
but only if I didn't follow the test case exactly.



Here is the patch:    

diff new/call-sc.exp old/call-sc.exp
334,348c334,336
<     set test "advance to fun for finish; ${tests}"
<     set skip_finish 0
<     gdb_test_multiple "advance fun" "${test}" {
<       -re "fun .*\[\r\n\]+\[0-9\].*return foo.*" {
<           pass "${test}"
<       }
<       -re "in main" {
<           # This happens if the "return foo" failed to actually return:
<           # this "advance fun" will not stop on fun, but just return from
<           # the routine that "return foo" should have.  Then the "finish"
<           # below will try to finish "main", which causes an infinte loop.
<           # So to avoid the timeout, skip the "finish".
<           set skip_finish 1
<       }
<     }
---
>     gdb_test "advance fun" \
>           "fun .*\[\r\n\]+\[0-9\].*return foo.*" \
>           "advance to fun for finish; ${tests}"
357,368c345,352
<     if $skip_finish {
<       fail "${test}"
<     } else {
<       gdb_test_multiple "finish" "${test}" {
<           -re "Value returned is .*${gdb_prompt} $" {
<               pass "${test}"
<           }
<           -re "Cannot determine contents.*${gdb_prompt} $" {
<               # Expected bad value.  For the moment this is ok.
<               set finish_value_unknown 1
<               pass "${test}"
<           }
---
>     gdb_test_multiple "finish" "${test}" {
>       -re "Value returned is .*${gdb_prompt} $" {
>           pass "${test}"
>       }
>       -re "Cannot determine contents.*${gdb_prompt} $" {
>           # Expected bad value.  For the moment this is ok.
>           set finish_value_unknown 1
>           pass "${test}"


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