diff --git a/src/cmd/addr2line/main.c b/src/cmd/addr2line/main.c index 6b2fe5dfe19..9faadc27bb3 100644 --- a/src/cmd/addr2line/main.c +++ b/src/cmd/addr2line/main.c @@ -11,13 +11,19 @@ #include #include +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();