Re: [PATCH 04/12] Delete reinsert breakpoints from forked child

Pedro Alves
2016-06-14T11:40:22Z

On 06/14/2016 12:16 PM, Yao Qi wrote:

>> >
>>> >> I think
>>> >> they've already covered by gdb.base/step-over-syscall.exp.
>> >
>> > In that case, shouldn't we be extending that test instead?
> OK, I extend step-over-syscall.exp by setting different
> combinations of follow-fork and detach-on-fork modes, and it still can
> trigger GDBserver internal errors. How about the patch below?

Fine with me. One suggestion below.

> + foreach_with_prefix detach-on-fork {"on" "off"} {
> + foreach_with_prefix follow-fork {"parent" "child"} {
> + foreach syscall { "fork" "vfork" "clone" } {
> +
> + if { $syscall != "vfork"
> + || ${follow-fork} != "parent"
> + || ${detach-on-fork} != "off" } {
> + # Both vforked child process and parent process are
> + # under GDB's control, but GDB follows the parent
> + # process only, which can't be run until vforked child
> + # finishes. Skip the test in this scenario.
> + break_cond_on_syscall $syscall ${follow-fork} ${detach-on-fork}
> + }

I'd suggest reversing the condition logic, making it match the
comment, like this:

if { $syscall == "vfork"
&& ${follow-fork} == "parent"
&& ${detach-on-fork} == "off" } {
# Both vforked child process and parent process are
# under GDB's control, but GDB follows the parent
# process only, which can't be run until vforked child
# finishes. Skip the test in this scenario.
continue
}

break_cond_on_syscall $syscall ${follow-fork} ${detach-on-fork}

This way makes it easier to add more "skip" conditions in the future too. E.g.,

if { $syscall == "vfork"
&& ${follow-fork} == "parent"
&& ${detach-on-fork} == "off" } {
# Both vforked child process and parent process are
# under GDB's control, but GDB follows the parent
# process only, which can't be run until vforked child
# finishes. Skip the test in this scenario.
continue
}

+ if { $syscall == "whatnot"
+ && ${follow-fork} == "parent"} {
+ # For whatever reason, this shouldn't be tested either.
+ continue
+ }

break_cond_on_syscall $syscall ${follow-fork} ${detach-on-fork}

> + }
> + }
> + }
> }

Thanks,
Pedro Alves