From patchwork Mon Dec 19 13:53:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maurizio Papini X-Patchwork-Id: 34553 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2399376wrn; Mon, 19 Dec 2022 05:54:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXt4eyuPLu5ozwqPPWtrXUR90zyGHl8UhefdKV8ElaxP1Vi09dLHBtFaQfRp0hLQc9nQGZ+L X-Received: by 2002:a05:6402:298d:b0:465:f6a9:cb7b with SMTP id eq13-20020a056402298d00b00465f6a9cb7bmr13519237edb.12.1671458047495; Mon, 19 Dec 2022 05:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671458047; cv=none; d=google.com; s=arc-20160816; b=rO7x6iHoBMB7TdLACKjXRnde3Ue57Z6YitiyCAJIe+hpdQyY3MrSPh18DQW9ri+/xh bYGZl7/8tl/Gd7+nQ2N/RR1GGs+QL/aQLggZQGA/5ycF1Hks3XxAV1IsbjwVQP1JmRV5 /n3HFVsBPfDnhBijj0W6oQ8BTsTfC5BvKpSeLw4qpjHxKnALEgJz1qowtBVKZ5CDZB/X XI5/zNearPRoB5BnyyToB/FVUMQqTAjDFUeRTUhdpw/LLbuHIDRIEpcwsbK5sJmpYHX7 QoUK8BIzF/0cCPdXO+qWyDid57fLl0g5112k35/QsGalb69TR3avjVGeHSqIen5bmpKs Hj7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=542C2g1tOZD+my6b/TAWGt17HlB0F0QIRC5bzLq9e7Y=; b=tJm8AepDQTHl4qrnvsHKGnmBGtnaIq3b+4ixy2uS42P0yLj8p4KXGDtXbTV7OnNGvN L072KWH3M3kSrM4J4SieZ/wFmlYmaczEw1AOTPyZX+mwQaAEGzkJjbexN4G1evIBajNM V8FPQMDYOJUDS+92B0rLlzFMGXq/emdQUhucvIjZM2rqSb6qtXVGK4AyZeRk5boPMAo5 mMX/6sM1liMCpTVLmwr8YBmb2/ksu/cFDPGeVfglbshPxYkMkQgzb7SLpXmRfaFQP+VY AnPtBEzaQvwA1YYHhb76b1dHAmBLYTTJAT3c/eFiyYauA/itE1qAOXM190gQc143I7KT 2CRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=DwRWpLKR; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h8-20020a056402094800b0046125ddf5easi4524580edz.185.2022.12.19.05.54.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 05:54:07 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=DwRWpLKR; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FBC43858C83 for ; Mon, 19 Dec 2022 13:54:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FBC43858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671458042; bh=542C2g1tOZD+my6b/TAWGt17HlB0F0QIRC5bzLq9e7Y=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=DwRWpLKRq2bZpy1rXc9XfpEZTfCDqIImCKlcdomkwrNxhE6e+aKrmpxf3+2ojZD+Z uEgUSfsJck9+QOCwxBiNoUgnVZtFr7Jq0FLQRHNa58GYT26fXub12N7VG/FvSWGZgt vbF/3fv5Dca5ClOgEI/a6eHNxbAfBIBCTqfDrUEA= X-Original-To: binutils@sourceware.org Delivered-To: binutils@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 57A443858D39 for ; Mon, 19 Dec 2022 13:53:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 57A443858D39 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-502-kf1_-JNIOtin30M9DhtSdQ-1; Mon, 19 Dec 2022 08:53:51 -0500 X-MC-Unique: kf1_-JNIOtin30M9DhtSdQ-1 Received: by mail-ed1-f69.google.com with SMTP id y20-20020a056402271400b0046c9a6ec30fso6581030edd.14 for ; Mon, 19 Dec 2022 05:53:51 -0800 (PST) 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=542C2g1tOZD+my6b/TAWGt17HlB0F0QIRC5bzLq9e7Y=; b=WC9m5XsIFGsd6zf8wHeoFvJucXlqtOz4B4p7+rLDpfEcmF7IgTrybdbPYQGHx+mqOx HCc+3/t1kZNerf09rbv6EOYamRMwj2isp240K4Zt5NCkaxmMTuB9VfkGlHO2n+nXm4BG ROWtnQa09XX3tFmJqJSqfJ6NY4Sj0bu4CHguVvlLE0qC8fVfuSjurTPZ0RoD8qxaN0il XJQxxpgnpOlCiZibv/SCuyO5I5H08dDhr1iSN/8ey3SaGwAVNjkccqMx/00k+xlkI9sl 0InhYxBvUPRRjPG/XNhNfRNAtd1MPjIvc5y1mbXTrjp9XWVD8JLqp6WAaojf4ZhHC0b4 gulQ== X-Gm-Message-State: ANoB5pkaIzjprJT/nploY2OMEP/KeHl9ks6MpQIQ2yLDLJpLMfL4CZW8 Tpt9rTeuBERC3Wl3ITOcXcfd1mmmnv/D9y72BDTqUHmGMsk3Z/M9Vm1IHStybM8d1YZwxWyr8P/ 6RyPFmkIQGCrQunbtZ7SIwmeucDXL/nAZGlwRoHdyx56gQwSJCcjBqZVqbjIOUtISybfr X-Received: by 2002:a17:906:1c0c:b0:7c1:e7a:62e6 with SMTP id k12-20020a1709061c0c00b007c10e7a62e6mr35502065ejg.71.1671458030231; Mon, 19 Dec 2022 05:53:50 -0800 (PST) X-Received: by 2002:a17:906:1c0c:b0:7c1:e7a:62e6 with SMTP id k12-20020a1709061c0c00b007c10e7a62e6mr35502048ejg.71.1671458029928; Mon, 19 Dec 2022 05:53:49 -0800 (PST) Received: from ulissedini.. ([81.56.11.23]) by smtp.gmail.com with ESMTPSA id t21-20020a056402021500b00463bc1ddc76sm4377476edv.28.2022.12.19.05.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 05:53:49 -0800 (PST) To: binutils@sourceware.org Cc: Maurizio Papini Subject: [PATCH 1/2] addr2line: new option -n to add a newline at the end Date: Mon, 19 Dec 2022 14:53:02 +0100 Message-Id: <20221219135303.116222-2-mpapini@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219135303.116222-1-mpapini@redhat.com> References: <20221219135303.116222-1-mpapini@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.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_H2, 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Maurizio Papini via Binutils From: Maurizio Papini Reply-To: Maurizio Papini Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752650781337057996?= X-GMAIL-MSGID: =?utf-8?q?1752650793132109677?= --- binutils/addr2line.c | 11 +++++++++-- binutils/doc/binutils.texi | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/binutils/addr2line.c b/binutils/addr2line.c index baf16716182..d9338e9f1ea 100644 --- a/binutils/addr2line.c +++ b/binutils/addr2line.c @@ -45,7 +45,7 @@ static bool with_functions; /* -f, show function names. */ static bool do_demangle; /* -C, demangle names. */ static bool pretty_print; /* -p, print on one line. */ static bool base_names; /* -s, strip directory names. */ - +static bool add_newline; /* -n, add a newline at the end. */ /* Flags passed to the name demangler. */ static int demangle_flags = DMGL_PARAMS | DMGL_ANSI; @@ -70,6 +70,7 @@ static struct option long_options[] = {"no-recursion-limit", no_argument, NULL, 'r'}, {"section", required_argument, NULL, 'j'}, {"target", required_argument, NULL, 'b'}, + {"add-newline", no_argument, NULL, 'n'}, {"help", no_argument, NULL, 'H'}, {"version", no_argument, NULL, 'V'}, {0, no_argument, 0, 0} @@ -102,6 +103,7 @@ usage (FILE *stream, int status) -C --demangle[=style] Demangle function names\n\ -R --recurse-limit Enable a limit on recursion whilst demangling. [Default]\n\ -r --no-recurse-limit Disable a limit on recursion whilst demangling\n\ + -n --add-newline Add a newline at the end of the output\n\ -h --help Display this information\n\ -v --version Display the program's version\n\ \n")); @@ -417,6 +419,8 @@ translate_addresses (bfd *abfd, asection *section) } } + if(add_newline) + printf("\n"); /* fflush() is essential for using this command as a server child process that reads addresses from a pipe and responds with line number information, processing one address at a @@ -505,7 +509,7 @@ main (int argc, char **argv) file_name = NULL; section_name = NULL; target = NULL; - while ((c = getopt_long (argc, argv, "ab:Ce:rRsfHhij:pVv", long_options, (int *) 0)) + while ((c = getopt_long (argc, argv, "ab:Ce:rRsfnHhij:pVv", long_options, (int *) 0)) != EOF) { switch (c) @@ -564,6 +568,9 @@ main (int argc, char **argv) case 'j': section_name = optarg; break; + case 'n': + add_newline = true; + break; default: usage (stderr, 1); break; diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index c9d52d7c92f..0940708d77e 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -3976,6 +3976,7 @@ addr2line [@option{-a}|@option{--addresses}] [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}] [@option{-i}|@option{--inlines}] [@option{-p}|@option{--pretty-print}] + [@option{-n}|@option{--add-newline}] [@option{-j}|@option{--section=}@var{name}] [@option{-H}|@option{--help}] [@option{-V}|@option{--version}] [addr addr @dots{}] @@ -4102,6 +4103,10 @@ Make the output more human friendly: each location are printed on one line. If option @option{-i} is specified, lines for all enclosing scopes are prefixed with @samp{(inlined by)}. +@item -n +@itemx --add-newline +Add a newline at the end of the output. + @item -r @itemx -R @itemx --recurse-limit