This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/Linux] Ask kernel to kill inferior when GDB terminates
- From: Pedro Alves <palves at redhat dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 15 Dec 2014 13:22:16 +0000
- Subject: Re: [RFA/Linux] Ask kernel to kill inferior when GDB terminates
- Authentication-results: sourceware.org; auth=none
- References: <1415984034-27122-1-git-send-email-brobecker at adacore dot com> <54663729 dot 6010708 at redhat dot com> <20141114173255 dot GD5774 at adacore dot com> <20141119092547 dot GP5774 at adacore dot com> <546C69D4 dot 5090300 at redhat dot com> <20141213162757 dot GL5457 at adacore dot com>
On 12/13/2014 04:27 PM, Joel Brobecker wrote:
>>>>> I could see this making some sense when GDB has spawned the process,
>>>>> but it seems harsh when GDB has attached to the process instead
>>>>> of spawning it?
> [...]
>>> I will adapt my patch when I have a moment.
>
> Just took a look, and it's not clear to me what the best way to do that
> might me. For native GDB, it'd be fairly easy, if I could just add
> an "attaching_p" parameter to "linux_enable_event_reporting", then
> I could just mask PTRACE_O_EXITKILL out if nonzero. In linux-nat.c,
> it's fairly easy to provide that info. However, things are not so
> clear in the gdbserver case, because linux_enable_event_reporting
> is performed during the event handling conditional on
> child->must_set_ptrace_flags:
>
> if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags)
> {
> linux_enable_event_reporting (lwpid);
> child->must_set_ptrace_flags = 0;
> }
>
> I think the only clean way to do this would be to add another
> field in struct lwp_info such as "attaching_p" which we would
> set to 1 in the attaching case only.
I think we can get by without adding a new field. The process_info
structure has the "process->attached" field already. We could
check that here. Alternatively, must_set_ptrace_flags could be a
tri-state instead of a boolean, which would be cheaper.
>
> Does this seem reasonable?
>
> Thanks,
>
Thanks,
Pedro Alves