summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2022-03-11 15:44:21 +0100
committerMark Wielaard <mark@klomp.org>2022-03-14 12:57:41 +0100
commit9e39d31c4ec1c8f7eb16886f8b7fd04c0a4f2462 (patch)
tree421ba5b5d78fbe82708da12beb47de7f98f36b84 /src
parent29859f2e79ef3c650ee9712cae990c6a7f787a7d (diff)
downloadelfutils-9e39d31c4ec1c8f7eb16886f8b7fd04c0a4f2462.tar.gz
addr2line: Make --absolute the default, add --relative option.
Make --absolute (including the compilation directory in file names) the default and add a new option --relative to get the previous default behavior. https://www.sourceware.org/bugzilla/show_bug.cgi?id=28951 Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/addr2line.c14
2 files changed, 18 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 263e9faa..0e705b7d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2022-03-11 Mark Wielaard <mark@klomp.org>
+
+ * addr2line.c (OPT_RELATIVE): New constant.
+ (options): Add --relative.
+ (use_comp_dir): Initialize to true.
+ (parse_opt): Handle OPT_RELATIVE.
+
2021-12-04 Mark Wielaard <mark@klomp.org>
* readelf.c (print_ehdr): Pass sizeof (buf) - 1 to strncpy.
diff --git a/src/addr2line.c b/src/addr2line.c
index 34945046..7c8d3a72 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -1,5 +1,6 @@
/* Locate source files and line information for given addresses
Copyright (C) 2005-2010, 2012, 2013, 2015 Red Hat, Inc.
+ Copyright (C) 2022 Mark J. Wielaard <mark@klomp.org>
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2005.
@@ -49,7 +50,8 @@ ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
/* Values for the parameters which have no short form. */
#define OPT_DEMANGLER 0x100
-#define OPT_PRETTY 0x101 /* 'p' is already used to select the process. */
+#define OPT_PRETTY 0x101 /* 'p' is already used to select the process. */
+#define OPT_RELATIVE 0x102 /* 'r' is something else in binutils addr2line. */
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
@@ -62,7 +64,7 @@ static const struct argp_option options[] =
{ "addresses", 'a', NULL, 0, N_("Print address before each entry"), 0 },
{ "basenames", 's', NULL, 0, N_("Show only base names of source files"), 0 },
{ "absolute", 'A', NULL, 0,
- N_("Show absolute file names using compilation directory"), 0 },
+ N_("Show absolute file names using compilation directory (default)"), 0 },
{ "functions", 'f', NULL, 0, N_("Also show function names"), 0 },
{ "symbols", 'S', NULL, 0, N_("Also show symbol or section names"), 0 },
{ "symbols-sections", 'x', NULL, 0, N_("Also show symbol and the section names"), 0 },
@@ -74,6 +76,8 @@ static const struct argp_option options[] =
N_("Show demangled symbols (ARG is always ignored)"), 0 },
{ "pretty-print", OPT_PRETTY, NULL, 0,
N_("Print all information on one line, and indent inlines"), 0 },
+ { "relative", OPT_RELATIVE, NULL, 0,
+ N_("Show relative file names without compilation directory"), 0 },
{ NULL, 0, NULL, 0, N_("Miscellaneous:"), 0 },
/* Unsupported options. */
@@ -111,7 +115,7 @@ static bool print_addresses;
static bool only_basenames;
/* True if absolute file names based on DW_AT_comp_dir should be shown. */
-static bool use_comp_dir;
+static bool use_comp_dir = true;
/* True if line flags should be shown. */
static bool show_flags;
@@ -236,6 +240,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
use_comp_dir = true;
break;
+ case OPT_RELATIVE:
+ use_comp_dir = false;
+ break;
+
case 'f':
show_functions = true;
break;