public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/5] addr2line: Always parse addresses as hex numbers.
@ 2015-05-20 14:35 Mark Wielaard
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2015-05-20 14:35 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 2184 bytes --]

We would sometimes interpret input addresses as decimal or octal.
That could be confusing and isn't what binutils addr2line does.
Be consistent and always treat input addresses as hex.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog              | 5 +++++
 src/addr2line.c            | 4 ++--
 tests/ChangeLog            | 4 ++++
 tests/run-addrname-test.sh | 2 +-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index f4ff1fb..284b886 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
 2015-05-20  Mark Wielaard  <mjw@redhat.com>
 
+	* addr2line.c (handle_address): Call strtoumax with base 16. Make
+	sure all input has been processed.
+
+2015-05-20  Mark Wielaard  <mjw@redhat.com>
+
 	* addr2line (argp_option): Group 'section' under "Input format
 	options".
 
diff --git a/src/addr2line.c b/src/addr2line.c
index c7ff7f7..b1ff368 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -532,8 +532,8 @@ static int
 handle_address (const char *string, Dwfl *dwfl)
 {
   char *endp;
-  uintmax_t addr = strtoumax (string, &endp, 0);
-  if (endp == string)
+  uintmax_t addr = strtoumax (string, &endp, 16);
+  if (endp == string || *endp != '\0')
     {
       bool parsed = false;
       int i, j;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index a899947..0e31012 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-20  Mark Wielaard  <mjw@redhat.com>
+
+	* run-addrname-test.sh: Make sure all input addresses are hex.
+
 2015-05-04  Max Filippov  <jcmvbkbc@gmail.com>
 
 	* backtrace-child.c (stdarg, main): Replace assert_perror with assert.
diff --git a/tests/run-addrname-test.sh b/tests/run-addrname-test.sh
index f954ee4..90e19df 100755
--- a/tests/run-addrname-test.sh
+++ b/tests/run-addrname-test.sh
@@ -277,7 +277,7 @@ EOF
 #	local l0local2, 0
 #	offset 12
 testfiles testfile64
-testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile64 1 4 5 8 9 12 <<\EOF
+testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile64 1 4 5 8 9 c <<\EOF
 gglobal2
 ??:0
 g0global2
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/5] addr2line: Always parse addresses as hex numbers.
@ 2015-05-21 13:34 Mark Wielaard
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2015-05-21 13:34 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]

On Wed, 2015-05-20 at 11:18 -0700, Roland McGrath wrote:
> That looks fine but it should get a NEWS item for the incompatible UI change.

Yeah, I guess technically it is an incompatible change. Though I think
it was just a bug and nobody actually expected the addresses to be
interpreted as octal or decimal. At least it was a surprise to me.
I added the following to NEWS:

diff --git a/NEWS b/NEWS
index 60aa995..8cc184a 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ Version 0.162
 
 libdw: Install new header elfutils/known-dwarf.h.
 
+addr2line: Input addresses are now always interpreted as hexadecimal
+           numbers, never as octal or decimal numbers.
+
 Version 0.161
 
 libdw: New function dwarf_peel_type. dwarf_aggregate_size now uses


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/5] addr2line: Always parse addresses as hex numbers.
@ 2015-05-20 18:18 Roland McGrath
  0 siblings, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2015-05-20 18:18 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 79 bytes --]

That looks fine but it should get a NEWS item for the incompatible UI change.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-21 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20 14:35 [PATCH 2/5] addr2line: Always parse addresses as hex numbers Mark Wielaard
2015-05-20 18:18 Roland McGrath
2015-05-21 13:34 Mark Wielaard

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).