From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 30206385841E for ; Thu, 22 Jun 2023 13:17:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30206385841E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687439872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tv3Wc1AbmFSzSvpg8kjCjc291kGUhuqD1Xt3d6w/NMk=; b=MR6KssOItiAp3LlRyJGTAPVb1mV8d1ErP8oT9Nfi+8jouk9an8mua68GDrk9vzX2Jo2aOf 5L1yUgf4oQfIO1saqGL452QpwGTZbYsmX4up6UU1MdZMLcUGMKM5rd5qDqioL/gOrsvpaY sl5E8fsDNco8uJ6Poqd4h9nuH1xj5MM= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-XI8E6mL4M4uNS4xOoPOefg-1; Thu, 22 Jun 2023 09:17:50 -0400 X-MC-Unique: XI8E6mL4M4uNS4xOoPOefg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3127d83b31cso1518154f8f.1 for ; Thu, 22 Jun 2023 06:17:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687439869; x=1690031869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tv3Wc1AbmFSzSvpg8kjCjc291kGUhuqD1Xt3d6w/NMk=; b=Loj8n/g/PGlsDtl22el+XU+qbZIIwiOTDT/f++Z50nWOkT6bI6W8TzJUxE5BaKZPJR 8P8Cn29uQo0kcbieRO8yOKB1DnIffnyvCW20EZc4ELoJDSlOeMMM/TBCnjW7PN4r2nL5 /Mrh6NAGLc6vWPA+gn3AcUBiSXmSvy3JtHxPPtylsfq46xISN8v3RcnaV5WX5zxsGrt+ +OdSkDV5YTPjFJfkLD1m3vxFnWWm/CcDeD94sSrc4zFO0W3DgBz8KnFjiXq5Xh4+2GyZ CM3Hz6yE89YoioX/7uzB2H3mi4YR1OOmGM3fCxNyz7HpV2UTCV+nIwCQJ+HlKHzKZ/tZ BSHw== X-Gm-Message-State: AC+VfDwMljJcsZleh0i6AvSJ/YpxScJb47J440PM/koZyhSADM32A/ba 11Uek0L+g6YelAd05YWWN6bQiEc1KCPARUHUQ5lyYO9dCpjQ7hb8cEPr6ynBc5SnT4HMbMtpwTB WKkICsU8PQXtMZy43Fjud10K62MA8IJZKEqRyONt9Kwm5wALfHdsbTeLY12cdlQ5tLO+IgVKPp1 i7NGxgxg== X-Received: by 2002:a5d:40ca:0:b0:311:df7:a23 with SMTP id b10-20020a5d40ca000000b003110df70a23mr12656705wrq.59.1687439869418; Thu, 22 Jun 2023 06:17:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5pv3B/D3OtKsCozUYEdCPgmmSu1d7UhjYGwEJOPgocxcocYSJ81GCPYzdAydtg2lzT08SWLg== X-Received: by 2002:a5d:40ca:0:b0:311:df7:a23 with SMTP id b10-20020a5d40ca000000b003110df70a23mr12656687wrq.59.1687439869011; Thu, 22 Jun 2023 06:17:49 -0700 (PDT) Received: from localhost (2.72.115.87.dyn.plus.net. [87.115.72.2]) by smtp.gmail.com with ESMTPSA id k18-20020adfe8d2000000b0030ae3a6be4asm7157929wrn.72.2023.06.22.06.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 06:17:48 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 8/8] gdb: additional debug output in infrun.c and linux-nat.c Date: Thu, 22 Jun 2023 14:17:28 +0100 Message-Id: <0009534eb6886581049bb25fbed98589334368b9.1687438786.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: While working on some of the recent patches relating to vfork handling I found this debug output very helpful, I'd like to propose adding this into GDB. With debug turned off there should be no user visible changes after this commit. --- gdb/infrun.c | 26 ++++++++++++++++++++++---- gdb/linux-nat.c | 23 +++++++++++++++++++---- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 3eb3b290001..52de4920661 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -435,6 +435,11 @@ show_follow_fork_mode_string (struct ui_file *file, int from_tty, static bool follow_fork_inferior (bool follow_child, bool detach_fork) { + INFRUN_SCOPED_DEBUG_ENTER_EXIT; + + infrun_debug_printf ("follow_child = %d, detach_fork = %d", + follow_child, detach_fork); + target_waitkind fork_kind = inferior_thread ()->pending_follow.kind (); gdb_assert (fork_kind == TARGET_WAITKIND_FORKED || fork_kind == TARGET_WAITKIND_VFORKED); @@ -543,6 +548,13 @@ holding the child stopped. Try \"set detach-on-fork\" or \ parent_inf->thread_waiting_for_vfork_done = detach_fork ? inferior_thread () : nullptr; parent_inf->pspace->breakpoints_not_allowed = detach_fork; + + infrun_debug_printf + ("parent_inf->thread_waiting_for_vfork_done == %s", + (parent_inf->thread_waiting_for_vfork_done == nullptr + ? "nullptr" + : (parent_inf->thread_waiting_for_vfork_done + ->ptid.to_string ().c_str ()))); } } else @@ -727,6 +739,8 @@ set_last_target_status_stopped (thread_info *tp) static bool follow_fork () { + INFRUN_SCOPED_DEBUG_ENTER_EXIT; + bool follow_child = (follow_fork_mode_string == follow_fork_mode_child); bool should_resume = true; @@ -996,6 +1010,8 @@ proceed_after_vfork_done (thread_info *thread) static void handle_vfork_child_exec_or_exit (int exec) { + INFRUN_SCOPED_DEBUG_ENTER_EXIT; + struct inferior *inf = current_inferior (); if (inf->vfork_parent) @@ -1127,6 +1143,8 @@ handle_vfork_child_exec_or_exit (int exec) static void handle_vfork_done (thread_info *event_thread) { + INFRUN_SCOPED_DEBUG_ENTER_EXIT; + /* We only care about this event if inferior::thread_waiting_for_vfork_done is set, that is if we are waiting for a vfork child not under our control (because we detached it) to exec or exit. @@ -1142,8 +1160,6 @@ handle_vfork_done (thread_info *event_thread) return; } - INFRUN_SCOPED_DEBUG_ENTER_EXIT; - /* We stopped all threads (other than the vforking thread) of the inferior in follow_fork and kept them stopped until now. It should therefore not be possible for another thread to have reported a vfork during that window. @@ -3456,8 +3472,10 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) if (!cur_thr->control.in_infcall) set_running (resume_target, resume_ptid, true); - infrun_debug_printf ("addr=%s, signal=%s", paddress (gdbarch, addr), - gdb_signal_to_symbol_string (siggnal)); + infrun_debug_printf ("addr=%s, signal=%s, resume_ptid=%s", + paddress (gdbarch, addr), + gdb_signal_to_symbol_string (siggnal), + resume_ptid.to_string ().c_str ()); annotate_starting (); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 7e121b7ab41..87152621dd6 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1293,6 +1293,11 @@ get_detach_signal (struct lwp_info *lp) static void detach_one_lwp (struct lwp_info *lp, int *signo_p) { + LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT; + + linux_nat_debug_printf ("lwp %s (stopped = %d)", + lp->ptid.to_string ().c_str (), lp->stopped); + int lwpid = lp->ptid.lwp (); int signo; @@ -1363,6 +1368,10 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p) else signo = *signo_p; + linux_nat_debug_printf ("preparing to resume lwp %s (stopped = %d)", + lp->ptid.to_string ().c_str (), + lp->stopped); + /* Preparing to resume may try to write registers, and fail if the lwp is zombie. If that happens, ignore the error. We'll handle it below, when detach fails with ESRCH. */ @@ -1395,6 +1404,8 @@ detach_callback (struct lwp_info *lp) void linux_nat_target::detach (inferior *inf, int from_tty) { + LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT; + struct lwp_info *main_lwp; int pid = inf->pid; @@ -3122,13 +3133,13 @@ static ptid_t linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, target_wait_flags target_options) { + LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT; + sigset_t prev_mask; enum resume_kind last_resume_kind; struct lwp_info *lp; int status; - linux_nat_debug_printf ("enter"); - /* The first time we get here after starting a new inferior, we may not have added it to the LWP list yet - this is the earliest moment at which we know its PID. */ @@ -3228,7 +3239,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, if (target_options & TARGET_WNOHANG) { - linux_nat_debug_printf ("exit (ignore)"); + linux_nat_debug_printf ("no interesting events found"); ourstatus->set_ignore (); restore_child_signals_mask (&prev_mask); @@ -3314,7 +3325,7 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, else *ourstatus = host_status_to_waitstatus (status); - linux_nat_debug_printf ("exit"); + linux_nat_debug_printf ("event found"); restore_child_signals_mask (&prev_mask); @@ -3410,6 +3421,8 @@ ptid_t linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, target_wait_flags target_options) { + LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT; + ptid_t event_ptid; linux_nat_debug_printf ("[%s], [%s]", ptid.to_string ().c_str (), @@ -3589,6 +3602,8 @@ linux_nat_target::kill () void linux_nat_target::mourn_inferior () { + LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT; + int pid = inferior_ptid.pid (); purge_lwp_list (pid); -- 2.25.4