From patchwork Thu Oct 6 17:23:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 58484 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B20B1384D146 for ; Thu, 6 Oct 2022 17:24:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B20B1384D146 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665077058; bh=xt6MY62zPKtaspDnKw7rn+mJPJNTruXZEZQ44eC6xsA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DgBnY+m01KAaQPbpjgWM+2RIIjHQJa3SSBCGFdp8HaimhS2Pdz0G3YX0/DRNn/RbN vSqWeOO7on3mXj5/41cNWcDbfivZS9vZvodditiN2F2pX3Uw4u4YHYGO4rugbd5KqE ovYi3raracBWoTitVQHRcCOHztvVxmLubMmZBufE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 C81B9384D16A for ; Thu, 6 Oct 2022 17:23:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C81B9384D16A Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-563-G05ynfh9OQSHpmfSgTKAow-1; Thu, 06 Oct 2022 13:23:53 -0400 X-MC-Unique: G05ynfh9OQSHpmfSgTKAow-1 Received: by mail-wm1-f71.google.com with SMTP id g8-20020a05600c4ec800b003b4bcbdb63cso1330530wmq.7 for ; Thu, 06 Oct 2022 10:23:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=xt6MY62zPKtaspDnKw7rn+mJPJNTruXZEZQ44eC6xsA=; b=hC/gC1KxQXos17U4NlaMrFF7U7rJq3jJetIYy6Yx1vX7e7RYzkhLAg9nOi1B+WGuF1 60ld1s8tWRlrsYvSaagOwztBix0TCb3P7DAH9BKy5uBdPjlAB2Z9cFVSwEmYfTnrzKlB tsoYK6L89ogGtDAFGlBgEdDKMyn/lEXax5vR+keULXzC07LHp1slXgD/tax6pEJFgYjj ijc7wMgXpRQlkdMG4FgoulY6iANL2VBMxjfGbGPW4VQPQMuwoeGa8BlMIJlUIkYFQZqW EW19jkt2D+tEJGPrjHBOe598AgKlzER/TSwCTWSEn+5NoqUs62pcVhVbQehD0hz9u68u iUcQ== X-Gm-Message-State: ACrzQf04rehxkFRqvV8YaeND3mUfWXU1UpFza80QFT3wDnOPUnwkOe5j LPVPqYAvF6BYDCms5lZau218VOB0WmstXt0e30L9mkOmnxOulK+acrKYQi1ck5jWWg3+rPUXGk+ jh003fg1ktvAHGK38abZRYe5DdQsUdBdykdjPCZsbxY+LKPGd34P3fk2lH49z0aJtGQGjN6Nc7g == X-Received: by 2002:a05:6000:144c:b0:22b:dda:eeb0 with SMTP id v12-20020a056000144c00b0022b0ddaeeb0mr695063wrx.335.1665077031633; Thu, 06 Oct 2022 10:23:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5pUUhdoXjeloMfFAX5+NuIE5NzKK427neddRQEr2dS/HL/g8OwwfqjpEjggkIt2fju35h9tQ== X-Received: by 2002:a05:6000:144c:b0:22b:dda:eeb0 with SMTP id v12-20020a056000144c00b0022b0ddaeeb0mr695052wrx.335.1665077031411; Thu, 06 Oct 2022 10:23:51 -0700 (PDT) Received: from localhost (92.40.178.145.threembb.co.uk. [92.40.178.145]) by smtp.gmail.com with ESMTPSA id b1-20020a5d45c1000000b0022ac119fcc5sm18257089wrs.60.2022.10.06.10.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 10:23:51 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 1/3] gdb: improve infrun_debug_show_threads output Date: Thu, 6 Oct 2022 18:23:43 +0100 Message-Id: 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 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This commit switches to use INFRUN_SCOPED_DEBUG_START_END in the infrun_debug_show_threads function, which means the output will get an extra level of indentation, this looks a little nicer I think. --- gdb/infrun.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdb/infrun.h b/gdb/infrun.h index 0c7c55eabec..226cb3c3e34 100644 --- a/gdb/infrun.h +++ b/gdb/infrun.h @@ -62,6 +62,8 @@ infrun_debug_show_threads (const char *title, ThreadRange threads) { if (debug_infrun) { + INFRUN_SCOPED_DEBUG_ENTER_EXIT; + infrun_debug_printf ("%s:", title); for (thread_info *thread : threads) infrun_debug_printf (" thread %s, executing = %d, resumed = %d, " From patchwork Thu Oct 6 17:23:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 58485 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 98DF838A284F for ; Thu, 6 Oct 2022 17:24:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98DF838A284F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665077062; bh=PS/EeyIsl5B1csZubONdZK1+FGMetfpfKL88W50Z3oM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ksP2C5YJcGGX9rK8QHbEj+MF6l3RBDNypC8yYeJrXhnJLnd+R3FN5NMcoa1tXGjMZ YbSOW2/7Mj1RqDDBMOeAEJ3xsOF9gY24KeOMUez6t1gcky6JonQ8pIerA5BR8j4SsW t7IZ+4ovIcD4YEonbtfUtIGwaMp2sBopEFz+Jt0k= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 324023846477 for ; Thu, 6 Oct 2022 17:23:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 324023846477 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-546-BchDLAPPMH29Z2fFSXm86Q-1; Thu, 06 Oct 2022 13:23:55 -0400 X-MC-Unique: BchDLAPPMH29Z2fFSXm86Q-1 Received: by mail-wm1-f71.google.com with SMTP id o18-20020a05600c339200b003bf24961658so1332804wmp.6 for ; Thu, 06 Oct 2022 10:23:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PS/EeyIsl5B1csZubONdZK1+FGMetfpfKL88W50Z3oM=; b=GBTQoc8rN7SG1sVpqa1YQxqGuuVon9jkI5V1rzuZjJf0Wp693xfaYKABH8rG9fNhJb Ka285xXi8OoH9rElXPy8C/UXCAXQf67D79CD3zgzHOu263NPL+QB4fRFJ9pFuR8VTLo/ T9/IkOq98t2BHcLWYjnfRxHvNohx19I+SoAlnufYVLlLfHXW3RHxIWqJs2qGGwaPYKrx shgXGp8pYO96bAhZBAED9KPKa1l5HwBn+HcJqRA1XXEf6QFEcdQIauH1QQ50ERLOfty+ Y4RCkI+zEMymj5EZbEgx2z9WKcsR5YUTfdwnCCp23R1zaOVaIhmPlJSq68yPKG7r26LR KfiQ== X-Gm-Message-State: ACrzQf1vjuzQLgzc/IJ0l14vZKUFeNlCWOh+OENqPOQgy588X5Wpzhl1 OnKtp1XR8WrcJPF7RzeUS+ZxAjNJBABD7kDuHWcMqI0yGraDJCWnZP2qfQf3Yg3Seh3somtaEIK jhpo8906xaqa7ir5bxHb3uaypusYYnZQId2Z4zELdyzADefc5zYpqzADP4NNjTOLEHbfC1ukybQ == X-Received: by 2002:a5d:6446:0:b0:22c:df37:4d76 with SMTP id d6-20020a5d6446000000b0022cdf374d76mr673364wrw.247.1665077033868; Thu, 06 Oct 2022 10:23:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CyS97QJTCXs1q4PdRTIc1iWL3zToAXYNCWevFY4Kda2uTFKa7AzVv8Km1ec3+BefWCbhRlQ== X-Received: by 2002:a5d:6446:0:b0:22c:df37:4d76 with SMTP id d6-20020a5d6446000000b0022cdf374d76mr673353wrw.247.1665077033620; Thu, 06 Oct 2022 10:23:53 -0700 (PDT) Received: from localhost (92.40.178.145.threembb.co.uk. [92.40.178.145]) by smtp.gmail.com with ESMTPSA id z15-20020adfdf8f000000b0022cc895cc11sm18053736wrl.104.2022.10.06.10.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 10:23:53 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 2/3] gdb: extra debug output in thread.c Date: Thu, 6 Oct 2022 18:23:44 +0100 Message-Id: <7c6aea7043ed6eabf93015f215edf6636f565934.1665076921.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 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add some extra 'threads' debug in a couple of places in thread.c. I've also added an additional gdb_assert in one case. --- gdb/thread.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdb/thread.c b/gdb/thread.c index 378c5ee2d13..349fc01dd48 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -834,6 +834,10 @@ set_running_thread (struct thread_info *tp, bool running) started = true; tp->state = running ? THREAD_RUNNING : THREAD_STOPPED; + threads_debug_printf ("thread: %s, running? %d%s", + tp->ptid.to_string ().c_str (), running, + (started ? " (started" : "")); + if (!running) { /* If the thread is now marked stopped, remove it from @@ -1298,6 +1302,9 @@ info_threads_command_completer (struct cmd_list_element *ignore, void switch_to_thread_no_regs (struct thread_info *thread) { + gdb_assert (thread != nullptr); + threads_debug_printf ("thread = %s", thread->ptid.to_string ().c_str ()); + struct inferior *inf = thread->inf; set_current_program_space (inf->pspace); @@ -1315,6 +1322,8 @@ switch_to_no_thread () if (current_thread_ == nullptr) return; + threads_debug_printf ("thread = NONE"); + current_thread_ = nullptr; inferior_ptid = null_ptid; reinit_frame_cache (); From patchwork Thu Oct 6 17:23:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 58486 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EEFDD389838D for ; Thu, 6 Oct 2022 17:24:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEFDD389838D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665077083; bh=uI0mxT8mw5lk+II6N8knC1hLfe3jjDmxiU8Tq5gvXMU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=d28ggn/hO0qNOnKUdffL6HGVCs8b6gkV+ujeWcElx0MJ64xNIzpvMR9YhaIK15a6p PsSOizSfRkWp5wkdjtrH3kivvhT75FRlvysfJCT2kQhfoomHbIpBfOZdyWgYXxOIYy DwmR54ArD7xWi1FDfsFUcg5SvRb0esSGKDTWDKHQ= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 92C8B384B82E for ; Thu, 6 Oct 2022 17:23:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 92C8B384B82E Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-609-Xk12buPSPi23yPuT3hqMIw-1; Thu, 06 Oct 2022 13:23:57 -0400 X-MC-Unique: Xk12buPSPi23yPuT3hqMIw-1 Received: by mail-wr1-f69.google.com with SMTP id f9-20020adfc989000000b0022b3bbc7a7eso748569wrh.13 for ; Thu, 06 Oct 2022 10:23:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=uI0mxT8mw5lk+II6N8knC1hLfe3jjDmxiU8Tq5gvXMU=; b=L/6QXU2eaTHZP/j5naHLnKp3zKFvofcmq5n3F3bUrJgdCCjW7N02e1QEmLV+9e775a WoBZQWs3gz4xZVFcgEijrPPD8n4mLRTBNkeSLFAQV7LkxihFE1V38Z1we8xJ/Q5AvN81 q9d3fi2UZLQeOXAeerSUbBi63xnzRqFBqKUQhDbtyhHZbVALjXY467kzzLwJz0uWw48c PVStElF7f4AY+vu5yTGA+WokSKIYvXMvfxf50HRJN68o8bIvQOdtxL6ICv1mCUr1vrEn WpgWwJ54JSOfH/oOwnMIPhxxmPG5ZX95AJtMr5g9fVaI9nBpVt7d4IdkkXTOSsHsGZu5 UoKw== X-Gm-Message-State: ACrzQf0UJ9k/Yg4kRdmBxKDWEeiGXUT6IkljwPj0dKoCbqpZyT3t/uTk dlqSA5OHjVezT5957bbsso8ScRJ8e3wnCBTa00HH8s8XSH/TAfGfvfUI0xM4AjTZ4GmEK6FAlW1 zD8rMDiQQ1l33l0SZGcY5JOgd66iGHdWVIVbkLdefNXRVWv5aL+wPUe4oEagoip2ue+wsPDJnPQ == X-Received: by 2002:a5d:6508:0:b0:22e:1af4:57f9 with SMTP id x8-20020a5d6508000000b0022e1af457f9mr660754wru.539.1665077035720; Thu, 06 Oct 2022 10:23:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41Fm8mnFMWomYIYFMjU8DQr/KkVgxaJTFF3LPB5f5iNsbAgYYloAxYwcDEZIcS94oes1TaHg== X-Received: by 2002:a5d:6508:0:b0:22e:1af4:57f9 with SMTP id x8-20020a5d6508000000b0022e1af457f9mr660742wru.539.1665077035369; Thu, 06 Oct 2022 10:23:55 -0700 (PDT) Received: from localhost (92.40.178.145.threembb.co.uk. [92.40.178.145]) by smtp.gmail.com with ESMTPSA id h14-20020a056000000e00b0022e6da05e43sm2097076wrx.89.2022.10.06.10.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 10:23:55 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 3/3] gdb: add infcall specific debugging Date: Thu, 6 Oct 2022 18:23:45 +0100 Message-Id: <9871275a989ff2c262ea9c94e3172c7eabfe7957.1665076921.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 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add two new commands: set debug infcall on|off show debug infcall These enable some new debugging related to when GDB makes inferior function calls. I've added some basic debugging for what I think are the major steps in the inferior function call process, but I'm sure we might want to add more later. --- gdb/NEWS | 4 +++ gdb/doc/gdb.texinfo | 7 +++++ gdb/infcall.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 796a4ef8072..8b519a648f7 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -111,6 +111,10 @@ maintenance print frame-id [ LEVEL ] Print GDB's internal frame-id for the frame at LEVEL. If LEVEL is not given, then print the frame-id for the currently selected frame. +set debug infcall on|off +show debug infcall + Print additional debug messages about inferior function calls. + * Changed commands document user-defined diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 44d87e95748..e04c053c7bc 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -27587,6 +27587,13 @@ @item show debug infrun Displays the current state of @value{GDBN} inferior debugging. +@item set debug infcall +@cindex inferior function call debugging info +Turns on or off display of debugging info related to when @value{GDBN} +makes inferior function calls. +@item show debug infcall +Displays the current state of @value{GDBN} inferior function call debugging. + @item set debug jit @cindex just-in-time compilation, debugging messages Turn on or off debugging messages from JIT debug support. diff --git a/gdb/infcall.c b/gdb/infcall.c index 34852191043..8e12a119c15 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -44,6 +44,34 @@ #include "gdbsupport/scope-exit.h" #include +/* True if we are debugging inferior calls. */ + +static bool debug_infcall = false; + +/* Print an "infcall" debug statement. */ + +#define infcall_debug_printf(fmt, ...) \ + debug_prefixed_printf_cond (debug_infcall, "infcall", fmt, ##__VA_ARGS__) + +/* Print "infcall" enter/exit debug statements. */ + +#define INFCALL_SCOPED_DEBUG_ENTER_EXIT \ + scoped_debug_enter_exit (debug_infcall, "infcall") + +/* Print "infcall" start/end debug statements. */ + +#define INFCALL_SCOPED_DEBUG_START_END(fmt, ...) \ + scoped_debug_start_end (debug_infrun, "infcall", fmt, ##__VA_ARGS__) + +/* Implement 'show debug infcall'. */ + +static void +show_debug_infcall (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + gdb_printf (file, _("Inferior call debugging is %s.\n"), value); +} + /* If we can't find a function's name from its address, we print this instead. */ #define RAW_FUNCTION_ADDRESS_FORMAT "at 0x%s" @@ -529,6 +557,8 @@ call_thread_fsm::call_thread_fsm (struct ui *waiting_ui, bool call_thread_fsm::should_stop (struct thread_info *thread) { + INFCALL_SCOPED_DEBUG_ENTER_EXIT; + if (stop_stack_dummy == STOP_STACK_DUMMY) { /* Done. */ @@ -577,10 +607,17 @@ static struct gdb_exception run_inferior_call (std::unique_ptr sm, struct thread_info *call_thread, CORE_ADDR real_pc) { + INFCALL_SCOPED_DEBUG_ENTER_EXIT; + struct gdb_exception caught_error; ptid_t call_thread_ptid = call_thread->ptid; int was_running = call_thread->state == THREAD_RUNNING; + infcall_debug_printf ("call function at %s in thread %s, was_running = %d", + core_addr_to_string (real_pc), + call_thread_ptid.to_string ().c_str (), + was_running); + current_ui->unregister_file_handler (); scoped_restore restore_in_infcall @@ -610,15 +647,25 @@ run_inferior_call (std::unique_ptr sm, proceed (real_pc, GDB_SIGNAL_0); + infrun_debug_show_threads ("non-exited threads after proceed for inferior-call", + all_non_exited_threads ()); + /* Inferior function calls are always synchronous, even if the target supports asynchronous execution. */ wait_sync_command_done (); + + infcall_debug_printf ("inferior call completed successfully"); } catch (gdb_exception &e) { + infcall_debug_printf ("exception while making inferior call (%d): %s", + e.reason, e.what ()); caught_error = std::move (e); } + infcall_debug_printf ("thread is now: %s", + inferior_ptid.to_string ().c_str ()); + /* If GDB has the prompt blocked before, then ensure that it remains so. normal_stop calls async_enable_stdin, so reset the prompt state again here. In other cases, stdin will be re-enabled by @@ -764,6 +811,8 @@ call_function_by_hand_dummy (struct value *function, dummy_frame_dtor_ftype *dummy_dtor, void *dummy_dtor_data) { + INFCALL_SCOPED_DEBUG_ENTER_EXIT; + CORE_ADDR sp; struct type *target_values_type; function_call_return_method return_method = return_method_normal; @@ -830,6 +879,9 @@ call_function_by_hand_dummy (struct value *function, if (args.size () < ftype->num_fields ()) error (_("Too few arguments in function call.")); + infcall_debug_printf ("calling %s", get_function_name (funaddr, name_buf, + sizeof (name_buf))); + /* A holder for the inferior status. This is only needed while we're preparing the inferior function call. */ infcall_control_state_up inf_status (save_infcall_control_state ()); @@ -1276,6 +1328,12 @@ call_function_by_hand_dummy (struct value *function, e = run_inferior_call (std::move (sm_up), call_thread.get (), real_pc); } + if (e.reason < 0) + infcall_debug_printf ("after inferior call, exception (%d): %s", + e.reason, e.what ()); + infcall_debug_printf ("after inferior call, thread state is: %s", + thread_state_string (call_thread->state)); + gdb::observers::inferior_call_post.notify (call_thread_ptid, funaddr); if (call_thread->state != THREAD_EXITED) @@ -1287,6 +1345,8 @@ call_function_by_hand_dummy (struct value *function, { struct value *retval; + infcall_debug_printf ("call completed"); + /* The inferior call is successful. Pop the dummy frame, which runs its destructors and restores the inferior's suspend state, and restore the inferior control @@ -1317,6 +1377,8 @@ call_function_by_hand_dummy (struct value *function, return retval; } + else + infcall_debug_printf ("call did not complete"); /* Didn't complete. Clean up / destroy the call FSM, and restore the previous state machine, and handle the error. */ @@ -1572,4 +1634,10 @@ The default is to unwind the frame."), show_unwind_on_terminating_exception_p, &setlist, &showlist); + add_setshow_boolean_cmd + ("infcall", class_maintenance, &debug_infcall, + _("Set inferior call debugging."), + _("Show inferior call debugging."), + _("When on, inferior function call specific debugging is enabled."), + NULL, show_debug_infcall, &setdebuglist, &showdebuglist); }