From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 9CDA53858D28 for ; Wed, 29 Sep 2021 09:56:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9CDA53858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x42e.google.com with SMTP id w29so3213663wra.8 for ; Wed, 29 Sep 2021 02:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2j+UU1iATswy2uX4d1kkJEyx/Gjet3Gwho57ItbL91g=; b=ZWSF0pJasNL5pGwB/ShxZoqx/0Iv/8TGIaktQkY+lwtbuas3eIMZLz6GUHNehpd4B2 u5frbSIgU58iGABRI0EuDOTKd98Up/fFrHeJAixPytNbO/Aus/67OH3XiNfTkAK7bsaQ YIPqqa0j71jI9WIlxnMdXg3quv0/yea2g6g92nDMbFmmRuxjaanVzUevjxgVAYVG/Y9R v5NAyeKWlpsCczw1sqJfDiz8SBHSaGq89JRMz5a/tGu/SxK5SfyxJ6v1NKnJ3Zlz5SEk Jb3iGwAtMjbm5Psu9Q5WiQzsMF42Ce1xlFvVkR9JkWkfVpGEnqlagVcwnMf47RXy2gvz TB7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2j+UU1iATswy2uX4d1kkJEyx/Gjet3Gwho57ItbL91g=; b=L07S1+nqh4K6w0+BiJT/Y7tAYE6hcTMAT5vCCHRZSo3FxSqZSjOoSxDyom01fvTCfl RYn/oh8N3YXBYrOr1aFQtwPCwFiLT21CK8oQOgkAPu7iHzVrEqhmoDC4v2LasFMPvC/Y GktQyZbjhBXKTTQT7qwb5xynLQbVyaOSKnkzkrVVayQaDM48SFMTV8tACGm7m4UP6mT9 SK6wqt+uEtNzrap0yBRH8A3Hlvlv53DXNZXpYSxQUCAUR9diS87vqbL2proMH+XOCWpJ iv86yJlSHJsgEWR7ozTWo4AFtd77zqIP0AHSewojdRU503VTybkFpicrrYgzDlcyubN/ fl/A== X-Gm-Message-State: AOAM5315Se94fi848MG+iDBVU73XGZNUEs1N3CuDyKH4EMCdVLynRZU7 1naKAG7heu71DI3pmH0b50p5pb/5s2KeDg== X-Google-Smtp-Source: ABdhPJze/hNbPQPgW/xQINhQe9byFZQC8aPS9ctP/3/jYmu8cD5WojSYjFQ4m5tVrX96C/Ym/OJVlA== X-Received: by 2002:a5d:6d8a:: with SMTP id l10mr5676932wrs.121.1632909409767; Wed, 29 Sep 2021 02:56:49 -0700 (PDT) Received: from localhost (host86-169-137-11.range86-169.btcentralplus.com. [86.169.137.11]) by smtp.gmail.com with ESMTPSA id a8sm739048wrp.61.2021.09.29.02.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 02:56:48 -0700 (PDT) Date: Wed, 29 Sep 2021 10:56:46 +0100 From: Andrew Burgess To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PUSHED 5/6] gdb: use libbacktrace to create a better backtrace for fatal signals Message-ID: <20210929095646.GM1900093@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 10:56:04 up 10 days, 1:05, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Wed, 29 Sep 2021 09:56:52 -0000 * Simon Marchi [2021-09-28 23:09:20 -0400]: > > +void > > +gdb_internal_backtrace () > > +{ > > + if (current_ui == nullptr) > > + return; > > + > > + const auto sig_write = [] (const char *msg) -> void > > + { > > + gdb_stderr->write_async_safe (msg, strlen (msg)); > > + }; > > + > > + sig_write (_("----- Backtrace -----\n")); > > + > > + if (gdb_stderr->fd () > -1) > > + gdb_internal_backtrace_1 (); > > + else > > + sig_write (_("Backtrace unavailable\n")); > > I happen to try to build GDB on NetBSD, and I get: > > CXX bt-utils.o > /home/simark/src/binutils-gdb/gdb/bt-utils.c: In function 'void gdb_internal_backtrace()': > /home/simark/src/binutils-gdb/gdb/bt-utils.c:165:5: error: 'gdb_internal_backtrace_1' was not declared in this scope > gdb_internal_backtrace_1 (); > ^~~~~~~~~~~~~~~~~~~~~~~~ > > Indeed, it looks like gdb_internal_backtrace_1 is never defined if > !GDB_PRINT_INTERNAL_BACKTRACE_USING_EXECINFO and > !GDB_PRINT_INTERNAL_BACKTRACE_USING_LIBBACKTRACE. > > You can reproduce on Linux by deleting HAVE_LIBBACKTRACE and > HAVE_EXECINFO_BACKTRACE from your generated config.h. Sorry for breaking this. I pushed the patch below to resolve this issue. Let me know if you see any further problems. Thanks, Andrew -- commit 74ea3b51c3b76fc0ccd46cc755e6e85e4570515b Author: Andrew Burgess Date: Wed Sep 29 10:26:59 2021 +0100 gdb: fix build when libbacktrace and execinfo backtrace are not available In this commit: commit abbbd4a3e0ca51132e7fb31a43f896d29894dae0 Date: Wed Aug 11 13:24:33 2021 +0100 gdb: use libbacktrace to create a better backtrace for fatal signals The build of GDB was broken iff, the execinfo backtrace API is not available, and, libbacktrace is either disabled, or not usable. In this case you'll see build errors like this: CXX bt-utils.o /home/username/src/binutils-gdb/gdb/bt-utils.c: In function 'void gdb_internal_backtrace()': /home/username/src/binutils-gdb/gdb/bt-utils.c:165:5: error: 'gdb_internal_backtrace_1' was not declared in this scope gdb_internal_backtrace_1 (); ^~~~~~~~~~~~~~~~~~~~~~~~ This commit fixes the issue by guarding the call to gdb_internal_backtrace_1 with '#ifdef GDB_PRINT_INTERNAL_BACKTRACE', which is only defined when one of the backtrace libraries are available. diff --git a/gdb/bt-utils.c b/gdb/bt-utils.c index 8f826bde6b4..79e6e090d42 100644 --- a/gdb/bt-utils.c +++ b/gdb/bt-utils.c @@ -161,9 +161,11 @@ gdb_internal_backtrace () sig_write (_("----- Backtrace -----\n")); +#ifdef GDB_PRINT_INTERNAL_BACKTRACE if (gdb_stderr->fd () > -1) gdb_internal_backtrace_1 (); else +#endif sig_write (_("Backtrace unavailable\n")); sig_write ("---------------------\n");