From: Maurizio Papini <mpapini@redhat.com>
To: binutils@sourceware.org
Cc: Maurizio Papini <mpapini@redhat.com>
Subject: [PATCH 1/2] addr2line: new option -n to add a newline at the end
Date: Mon, 19 Dec 2022 14:53:02 +0100 [thread overview]
Message-ID: <20221219135303.116222-2-mpapini@redhat.com> (raw)
In-Reply-To: <20221219135303.116222-1-mpapini@redhat.com>
---
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
--
2.38.1
next prev parent reply other threads:[~2022-12-19 13:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 13:53 [PATCH 0/2] " Maurizio Papini
2022-12-19 13:53 ` Maurizio Papini [this message]
2022-12-19 13:53 ` [PATCH 2/2] addr2line: test to check -n option Maurizio Papini
2023-01-09 16:04 ` [PATCH 0/2] addr2line: new option -n to add a newline at the end Maurizio Papini
2023-01-09 16:17 ` Jan Beulich
2023-01-10 14:17 ` Maurizio Papini
2023-01-10 15:50 ` Jan Beulich
2023-01-10 12:19 ` Nick Clifton
2023-01-10 15:28 ` Maurizio Papini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221219135303.116222-2-mpapini@redhat.com \
--to=mpapini@redhat.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).