From c484031f1f199ee53567241426efffee49008f82 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 25 Mar 2021 18:32:03 -0700 Subject: [PATCH] Consistently call BaseName() in various Usage() functions. Make various tools print just their names as part of the usage instructions, rather than the full path. Also fix a missing space in the dump_syms usage output. Change-Id: I2b796678cd47e7dbabcc03df2b57cdc3420c008c Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2787678 Reviewed-by: Mike Frysinger --- Makefile.am | 12 ++++++--- Makefile.in | 28 ++++++++++++++------ src/processor/minidump_dump.cc | 3 ++- src/tools/linux/core2md/core2md.cc | 4 ++- src/tools/linux/core_handler/core_handler.cc | 4 ++- src/tools/linux/dump_syms/dump_syms.cc | 7 +++-- src/tools/linux/pid2md/pid2md.cc | 4 ++- src/tools/linux/symupload/minidump_upload.cc | 7 +++-- src/tools/linux/symupload/sym_upload.cc | 8 +++--- 9 files changed, 55 insertions(+), 22 deletions(-) diff --git a/Makefile.am b/Makefile.am index ee7454e4..0602314d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -578,21 +578,24 @@ src_tools_linux_core2md_core2md_SOURCES = \ src/tools/linux/core2md/core2md.cc src_tools_linux_core2md_core2md_LDADD = \ - src/client/linux/libbreakpad_client.a + src/client/linux/libbreakpad_client.a \ + src/common/path_helper.o if HAVE_MEMFD_CREATE src_tools_linux_core_handler_core_handler_SOURCES = \ src/tools/linux/core_handler/core_handler.cc src_tools_linux_core_handler_core_handler_LDADD = \ - src/client/linux/libbreakpad_client.a + src/client/linux/libbreakpad_client.a \ + src/common/path_helper.o endif src_tools_linux_pid2md_pid2md_SOURCES = \ src/tools/linux/pid2md/pid2md.cc src_tools_linux_pid2md_pid2md_LDADD = \ - src/client/linux/libbreakpad_client.a + src/client/linux/libbreakpad_client.a \ + src/common/path_helper.o src_tools_linux_dump_syms_dump_syms_SOURCES = \ src/common/dwarf_cfi_to_module.cc \ @@ -632,6 +635,7 @@ src_tools_linux_md2core_minidump_2_core_SOURCES = \ src_tools_linux_symupload_minidump_upload_SOURCES = \ src/common/linux/http_upload.cc \ + src/common/path_helper.cc \ src/tools/linux/symupload/minidump_upload.cc src_tools_linux_symupload_minidump_upload_LDADD = -ldl @@ -644,6 +648,7 @@ src_tools_linux_symupload_sym_upload_SOURCES = \ src/common/linux/symbol_collector_client.h \ src/common/linux/symbol_upload.cc \ src/common/linux/symbol_upload.h \ + src/common/path_helper.cc \ src/tools/linux/symupload/sym_upload.cc src_tools_linux_symupload_sym_upload_LDADD = -ldl @@ -1260,6 +1265,7 @@ noinst_SCRIPTS = $(check_SCRIPTS) src_processor_minidump_dump_SOURCES = \ src/processor/minidump_dump.cc src_processor_minidump_dump_LDADD = \ + src/common/path_helper.o \ src/processor/basic_code_modules.o \ src/processor/convert_old_arm64_context.o \ src/processor/dump_context.o \ diff --git a/Makefile.in b/Makefile.in index 55ef6f3f..3c82fc95 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1094,6 +1094,7 @@ am__src_processor_minidump_dump_SOURCES_DIST = \ src_processor_minidump_dump_OBJECTS = \ $(am_src_processor_minidump_dump_OBJECTS) @DISABLE_PROCESSOR_FALSE@src_processor_minidump_dump_DEPENDENCIES = \ +@DISABLE_PROCESSOR_FALSE@ src/common/path_helper.o \ @DISABLE_PROCESSOR_FALSE@ src/processor/basic_code_modules.o \ @DISABLE_PROCESSOR_FALSE@ src/processor/convert_old_arm64_context.o \ @DISABLE_PROCESSOR_FALSE@ src/processor/dump_context.o \ @@ -1450,13 +1451,15 @@ am__src_tools_linux_core2md_core2md_SOURCES_DIST = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am_src_tools_linux_core2md_core2md_OBJECTS = src/tools/linux/core2md/core2md.$(OBJEXT) src_tools_linux_core2md_core2md_OBJECTS = \ $(am_src_tools_linux_core2md_core2md_OBJECTS) -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core2md_core2md_DEPENDENCIES = src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core2md_core2md_DEPENDENCIES = src/client/linux/libbreakpad_client.a \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.o am__src_tools_linux_core_handler_core_handler_SOURCES_DIST = \ src/tools/linux/core_handler/core_handler.cc @DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@am_src_tools_linux_core_handler_core_handler_OBJECTS = src/tools/linux/core_handler/core_handler.$(OBJEXT) src_tools_linux_core_handler_core_handler_OBJECTS = \ $(am_src_tools_linux_core_handler_core_handler_OBJECTS) -@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_DEPENDENCIES = src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_DEPENDENCIES = src/client/linux/libbreakpad_client.a \ +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/common/path_helper.o am__src_tools_linux_dump_syms_dump_syms_SOURCES_DIST = \ src/common/dwarf_cfi_to_module.cc \ src/common/dwarf_cu_to_module.cc \ @@ -1529,11 +1532,13 @@ am__src_tools_linux_pid2md_pid2md_SOURCES_DIST = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am_src_tools_linux_pid2md_pid2md_OBJECTS = src/tools/linux/pid2md/pid2md.$(OBJEXT) src_tools_linux_pid2md_pid2md_OBJECTS = \ $(am_src_tools_linux_pid2md_pid2md_OBJECTS) -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_pid2md_pid2md_DEPENDENCIES = src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_pid2md_pid2md_DEPENDENCIES = src/client/linux/libbreakpad_client.a \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.o am__src_tools_linux_symupload_minidump_upload_SOURCES_DIST = \ - src/common/linux/http_upload.cc \ + src/common/linux/http_upload.cc src/common/path_helper.cc \ src/tools/linux/symupload/minidump_upload.cc @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am_src_tools_linux_symupload_minidump_upload_OBJECTS = src/common/linux/http_upload.$(OBJEXT) \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.$(OBJEXT) \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/minidump_upload.$(OBJEXT) src_tools_linux_symupload_minidump_upload_OBJECTS = \ $(am_src_tools_linux_symupload_minidump_upload_OBJECTS) @@ -1545,12 +1550,13 @@ am__src_tools_linux_symupload_sym_upload_SOURCES_DIST = \ src/common/linux/symbol_collector_client.cc \ src/common/linux/symbol_collector_client.h \ src/common/linux/symbol_upload.cc \ - src/common/linux/symbol_upload.h \ + src/common/linux/symbol_upload.h src/common/path_helper.cc \ src/tools/linux/symupload/sym_upload.cc @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am_src_tools_linux_symupload_sym_upload_OBJECTS = src/common/linux/http_upload.$(OBJEXT) \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/libcurl_wrapper.$(OBJEXT) \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/symbol_collector_client.$(OBJEXT) \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/symbol_upload.$(OBJEXT) \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.$(OBJEXT) \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/sym_upload.$(OBJEXT) src_tools_linux_symupload_sym_upload_OBJECTS = \ $(am_src_tools_linux_symupload_sym_upload_OBJECTS) @@ -2783,19 +2789,22 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/core2md/core2md.cc @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core2md_core2md_LDADD = \ -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.o @DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_SOURCES = \ @DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/tools/linux/core_handler/core_handler.cc @DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_LDADD = \ -@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a \ +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/common/path_helper.o @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_pid2md_pid2md_SOURCES = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/pid2md/pid2md.cc @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_pid2md_pid2md_LDADD = \ -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.o @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_dump_syms_dump_syms_SOURCES = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/dwarf_cfi_to_module.cc \ @@ -2837,6 +2846,7 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_symupload_minidump_upload_SOURCES = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/http_upload.cc \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.cc \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/minidump_upload.cc @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_symupload_minidump_upload_LDADD = -ldl @@ -2849,6 +2859,7 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/symbol_collector_client.h \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/symbol_upload.cc \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/linux/symbol_upload.h \ +@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/path_helper.cc \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/sym_upload.cc @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_symupload_sym_upload_LDADD = -ldl @@ -3529,6 +3540,7 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @DISABLE_PROCESSOR_FALSE@ src/processor/minidump_dump.cc @DISABLE_PROCESSOR_FALSE@src_processor_minidump_dump_LDADD = \ +@DISABLE_PROCESSOR_FALSE@ src/common/path_helper.o \ @DISABLE_PROCESSOR_FALSE@ src/processor/basic_code_modules.o \ @DISABLE_PROCESSOR_FALSE@ src/processor/convert_old_arm64_context.o \ @DISABLE_PROCESSOR_FALSE@ src/processor/dump_context.o \ diff --git a/src/processor/minidump_dump.cc b/src/processor/minidump_dump.cc index 06802f24..ed2edaf0 100644 --- a/src/processor/minidump_dump.cc +++ b/src/processor/minidump_dump.cc @@ -36,6 +36,7 @@ #include #include +#include "common/path_helper.h" #include "common/scoped_ptr.h" #include "google_breakpad/processor/minidump.h" #include "processor/logging.h" @@ -233,7 +234,7 @@ Usage(int argc, char *argv[], bool error) { " should be a minidump.\n" " -x:\t Display memory in a hexdump like format\n" " -h:\t Usage\n", - argv[0]); + google_breakpad::BaseName(argv[0]).c_str()); } //============================================================================= diff --git a/src/tools/linux/core2md/core2md.cc b/src/tools/linux/core2md/core2md.cc index c3a9da39..723796c7 100644 --- a/src/tools/linux/core2md/core2md.cc +++ b/src/tools/linux/core2md/core2md.cc @@ -33,13 +33,15 @@ #include "client/linux/minidump_writer/minidump_writer.h" #include "client/linux/minidump_writer/linux_core_dumper.h" +#include "common/path_helper.h" using google_breakpad::AppMemoryList; using google_breakpad::MappingList; using google_breakpad::LinuxCoreDumper; static int ShowUsage(const char* argv0) { - fprintf(stderr, "Usage: %s \n", argv0); + fprintf(stderr, "Usage: %s \n", + google_breakpad::BaseName(argv0).c_str()); return 1; } diff --git a/src/tools/linux/core_handler/core_handler.cc b/src/tools/linux/core_handler/core_handler.cc index 3148cc53..975311d6 100644 --- a/src/tools/linux/core_handler/core_handler.cc +++ b/src/tools/linux/core_handler/core_handler.cc @@ -40,6 +40,7 @@ #include "client/linux/minidump_writer/linux_core_dumper.h" #include "client/linux/minidump_writer/minidump_writer.h" +#include "common/path_helper.h" #include "common/scoped_ptr.h" namespace { @@ -58,7 +59,8 @@ using google_breakpad::scoped_array; const int core_read_size = 1024 * 1024; void ShowUsage(const char* argv0) { - fprintf(stderr, "Usage: %s \n\n", argv0); + fprintf(stderr, "Usage: %s \n\n", + google_breakpad::BaseName(argv0).c_str()); fprintf(stderr, "A tool which serves as a core dump handler and produces " "minidump files.\n"); diff --git a/src/tools/linux/dump_syms/dump_syms.cc b/src/tools/linux/dump_syms/dump_syms.cc index 42e582c6..e101d470 100644 --- a/src/tools/linux/dump_syms/dump_syms.cc +++ b/src/tools/linux/dump_syms/dump_syms.cc @@ -37,13 +37,16 @@ #include #include "common/linux/dump_symbols.h" +#include "common/path_helper.h" using google_breakpad::WriteSymbolFile; using google_breakpad::WriteSymbolFileHeader; int usage(const char* self) { - fprintf(stderr, "Usage: %s [OPTION] " - "[directories-for-debug-file]\n\n", self); + fprintf(stderr, + "Usage: %s [OPTION] " + "[directories-for-debug-file]\n\n", + google_breakpad::BaseName(self).c_str()); fprintf(stderr, "Options:\n"); fprintf(stderr, " -i: Output module header information only.\n"); fprintf(stderr, " -c Do not generate CFI section\n"); diff --git a/src/tools/linux/pid2md/pid2md.cc b/src/tools/linux/pid2md/pid2md.cc index 0481997e..f9cc291e 100644 --- a/src/tools/linux/pid2md/pid2md.cc +++ b/src/tools/linux/pid2md/pid2md.cc @@ -34,10 +34,12 @@ #include #include "client/linux/minidump_writer/minidump_writer.h" +#include "common/path_helper.h" int main(int argc, char* argv[]) { if (argc != 3) { - fprintf(stderr, "Usage: %s \n\n", argv[0]); + fprintf(stderr, "Usage: %s \n\n", + google_breakpad::BaseName(argv[0]).c_str()); fprintf(stderr, "A tool to generate a minidump from a running process. The process " "resumes its\nactivity once the operation is completed. Permission " diff --git a/src/tools/linux/symupload/minidump_upload.cc b/src/tools/linux/symupload/minidump_upload.cc index f24e9716..44c3ef63 100644 --- a/src/tools/linux/symupload/minidump_upload.cc +++ b/src/tools/linux/symupload/minidump_upload.cc @@ -41,6 +41,7 @@ #include #include "common/linux/http_upload.h" +#include "common/path_helper.h" #include "common/using_std_string.h" using google_breakpad::HTTPUpload; @@ -91,8 +92,10 @@ static void Start(Options *options) { static void Usage(int argc, const char *argv[]) { fprintf(stderr, "Submit minidump information.\n"); - fprintf(stderr, "Usage: %s [options...] -p -v " - "\n", argv[0]); + fprintf(stderr, + "Usage: %s [options...] -p -v " + "\n", + google_breakpad::BaseName(argv[0]).c_str()); fprintf(stderr, "Options:\n"); fprintf(stderr, " should be a minidump.\n"); fprintf(stderr, " is the destination for the upload\n"); diff --git a/src/tools/linux/symupload/sym_upload.cc b/src/tools/linux/symupload/sym_upload.cc index 57df81cf..87f12966 100644 --- a/src/tools/linux/symupload/sym_upload.cc +++ b/src/tools/linux/symupload/sym_upload.cc @@ -47,6 +47,7 @@ #include #include "common/linux/symbol_upload.h" +#include "common/path_helper.h" using google_breakpad::sym_upload::UploadProtocol; using google_breakpad::sym_upload::Options; @@ -66,10 +67,11 @@ static void Usage(int argc, const char *argv[]) { fprintf(stderr, "Submit symbol information.\n"); fprintf(stderr, "Usage: %s [options...] \n", - argv[0]); + google_breakpad::BaseName(argv[0]).c_str()); fprintf(stderr, "Options:\n"); - fprintf(stderr, " should be created by using the dump_syms" - "tool.\n"); + fprintf(stderr, + " should be created by using the dump_syms " + "tool.\n"); fprintf(stderr, " is the destination for the upload\n"); fprintf(stderr, "-p:\t One of ['sym-upload-v1'," " 'sym-upload-v2'], defaults to 'sym-upload-v1'.\n");