From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102505 invoked by alias); 7 Nov 2017 01:31:25 -0000 Mailing-List: contact gdb-testers-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-testers-owner@sourceware.org Received: (qmail 102198 invoked by uid 89); 7 Nov 2017 01:31:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: kwanyin.sergiodj.net Received: from kwanyin.sergiodj.net (HELO kwanyin.sergiodj.net) (158.69.185.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Nov 2017 01:31:23 +0000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] Simplify child_terminal_inferior From: sergiodj+buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: <556e5da51349d00307bc05b7a6a813f71ac58664@gdb-build> Date: Tue, 07 Nov 2017 01:31:00 -0000 X-SW-Source: 2017-q4/txt/msg04012.txt.bz2 *** TEST RESULTS FOR COMMIT 556e5da51349d00307bc05b7a6a813f71ac58664 *** Author: Pedro Alves Branch: master Commit: 556e5da51349d00307bc05b7a6a813f71ac58664 Simplify child_terminal_inferior The comment about Lynx in child_terminal_init reads a bit odd, since it's not exactly clear what "This" in "This is for Lynx" is referring to. Looking back in history makes it clearer. When the comment was originally added, in commit 91ecc8efa9b9, back in 1994, the code looked like this: ~~~ #ifdef PROCESS_GROUP_TYPE #ifdef PIDGET /* This is for Lynx, and should be cleaned up by having Lynx be a separate debugging target with a version of target_terminal_init_inferior which passes in the process group to a generic routine which does all the work (and the non-threaded child_terminal_init_inferior can just pass in inferior_pid to the same routine). */ inferior_process_group = PIDGET (inferior_pid); #else inferior_process_group = inferior_pid; #endif #endif ~~~ So this looked like it was about when GDB was growing support for multi-threading, and inferior_pid was still a single int for most ports. Eventually we got ptid_t, so the comment isn't really useful today. Particularly more so since we no longer support Lynx as a GDB host. The only caller left of child_terminal_init_with_pgrp is gnu-nat.c (the Hurd), and that target uses fork-child, so when we reach gnu_terminal_init after spawning a new child, the current inferior must already have the PID set, and the child must be a process group leader. We can't add a 'getpgid(inf->pid) == inf->pid' assertion to child_terminal_init though (like a previous version of this patch was doing [1]), because child_terminal_init is also reached after attaching to a process. If we did, the new gdb.base/attach-non-pgrp-leader.exp test would fail, with: (gdb) attach 12415 Attaching to program: build/gdb/testsuite/outputs/gdb.base/attach-non-pgrp-leader/attach-non-pgrp-leader, process 12415 src/gdb/inflow.c:180: internal-error: void child_terminal_init(target_ops*): Assertion `getpgid (inf->pid) == inf->pid' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) FAIL: gdb.base/attach-non-pgrp-leader.exp: child: attach to child (GDB internal error) I'm not making GDB save the pgid for attached processes with getpgid for now, because the saved process group affects other things which I'm leaving for following patches, like e.g., the "interrupt" command. [1] - https://sourceware.org/ml/gdb-patches/2017-11/msg00039.html gdb/ChangeLog: 2017-11-06 Pedro Alves * gnu-nat.c (gnu_terminal_init): Delete. (gnu_target): Don't install gnu_terminal_init. * inflow.c (child_terminal_init_with_pgrp): Delete, merged with ... (child_terminal_init): ... this function.