From patchwork Mon Jan 28 10:24:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1031839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-494824-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Xhk8hzyB"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43p5ND02vQz9s3l for ; Mon, 28 Jan 2019 21:24:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=jEcNnUj6cO9ouEsSs bUNWwTGL1Ln7Jkap9x1dAgRNqHWSS9SM507e9pFgmYkuXf7K7qzr3b9ngKL70mm2 YIDYK2FJh1IPxLJlTSwtdAFDuUYgmetYpteWzz/NZdX4SqLRvN8A2jbR2DuRBl+5 Ss1bVKFBvo+fB8qaVPc7rMdfyg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=Z5f7UhS/606npYW/e2LvJqq ck2U=; b=Xhk8hzyB29p/FroB28N5mj4uU0wolFb36YOT4j1yFPXPaxz0lElVHLT atUsJQjeWoujBglN17xP8yvXFYVQ63Nf61nQvmJbo+WWXdMOskvjeLT1VhgHRZGI 2mM5BxIm0YM1F+u9L3CohAG6CIbyIqfKoGwZd8qxfW/Y1n6aEz1Q= Received: (qmail 109556 invoked by alias); 28 Jan 2019 10:24:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 109454 invoked by uid 89); 28 Jan 2019 10:24:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 28 Jan 2019 10:24:13 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5E7D2AD86; Mon, 28 Jan 2019 10:24:03 +0000 (UTC) Subject: [libbacktrace] Add gen-xcoff-n.sh From: Tom de Vries To: Ian Lance Taylor Cc: GCC Patches References: <2839e296-39b7-d1e1-5bd7-62fdba33b156@acm.org> <5b641514-39af-eb56-ce4d-1cf7dd021899@suse.de> <850b2536-e33e-ffe3-82b6-acf0c3549a72@suse.de> <0291a980-223a-8c15-3253-9eefa5f377b4@acm.org> <8e0a3f07-3326-b4f8-f1e4-64ac1f5c7aed@suse.de> Message-ID: <1874cf9d-656c-ddee-070b-ef60570f69ce@suse.de> Date: Mon, 28 Jan 2019 11:24:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <8e0a3f07-3326-b4f8-f1e4-64ac1f5c7aed@suse.de> X-IsSubscribed: yes [ was: Re: [libbacktrace] Fix and simplify xcoff_%.c pattern rule ] On 28-01-19 10:25, Tom de Vries wrote: > [ was: Re: [backtrace] Avoid segfault ] > On 27-01-19 22:53, Ian Lance Taylor wrote: >> On Sun, Jan 27, 2019 at 1:16 PM Tom de Vries wrote: >>> >>> On 25-01-19 18:15, Nathan Sidwell wrote: >>>> On 1/25/19 5:28 AM, Tom de Vries wrote: >>>>> >>>>> This patch fixes it by passing "" instead of NULL, in the call to >>>>> elf_add at line 3083 (for .gnu_debugaltlink), not the call to elf_add at >>>>> line 3044 (for .gnu_debuglink) mentioned above. >>>>> >>>>> Nathan, does this fix the problem for you? If not, can you provide a >>>>> reproducer, or give a hint on how one could be constructed? >>>> >>>> I still hit the problem, and am installing this as sufficiently obvious. >>>> I'm on a fedora system debugging pr88995. The debuglink_name is >>>> "../../.dwz/isl-0.16.1-7.fc29.x86_64" >>>> >>> >>> I've managed to reproduce this segfault instance by adding a test-case >>> that uses both build-id and dwz. >>> >>> OK for trunk? >> >>> +elf_for_test.c: elf.c >>> + PWD=$$(pwd -P); \ >>> + BUILD_ID_DIR="usr/lib/debug/.build-id/"; \ >>> + SEARCH='#define SYSTEM_BUILD_ID_DIR'; \ >>> + REPLACE="#define SYSTEM_BUILD_ID_DIR \"$$PWD/$$BUILD_ID_DIR\""; \ >>> + $(SED) "s%^$$SEARCH.*\$$%$$REPLACE%" \ >>> + $< \ >>> + > $@ >> >> You need to use a temporary file, such as $@.tmp, for the final sed >> command, followed by a mv to $@. Otherwise a failure in the sed will >> leave what appears to be an up to date file. > > I noticed the same problem in the xcoff_%.c pattern rule. > And looking over the rule again, I wondered if it would be more readable if split off into a separate script file. Is this follow-up patch OK for trunk? Thanks, - Tom [Libbacktrace] Add gen-xcoff-n.sh Factor out xcoff_%.c generation into gen-xcoff-n.c, getting rid of the escaping of shell variables. 2019-01-28 Tom de Vries * Makefile.am: Factor out xcoff_%.c generation ... * gen-xcoff-n.sh: ... here. New file. * Makefile.in: Regenerate. --- libbacktrace/Makefile.am | 8 +------- libbacktrace/Makefile.in | 8 +------- libbacktrace/gen-xcoff-n.sh | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index 0d5b3193e25..43d0c9ffd73 100644 --- a/libbacktrace/Makefile.am +++ b/libbacktrace/Makefile.am @@ -104,13 +104,7 @@ libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE) libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD) xcoff_%.c: xcoff.c - SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \ - REPLACE='#undef BACKTRACE_XCOFF_SIZE\ - #define BACKTRACE_XCOFF_SIZE'; \ - $(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \ - $< \ - > $@.tmp - mv $@.tmp $@ + $(srcdir)/gen-xcoff-n.sh $(SED) $< $* $@ test_elf_SOURCES = test_format.c testlib.c test_elf_LDADD = libbacktrace_noformat.la elf.lo diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in index b25ac92aeda..650392c2988 100644 --- a/libbacktrace/Makefile.in +++ b/libbacktrace/Makefile.in @@ -1750,13 +1750,7 @@ uninstall-am: @NATIVE_TRUE@xcoff_%.c: xcoff.c -@NATIVE_TRUE@ SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \ -@NATIVE_TRUE@ REPLACE='#undef BACKTRACE_XCOFF_SIZE\ -@NATIVE_TRUE@ #define BACKTRACE_XCOFF_SIZE'; \ -@NATIVE_TRUE@ $(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \ -@NATIVE_TRUE@ $< \ -@NATIVE_TRUE@ > $@.tmp -@NATIVE_TRUE@ mv $@.tmp $@ +@NATIVE_TRUE@ $(srcdir)/gen-xcoff-n.sh $(SED) $< $* $@ @NATIVE_TRUE@instrumented_alloc.lo: alloc.c diff --git a/libbacktrace/gen-xcoff-n.sh b/libbacktrace/gen-xcoff-n.sh new file mode 100755 index 00000000000..c8825a9deba --- /dev/null +++ b/libbacktrace/gen-xcoff-n.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +sed="$1" +src="$2" +n="$3" +dst="$4" + +tmp=$dst.tmp + +search='^#error "Unknown BACKTRACE_XCOFF_SIZE"$' + +replace='#undef BACKTRACE_XCOFF_SIZE\ + #define BACKTRACE_XCOFF_SIZE '"$n" + +$sed \ + "s/$search/$replace/" \ + $src \ + > $tmp + +mv $tmp $dst