]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/addr2line: accept optional "0x" prefix for addresses.
authorShenghou Ma <minux.ma@gmail.com>
Sat, 10 May 2014 17:35:40 +0000 (13:35 -0400)
committerShenghou Ma <minux.ma@gmail.com>
Sat, 10 May 2014 17:35:40 +0000 (13:35 -0400)
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/91250043

src/cmd/addr2line/main.go

index 23d02442b1997577600e53ed7b16712b74f6c8ab..d6d14a7330b49397002e15432a98d3686b650eb0 100644 (file)
@@ -8,7 +8,7 @@
 // Usage:
 //     go tool addr2line binary
 //
-// Addr2line reads hexadecimal addresses, one per line and without a 0x prefix,
+// Addr2line reads hexadecimal addresses, one per line and with optional 0x prefix,
 // from standard input. For each input address, addr2line prints two output lines,
 // first the name of the function containing the address and second the file:line
 // of the source code corresponding to that address.
@@ -88,7 +88,7 @@ func main() {
                        fmt.Fprintf(stdout, "!reverse translation not implemented\n")
                        continue
                }
-               pc, _ := strconv.ParseUint(p, 16, 64)
+               pc, _ := strconv.ParseUint(strings.TrimPrefix(p, "0x"), 16, 64)
                file, line, fn := tab.PCToLine(pc)
                name := "?"
                if fn != nil {