From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.CeBiTec.Uni-Bielefeld.DE (smtp.CeBiTec.Uni-Bielefeld.DE [129.70.160.84]) by sourceware.org (Postfix) with ESMTPS id E99F8383E832 for ; Sun, 21 Jun 2020 16:37:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E99F8383E832 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=CeBiTec.Uni-Bielefeld.DE Authentication-Results: sourceware.org; spf=none smtp.mailfrom=ro@cebitec.uni-bielefeld.de Received: from localhost (localhost [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id B610786DE3; Sun, 21 Jun 2020 18:37:23 +0200 (CEST) X-Virus-Scanned: amavisd-new at CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (smtp.cebitec.uni-bielefeld.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bsytxiYGl_js; Sun, 21 Jun 2020 18:37:22 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (p4fddbb33.dip0.t-ipconnect.de [79.221.187.51]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPSA id 3FCBF89ADB; Sun, 21 Jun 2020 18:37:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=CeBiTec.Uni-Bielefeld.DE; s=20200306; t=1592757442; bh=Y47aAq2fMUtj+59kOFVNObM2FCZDcOAlErKlvrOuTUc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=XdbE0iCLw4938oANDp2zv5tYkmFgG6aWCuK8QO1RCfx8+kl/jVpi3JsDa86+lqAdT hBe1rxY0WHlHNARBioBXMp+/SvIXpZoYBZVPdZne1BFp/Hi4s162Uim1D/faD1IDFE JNDKpUUsxUWa243P4cFbx0RMwpFvjb82XVv/uvgSXERPs6eiUMUqmUg5wdC9YvfAZQ sA93BL+AXyWLZPqxoYXY+Iuebc+h8R9a0MO7IGrSBwO9pYXqZwWtvEkQBgNH65r+uD s8BLp1VdtxpwYcClmtzfaLxf01kcAyFy7CYdPHTWfQukTtSEv6qUuZmc3xJ02pMmr1 mbOW6rj60D30A== From: Rainer Orth To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: [COMMITTED PATCH][PR gdb/25939] Move push_target call earlier in procfs.c References: <7fb790ae-61a9-a6a3-3b87-74fcac400664@redhat.com> <0e3e81a9-a5de-42bc-7d58-094f2adca164@redhat.com> Date: Sun, 21 Jun 2020 18:37:14 +0200 In-Reply-To: (Pedro Alves's message of "Fri, 19 Jun 2020 14:55:25 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (usg-unix-v) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Status: No, score=-3796.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jun 2020 16:37:27 -0000 --=-=-= Content-Type: text/plain Hi Pedro, > On 6/19/20 1:36 PM, Rainer Orth wrote: >>> On 6/18/20 3:55 PM, Pedro Alves via Gdb-patches wrote: > >>> Your push_target fix is still necessary, FAOD. >> >> Should I push it as is (with an appropriate description, of course) or >> would the code change need a comment, too? > > It's fine without a comment. I think you can remove the > push_target call from procfs_init_inferior at the same time, > too, as that one becomes unnecessary. Basically make the fix be > about moving the push_target call earlier. that works just fine. Here's what I've committed after testing both pathes together on amd64-pc-solaris2.11. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University [PR gdb/25939] Move push_target call earlier in procfs.c Since the multi-target patch, the run command fails on Solaris with an assertion failure even for a trivial program: $ ./gdb -D ./data-directory ./hello GNU gdb (GDB) 10.0.50.20200106-git [...] Reading symbols from ./hello... (gdb) run Starting program: /vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:336: internal-error: thread_info::thread_info(inferior*, ptid_t): Assertion `inf_ != NULL' failed. Here's the start of the corresponding stack trace: #0 internal_error ( file=file@entry=0x966150 "/vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c", line=line@entry=336, fmt=0x9ddb94 "%s: Assertion `%s' failed.") at /vol/src/gnu/gdb/hg/master/reghunt/gdb/gdbsupport/errors.c:51 #1 0x0000000000ef81f4 in thread_info::thread_info (this=0x1212020, inf_=, ptid_=...) at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:344 #2 0x0000000000ef82cd in new_thread (inf=inf@entry=0x0, ptid=...) at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:239 #3 0x0000000000efac3c in add_thread_silent ( targ=targ@entry=0x11b0940 , ptid=...) at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:304 #4 0x0000000000d90692 in procfs_target::create_inferior ( this=0x11b0940 , exec_file=0x13dbef0 "/vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello", allargs="", env=0x13c48f0, from_tty=) at /vol/src/gnu/gdb/hg/master/reghunt/gdb/gdbsupport/ptid.h:47 #5 0x0000000000c84e64 in run_command_1 (args=, from_tty=1, run_how=run_how@entry=RUN_NORMAL) at /vol/gcc-9/include/c++/9.1.0/bits/basic_string.h:263 #6 0x0000000000c85007 in run_command (args=, from_tty=) at /vol/src/gnu/gdb/hg/master/reghunt/gdb/infcmd.c:687 Looking closer, I found that in add_thread_silent as called from procfs.c (procfs_target::create_inferior) find_inferior_ptid returns NULL. The all_inferiors (targ) iterator comes up empty. Going from there, I see that in add_thread_silent m_target_stack = {m_top = file_stratum, m_stack = {0x20190e0 , 0x200b8c0 , 0x0, 0x0, 0x0, 0x0, 0x0}}} i.e. the_procfs_target is missing compared to the_amd64_linux_nat_target on Linux/x86_64. Moving the push_target call earlier allows debugging to get over the initial assertion failure. I run instead into procfs: couldn't find pid 0 in procinfo list. which is fixed by https://sourceware.org/pipermail/gdb-patches/2020-June/169674.html Both patches tested together on amd64-pc-solaris2.11. PR gdb/25939 * procfs.c (procfs_target::procfs_init_inferior): Move push_target call ... (procfs_target::create_inferior): ... here. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=sol2-procfs-push_target.patch # HG changeset patch # Parent 34403039561e7d3e10eb37561e6b574370a182d5 Move push_target call earlier in procfs.c [PR25939] diff --git a/gdb/procfs.c b/gdb/procfs.c --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2781,11 +2781,6 @@ procfs_target::procfs_init_inferior (int int fail; int lwpid; - /* This routine called on the parent side (GDB side) - after GDB forks the inferior. */ - if (!target_is_pushed (this)) - push_target (this); - pi = create_procinfo (pid, 0); if (pi == NULL) perror (_("procfs: out of memory in 'init_inferior'")); @@ -3006,6 +3001,9 @@ procfs_target::create_inferior (const ch shell_file = tryname; } + if (!target_is_pushed (this)) + push_target (this); + pid = fork_inferior (exec_file, allargs, env, procfs_set_exec_trap, NULL, NULL, shell_file, NULL); --=-=-=--