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]

Re: [PATCH] Fix for follow-fork: followed child doesn't stop


On 06/05/2014 10:44 PM, Breazeal, Don wrote:
> +proc test_follow_fork { who detach cmd } {
>      global gdb_prompt
> +    global srcfile
> +    global testfile
> 
> -    gdb_test "show follow-fork" \
> -	"Debugger response to a program call of fork or vfork is \"parent\".*" \
> -	"default show parent follow, no catchpoints"
> +    set test_name "follow $who, detach $detach, command \"$cmd\""


Instead of explicitly prepending "$test_name: " to tests,
please use with_test_prefix to make test messages unique.
Below, runto_main, the untested line, this "set verbose", all
these look like they'll print the same message in gdb.sum.

> 
> -    gdb_test "next 2" \
> -	"Detaching after fork from.*" \
> -	"default parent follow, no catchpoints"
> +    # Start a new debugger session each time so defaults are legitimate.
> +    clean_restart $testfile
> 
> -    # The child has been detached; allow time for any output it might
> -    # generate to arrive, so that output doesn't get confused with
> -    # any expected debugger output from a subsequent testpoint.
> -    #
> -    exec sleep 1
> -}
> +    if ![runto_main] {
> +	untested "could not run to main"
> +	return -1
> +    }
> 
> -proc explicit_fork_parent_follow {} {
> -    global gdb_prompt
> +    # The "Detaching..." and "Attaching..." messages may be hidden by
> +    # default.
> +    gdb_test_no_output "set verbose"



> +    # Set up the output we expect to see after we run.
> +    set expected_re ""
> +    if {$who == "child"} {
> +        set expected_re "Attaching after.* fork to.*set breakpoint here.*"
> +    } elseif {$who == "parent" && $detach == "on"} {
> +	set expected_re "Detaching after fork from .*set breakpoint here.*"

Something odd with indentation here.

> +    } else {
> +        set expected_re ".*set breakpoint here.*"
> +    }



> +    # The first two tests should be sufficient to test the defaults.
> +    # There is no need to test using the defaults in other permutations
> +    # (e.g. "default" "on", "parent" "default", etc.).
> +    set cases [list [list "default" "default" "next 2"]   \
> +                    [list "default" "default" "continue"] \
> +                    [list "parent"  "on"      "next 2"]   \
> +                    [list "parent"  "on"      "continue"] \
> +                    [list "child"   "on"      "next 2"]   \
> +                    [list "child"   "on"      "continue"] \
> +                    [list "parent"  "off"     "next 2"]   \
> +                    [list "parent"  "off"     "continue"] \
> +                    [list "child"   "off"     "next 2"]   \
> +                    [list "child"   "off"     "continue"]]
> +    foreach args $cases {
> +        test_follow_fork [lindex $args 0] [lindex $args 1] [lindex $args 2]
> +    }

This is still quite manual.  Please write:

    foreach cmd {"next 2" "continue"} {
      test_follow_fork "default" "default" $cmd
    }

    # Now test all explicit permutations.
    foreach who {"parent" "child"} {
      foreach detach {"on" "off"} {
	foreach cmd {"next 2" "continue"} {
	  test_follow_fork $who $detach $cmd
        }
      }
    }

-- 
Pedro Alves


-- 
Pedro Alves


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