]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/addr2line: exit 0 for --help
authorRuss Cox <rsc@golang.org>
Mon, 11 Mar 2013 22:12:07 +0000 (18:12 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 11 Mar 2013 22:12:07 +0000 (18:12 -0400)
This is what pprof expects, or else it won't use the program.
And if it doesn't use the program, it gets very bad results.

Fixes #4818.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7728043

src/cmd/addr2line/main.c

index 6b2fe5dfe19dece5a43d16e51e1bbb9a819e382e..9faadc27bb33041ffbc30507ade9baa57427c38e 100644 (file)
 #include <bio.h>
 #include <mach.h>
 
+void
+printusage(int fd)
+{
+       fprint(fd, "usage: addr2line binary\n");
+       fprint(fd, "reads addresses from standard input and writes two lines for each:\n");
+       fprint(fd, "\tfunction name\n");
+       fprint(fd, "\tfile:line\n");
+}
+
 void
 usage(void)
 {
-       fprint(2, "usage: addr2line binary\n");
-       fprint(2, "reads addresses from standard input and writes two lines for each:\n");
-       fprint(2, "\tfunction name\n");
-       fprint(2, "\tfile:line\n");
+       printusage(2);
        exits("usage");
 }
 
@@ -32,6 +38,11 @@ main(int argc, char **argv)
        Biobuf bin, bout;
        char file[1024];
 
+       if(argc > 1 && strcmp(argv[1], "--help") == 0) {
+               printusage(1);
+               exits(0);
+       }
+
        ARGBEGIN{
        default:
                usage();