-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[symbolizer] Address starting with a plus sign is valid. #135857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-llvm-binary-utilities Author: Ebuka Ezike (da-viper) Changesthis is also the same behaviour in depends on #135856 Full diff: https://github.com/llvm/llvm-project/pull/135857.diff 2 Files Affected:
diff --git a/llvm/test/tools/llvm-symbolizer/symbol-search.test b/llvm/test/tools/llvm-symbolizer/symbol-search.test
index 6729c4b01bfef..fe9a61bd8ef6c 100644
--- a/llvm/test/tools/llvm-symbolizer/symbol-search.test
+++ b/llvm/test/tools/llvm-symbolizer/symbol-search.test
@@ -65,8 +65,9 @@ RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+0A | FileCheck --check-p
RUN: llvm-addr2line --obj=%p/Inputs/symbols.so func_01+0A | FileCheck --check-prefix=NONEXISTENT %s
# If '+' is not preceded by a symbol, it is part of a symbol name, not an offset separator.
-RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so +0x1138 | FileCheck --check-prefix=NONEXISTENT %s
-RUN: llvm-addr2line --obj=%p/Inputs/symbols.so +0x1138 | FileCheck --check-prefix=NONEXISTENT %s
+# address starting with a `+` sign is a valid address
+RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so +0x1138 | FileCheck --check-prefix=CODE-CMD %s
+RUN: llvm-addr2line --obj=%p/Inputs/symbols.so +0x1138 | FileCheck --check-prefix=CODE-CMD %s
# Show that C++ mangled names may be specified.
RUN: llvm-addr2line --obj=%p/Inputs/symbols.so _ZL14static_func_01i | FileCheck --check-prefix=MULTI-CXX %s
diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 3ba7f59d5b847..c8abddbbab5dd 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -238,9 +238,12 @@ static Error parseCommand(StringRef BinaryName, bool IsAddr2Line,
bool StartsWithDigit = std::isdigit(AddrSpec.front());
// GNU addr2line assumes the address is hexadecimal and allows a redundant
- // "0x" or "0X" prefix; do the same for compatibility.
- if (IsAddr2Line)
- AddrSpec.consume_front("0x") || AddrSpec.consume_front("0X");
+ // "0x" or "0X" prefix or with an optional `+` sign; do the same for
+ // compatibility.
+ if (IsAddr2Line) {
+ AddrSpec.consume_front_insensitive("0x") ||
+ AddrSpec.consume_front_insensitive("+0x");
+ }
// If address specification is a number, treat it as a module offset.
if (!AddrSpec.getAsInteger(IsAddr2Line ? 16 : 0, Offset)) {
|
@da-viper, why was this PR closed? |
@jh7370 I could not tell if the existing behaviour was intended since I did not see any response, If it is not the case I can reopen it. |
Normally people "ping" a PR if it hasn't had any review after a week. You should also add some reviewers, by (if you have commit access) modifying the reviewers list, or (if you don't) pinging them here. I'd typically have reviewed this myself by now, but I'm on a reviewing pause, due to non-LLVM workloads being high at the moment. I suggest you reopen and update (if needed). We aim for compatibility with the GNU tools wherever possible, so I'd guess this PR has merit (but I can't be sure without digging deeper, which I won't have time for for a couple more weeks probably). |
Could you please provide more context? What problem does this change solve? I checked the trunk version of addr2line, it seems it does not support such syntax. |
When you pass and adress prefixed with $ llvm-addr2line --exe=./llvm-project/llvm/test/tools/llvm-symbolizer/Inputs/symbols.so +0x1138
??:0 [0.08s]
$ addr2line --exe=./llvm-project/llvm/test/tools/llvm-symbolizer/Inputs/symbols.so +0x1138
/tmp/dbginfo/symbols.part1.cpp:12
$ addr2line --version
GNU addr2line version 2.44-3.fc42
Copyright (C) 2025 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty. |
4eec5d8
to
6b65f98
Compare
this is also the same behaviour in gnu addr2line. Signed-off-by: Ebuka Ezike <yerimyah1@gmail.com>
6b65f98
to
cf3fbef
Compare
this is also the same behaviour in
gnu addr2line
.depends on #135856