mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-28 00:04:16 +01:00
pid2md: generate a minidump from a running process
On Linux, this tool generates a minidump for given process. It requires the permission to trace the process and access its /proc directory. This is useful when a defective behavior of a process does not lead to a crash. For example, it can be used by a watchdog or if a process does not correctly respond to a termination request. Change-Id: Iab501e42c064a537aea62831c471e395ff697186 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2539920 Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
bd4a28c08b
commit
78f7ae495b
@ -356,6 +356,7 @@ CLEANFILES += \
|
||||
if !DISABLE_TOOLS
|
||||
bin_PROGRAMS += \
|
||||
src/tools/linux/core2md/core2md \
|
||||
src/tools/linux/pid2md/pid2md \
|
||||
src/tools/linux/dump_syms/dump_syms \
|
||||
src/tools/linux/md2core/minidump-2-core \
|
||||
src/tools/linux/symupload/minidump_upload \
|
||||
@ -579,6 +580,12 @@ src_tools_linux_core_handler_core_handler_SOURCES = \
|
||||
src_tools_linux_core_handler_core_handler_LDADD = \
|
||||
src/client/linux/libbreakpad_client.a
|
||||
|
||||
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_tools_linux_dump_syms_dump_syms_SOURCES = \
|
||||
src/common/dwarf_cfi_to_module.cc \
|
||||
src/common/dwarf_cu_to_module.cc \
|
||||
|
37
Makefile.in
37
Makefile.in
@ -156,6 +156,7 @@ EXTRA_PROGRAMS = $(am__EXEEXT_1)
|
||||
@LINUX_HOST_TRUE@ src/client/linux/linux_client_unittest_shlib
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__append_13 = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/core2md/core2md \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/pid2md/pid2md \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/dump_syms/dump_syms \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/md2core/minidump-2-core \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/minidump_upload \
|
||||
@ -556,6 +557,7 @@ src_third_party_libdisasm_libdisasm_a_OBJECTS = \
|
||||
@DISABLE_PROCESSOR_FALSE@ src/processor/minidump_dump$(EXEEXT) \
|
||||
@DISABLE_PROCESSOR_FALSE@ src/processor/minidump_stackwalk$(EXEEXT)
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__EXEEXT_3 = src/tools/linux/core2md/core2md$(EXEEXT) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/pid2md/pid2md$(EXEEXT) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/dump_syms/dump_syms$(EXEEXT) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/md2core/minidump-2-core$(EXEEXT) \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/symupload/minidump_upload$(EXEEXT) \
|
||||
@ -1491,6 +1493,12 @@ src_tools_linux_md2core_minidump_2_core_unittest_OBJECTS = $(am_src_tools_linux_
|
||||
@LINUX_HOST_TRUE@src_tools_linux_md2core_minidump_2_core_unittest_DEPENDENCIES = \
|
||||
@LINUX_HOST_TRUE@ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
|
||||
@LINUX_HOST_TRUE@ $(am__DEPENDENCIES_1)
|
||||
am__src_tools_linux_pid2md_pid2md_SOURCES_DIST = \
|
||||
src/tools/linux/pid2md/pid2md.cc
|
||||
@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
|
||||
am__src_tools_linux_symupload_minidump_upload_SOURCES_DIST = \
|
||||
src/common/linux/http_upload.cc \
|
||||
src/tools/linux/symupload/minidump_upload.cc
|
||||
@ -1666,6 +1674,7 @@ SOURCES = $(src_client_linux_libbreakpad_client_a_SOURCES) \
|
||||
$(src_tools_linux_dump_syms_dump_syms_SOURCES) \
|
||||
$(src_tools_linux_md2core_minidump_2_core_SOURCES) \
|
||||
$(src_tools_linux_md2core_minidump_2_core_unittest_SOURCES) \
|
||||
$(src_tools_linux_pid2md_pid2md_SOURCES) \
|
||||
$(src_tools_linux_symupload_minidump_upload_SOURCES) \
|
||||
$(src_tools_linux_symupload_sym_upload_SOURCES) \
|
||||
$(src_tools_mac_dump_syms_dump_syms_mac_SOURCES)
|
||||
@ -1719,6 +1728,7 @@ DIST_SOURCES = \
|
||||
$(am__src_tools_linux_dump_syms_dump_syms_SOURCES_DIST) \
|
||||
$(am__src_tools_linux_md2core_minidump_2_core_SOURCES_DIST) \
|
||||
$(am__src_tools_linux_md2core_minidump_2_core_unittest_SOURCES_DIST) \
|
||||
$(am__src_tools_linux_pid2md_pid2md_SOURCES_DIST) \
|
||||
$(am__src_tools_linux_symupload_minidump_upload_SOURCES_DIST) \
|
||||
$(am__src_tools_linux_symupload_sym_upload_SOURCES_DIST) \
|
||||
$(am__src_tools_mac_dump_syms_dump_syms_mac_SOURCES_DIST)
|
||||
@ -2450,6 +2460,12 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_LDADD = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a
|
||||
|
||||
@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_tools_linux_dump_syms_dump_syms_SOURCES = \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/dwarf_cfi_to_module.cc \
|
||||
@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/common/dwarf_cu_to_module.cc \
|
||||
@ -4782,6 +4798,19 @@ src/tools/linux/md2core/src_tools_linux_md2core_minidump_2_core_unittest-minidum
|
||||
src/tools/linux/md2core/minidump_2_core_unittest$(EXEEXT): $(src_tools_linux_md2core_minidump_2_core_unittest_OBJECTS) $(src_tools_linux_md2core_minidump_2_core_unittest_DEPENDENCIES) $(EXTRA_src_tools_linux_md2core_minidump_2_core_unittest_DEPENDENCIES) src/tools/linux/md2core/$(am__dirstamp)
|
||||
@rm -f src/tools/linux/md2core/minidump_2_core_unittest$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(src_tools_linux_md2core_minidump_2_core_unittest_OBJECTS) $(src_tools_linux_md2core_minidump_2_core_unittest_LDADD) $(LIBS)
|
||||
src/tools/linux/pid2md/$(am__dirstamp):
|
||||
@$(MKDIR_P) src/tools/linux/pid2md
|
||||
@: > src/tools/linux/pid2md/$(am__dirstamp)
|
||||
src/tools/linux/pid2md/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) src/tools/linux/pid2md/$(DEPDIR)
|
||||
@: > src/tools/linux/pid2md/$(DEPDIR)/$(am__dirstamp)
|
||||
src/tools/linux/pid2md/pid2md.$(OBJEXT): \
|
||||
src/tools/linux/pid2md/$(am__dirstamp) \
|
||||
src/tools/linux/pid2md/$(DEPDIR)/$(am__dirstamp)
|
||||
|
||||
src/tools/linux/pid2md/pid2md$(EXEEXT): $(src_tools_linux_pid2md_pid2md_OBJECTS) $(src_tools_linux_pid2md_pid2md_DEPENDENCIES) $(EXTRA_src_tools_linux_pid2md_pid2md_DEPENDENCIES) src/tools/linux/pid2md/$(am__dirstamp)
|
||||
@rm -f src/tools/linux/pid2md/pid2md$(EXEEXT)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(src_tools_linux_pid2md_pid2md_OBJECTS) $(src_tools_linux_pid2md_pid2md_LDADD) $(LIBS)
|
||||
src/common/linux/http_upload.$(OBJEXT): \
|
||||
src/common/linux/$(am__dirstamp) \
|
||||
src/common/linux/$(DEPDIR)/$(am__dirstamp)
|
||||
@ -4914,6 +4943,7 @@ mostlyclean-compile:
|
||||
-rm -f src/tools/linux/core_handler/*.$(OBJEXT)
|
||||
-rm -f src/tools/linux/dump_syms/*.$(OBJEXT)
|
||||
-rm -f src/tools/linux/md2core/*.$(OBJEXT)
|
||||
-rm -f src/tools/linux/pid2md/*.$(OBJEXT)
|
||||
-rm -f src/tools/linux/symupload/*.$(OBJEXT)
|
||||
-rm -f src/tools/mac/dump_syms/*.$(OBJEXT)
|
||||
|
||||
@ -5203,6 +5233,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/tools/linux/dump_syms/$(DEPDIR)/src_tools_linux_dump_syms_dump_syms-dump_syms.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/tools/linux/md2core/$(DEPDIR)/minidump-2-core.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/tools/linux/md2core/$(DEPDIR)/src_tools_linux_md2core_minidump_2_core_unittest-minidump_memory_range_unittest.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/tools/linux/pid2md/$(DEPDIR)/pid2md.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/tools/linux/symupload/$(DEPDIR)/minidump_upload.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/tools/linux/symupload/$(DEPDIR)/sym_upload.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/tools/mac/dump_syms/$(DEPDIR)/src_tools_mac_dump_syms_dump_syms_mac-dump_syms_tool.Po@am__quote@
|
||||
@ -8911,6 +8942,8 @@ distclean-generic:
|
||||
-rm -f src/tools/linux/dump_syms/$(am__dirstamp)
|
||||
-rm -f src/tools/linux/md2core/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f src/tools/linux/md2core/$(am__dirstamp)
|
||||
-rm -f src/tools/linux/pid2md/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f src/tools/linux/pid2md/$(am__dirstamp)
|
||||
-rm -f src/tools/linux/symupload/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f src/tools/linux/symupload/$(am__dirstamp)
|
||||
-rm -f src/tools/mac/dump_syms/$(DEPDIR)/$(am__dirstamp)
|
||||
@ -8927,7 +8960,7 @@ clean-am: clean-binPROGRAMS clean-checkLIBRARIES clean-checkPROGRAMS \
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf src/client/$(DEPDIR) src/client/linux/crash_generation/$(DEPDIR) src/client/linux/dump_writer_common/$(DEPDIR) src/client/linux/handler/$(DEPDIR) src/client/linux/log/$(DEPDIR) src/client/linux/microdump_writer/$(DEPDIR) src/client/linux/minidump_writer/$(DEPDIR) src/common/$(DEPDIR) src/common/dwarf/$(DEPDIR) src/common/linux/$(DEPDIR) src/common/linux/tests/$(DEPDIR) src/common/mac/$(DEPDIR) src/common/tests/$(DEPDIR) src/processor/$(DEPDIR) src/testing/googlemock/src/$(DEPDIR) src/testing/googletest/src/$(DEPDIR) src/third_party/libdisasm/$(DEPDIR) src/tools/linux/core2md/$(DEPDIR) src/tools/linux/core_handler/$(DEPDIR) src/tools/linux/dump_syms/$(DEPDIR) src/tools/linux/md2core/$(DEPDIR) src/tools/linux/symupload/$(DEPDIR) src/tools/mac/dump_syms/$(DEPDIR)
|
||||
-rm -rf src/client/$(DEPDIR) src/client/linux/crash_generation/$(DEPDIR) src/client/linux/dump_writer_common/$(DEPDIR) src/client/linux/handler/$(DEPDIR) src/client/linux/log/$(DEPDIR) src/client/linux/microdump_writer/$(DEPDIR) src/client/linux/minidump_writer/$(DEPDIR) src/common/$(DEPDIR) src/common/dwarf/$(DEPDIR) src/common/linux/$(DEPDIR) src/common/linux/tests/$(DEPDIR) src/common/mac/$(DEPDIR) src/common/tests/$(DEPDIR) src/processor/$(DEPDIR) src/testing/googlemock/src/$(DEPDIR) src/testing/googletest/src/$(DEPDIR) src/third_party/libdisasm/$(DEPDIR) src/tools/linux/core2md/$(DEPDIR) src/tools/linux/core_handler/$(DEPDIR) src/tools/linux/dump_syms/$(DEPDIR) src/tools/linux/md2core/$(DEPDIR) src/tools/linux/pid2md/$(DEPDIR) src/tools/linux/symupload/$(DEPDIR) src/tools/mac/dump_syms/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-tags
|
||||
@ -8981,7 +9014,7 @@ installcheck-am:
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -rf src/client/$(DEPDIR) src/client/linux/crash_generation/$(DEPDIR) src/client/linux/dump_writer_common/$(DEPDIR) src/client/linux/handler/$(DEPDIR) src/client/linux/log/$(DEPDIR) src/client/linux/microdump_writer/$(DEPDIR) src/client/linux/minidump_writer/$(DEPDIR) src/common/$(DEPDIR) src/common/dwarf/$(DEPDIR) src/common/linux/$(DEPDIR) src/common/linux/tests/$(DEPDIR) src/common/mac/$(DEPDIR) src/common/tests/$(DEPDIR) src/processor/$(DEPDIR) src/testing/googlemock/src/$(DEPDIR) src/testing/googletest/src/$(DEPDIR) src/third_party/libdisasm/$(DEPDIR) src/tools/linux/core2md/$(DEPDIR) src/tools/linux/core_handler/$(DEPDIR) src/tools/linux/dump_syms/$(DEPDIR) src/tools/linux/md2core/$(DEPDIR) src/tools/linux/symupload/$(DEPDIR) src/tools/mac/dump_syms/$(DEPDIR)
|
||||
-rm -rf src/client/$(DEPDIR) src/client/linux/crash_generation/$(DEPDIR) src/client/linux/dump_writer_common/$(DEPDIR) src/client/linux/handler/$(DEPDIR) src/client/linux/log/$(DEPDIR) src/client/linux/microdump_writer/$(DEPDIR) src/client/linux/minidump_writer/$(DEPDIR) src/common/$(DEPDIR) src/common/dwarf/$(DEPDIR) src/common/linux/$(DEPDIR) src/common/linux/tests/$(DEPDIR) src/common/mac/$(DEPDIR) src/common/tests/$(DEPDIR) src/processor/$(DEPDIR) src/testing/googlemock/src/$(DEPDIR) src/testing/googletest/src/$(DEPDIR) src/third_party/libdisasm/$(DEPDIR) src/tools/linux/core2md/$(DEPDIR) src/tools/linux/core_handler/$(DEPDIR) src/tools/linux/dump_syms/$(DEPDIR) src/tools/linux/md2core/$(DEPDIR) src/tools/linux/pid2md/$(DEPDIR) src/tools/linux/symupload/$(DEPDIR) src/tools/mac/dump_syms/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
|
57
src/tools/linux/pid2md/pid2md.cc
Normal file
57
src/tools/linux/pid2md/pid2md.cc
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2020, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// pid2md.cc: An utility to generate a minidump from a running process
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "client/linux/minidump_writer/minidump_writer.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: %s <process id> <minidump file>\n\n", argv[0]);
|
||||
fprintf(stderr,
|
||||
"A tool to generate a minidump from a running process. The process "
|
||||
"resumes its\nactivity once the operation is completed. Permission "
|
||||
"to trace the process is\nrequired.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
pid_t process_id = atoi(argv[1]);
|
||||
const char* minidump_file = argv[2];
|
||||
|
||||
if (!google_breakpad::WriteMinidump(minidump_file, process_id, process_id)) {
|
||||
fprintf(stderr, "Unable to generate minidump.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user