aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/linux/android_link.h6
-rw-r--r--src/client/linux/handler/exception_handler.cc31
-rw-r--r--src/client/linux/log/log.cc48
-rw-r--r--src/client/linux/log/log.h41
-rw-r--r--src/client/linux/minidump_writer/minidump_writer.cc17
-rw-r--r--src/client/linux/minidump_writer/minidump_writer.h17
-rw-r--r--src/common/dwarf_cu_to_module.cc6
-rw-r--r--src/common/linux/file_id.cc3
-rw-r--r--src/common/linux/memory_mapped_file.cc8
-rw-r--r--src/tools/linux/core2md/core2md.cc18
10 files changed, 161 insertions, 34 deletions
diff --git a/src/client/linux/android_link.h b/src/client/linux/android_link.h
index 430ac3b6..32261fc2 100644
--- a/src/client/linux/android_link.h
+++ b/src/client/linux/android_link.h
@@ -33,7 +33,11 @@
#ifndef GOOGLE_BREAKPAD_CLIENT_LINUX_ANDROID_LINK_H_
#define GOOGLE_BREAKPAD_CLIENT_LINUX_ANDROID_LINK_H_
-#include <sys/exec_elf.h>
+// TODO(zhenghao): exec_elf.h conflicts with linux/elf.h.
+// But we still need ELFSIZE.
+//#include <sys/exec_elf.h>
+#include <machine/exec.h>
+#define ELFSIZE ARCH_ELFSIZE
#ifndef ElfW
#define ElfW(type) _ElfW (Elf, ELFSIZE, type)
diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc
index fff2d1c6..5d9e93f7 100644
--- a/src/client/linux/handler/exception_handler.cc
+++ b/src/client/linux/handler/exception_handler.cc
@@ -90,6 +90,7 @@
#include "common/linux/linux_libc_support.h"
#include "common/memory.h"
+#include "client/linux/log/log.h"
#include "client/linux/minidump_writer/linux_dumper.h"
#include "client/linux/minidump_writer/minidump_writer.h"
#include "common/linux/guid_creator.h"
@@ -391,14 +392,20 @@ bool ExceptionHandler::GenerateDump(CrashContext *context) {
// is the write() and read() calls will fail with EBADF
static const char no_pipe_msg[] = "ExceptionHandler::GenerateDump \
sys_pipe failed:";
- sys_write(2, no_pipe_msg, sizeof(no_pipe_msg) - 1);
- sys_write(2, strerror(errno), strlen(strerror(errno)));
- sys_write(2, "\n", 1);
+ logger::write(no_pipe_msg, sizeof(no_pipe_msg) - 1);
+ logger::write(strerror(errno), strlen(strerror(errno)));
+ logger::write("\n", 1);
}
+#if defined(__ANDROID__)
+ const pid_t child = clone(
+ ThreadEntry, stack, CLONE_FILES | CLONE_FS | CLONE_UNTRACED,
+ &thread_arg);
+#else
const pid_t child = sys_clone(
ThreadEntry, stack, CLONE_FILES | CLONE_FS | CLONE_UNTRACED,
&thread_arg, NULL, NULL, NULL);
+#endif
int r, status;
// Allow the child to ptrace us
sys_prctl(PR_SET_PTRACER, child);
@@ -412,9 +419,9 @@ bool ExceptionHandler::GenerateDump(CrashContext *context) {
if (r == -1) {
static const char msg[] = "ExceptionHandler::GenerateDump waitpid failed:";
- sys_write(2, msg, sizeof(msg) - 1);
- sys_write(2, strerror(errno), strlen(strerror(errno)));
- sys_write(2, "\n", 1);
+ logger::write(msg, sizeof(msg) - 1);
+ logger::write(strerror(errno), strlen(strerror(errno)));
+ logger::write("\n", 1);
}
bool success = r != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0;
@@ -434,9 +441,9 @@ void ExceptionHandler::SendContinueSignalToChild() {
if(r == -1) {
static const char msg[] = "ExceptionHandler::SendContinueSignalToChild \
sys_write failed:";
- sys_write(2, msg, sizeof(msg) - 1);
- sys_write(2, strerror(errno), strlen(strerror(errno)));
- sys_write(2, "\n", 1);
+ logger::write(msg, sizeof(msg) - 1);
+ logger::write(strerror(errno), strlen(strerror(errno)));
+ logger::write("\n", 1);
}
}
@@ -449,9 +456,9 @@ void ExceptionHandler::WaitForContinueSignal() {
if(r == -1) {
static const char msg[] = "ExceptionHandler::WaitForContinueSignal \
sys_read failed:";
- sys_write(2, msg, sizeof(msg) - 1);
- sys_write(2, strerror(errno), strlen(strerror(errno)));
- sys_write(2, "\n", 1);
+ logger::write(msg, sizeof(msg) - 1);
+ logger::write(strerror(errno), strlen(strerror(errno)));
+ logger::write("\n", 1);
}
}
diff --git a/src/client/linux/log/log.cc b/src/client/linux/log/log.cc
new file mode 100644
index 00000000..18635913
--- /dev/null
+++ b/src/client/linux/log/log.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 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.
+
+#include "client/linux/log/log.h"
+
+#if defined(__ANDROID__)
+#include <android/log.h>
+#else
+#include "third_party/lss/linux_syscall_support.h"
+#endif
+
+namespace logger {
+
+int write(const char* buf, size_t nbytes) {
+#if defined(__ANDROID__)
+ return __android_log_write(ANDROID_LOG_WARN, "google-breakpad", buf);
+#else
+ return sys_write(2, buf, nbytes);
+#endif
+}
+
+} // namespace logger
diff --git a/src/client/linux/log/log.h b/src/client/linux/log/log.h
new file mode 100644
index 00000000..a50e30dc
--- /dev/null
+++ b/src/client/linux/log/log.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2012, 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.
+
+#ifndef CLIENT_LINUX_LOG_LOG_H_
+#define CLIENT_LINUX_LOG_LOG_H_
+
+#include <stddef.h>
+
+namespace logger {
+
+int write(const char* buf, size_t nbytes);
+
+} // namespace logger
+
+#endif // CLIENT_LINUX_LOG_LOG_H_
diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc
index a9d4927b..35a291db 100644
--- a/src/client/linux/minidump_writer/minidump_writer.cc
+++ b/src/client/linux/minidump_writer/minidump_writer.cc
@@ -46,19 +46,19 @@
#include "client/linux/minidump_writer/minidump_writer.h"
#include "client/minidump_file_writer-inl.h"
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#if !defined(__ANDROID__)
#include <link.h>
#endif
#include <stdio.h>
-#include <unistd.h>
-#include <ctype.h>
#if !defined(__ANDROID__)
#include <sys/ucontext.h>
#include <sys/user.h>
#endif
#include <sys/utsname.h>
+#include <unistd.h>
#include <algorithm>
@@ -72,10 +72,11 @@
#include "client/linux/handler/exception_handler.h"
#include "client/linux/minidump_writer/line_reader.h"
#include "client/linux/minidump_writer/linux_dumper.h"
-#include "client/linux/minidump_writer/linux_core_dumper.h"
#include "client/linux/minidump_writer/linux_ptrace_dumper.h"
#include "client/linux/minidump_writer/minidump_extension_linux.h"
+#include "client/minidump_file_writer.h"
#include "common/linux/linux_libc_support.h"
+#include "google_breakpad/common/minidump_format.h"
#include "third_party/lss/linux_syscall_support.h"
// Minidump defines register structures which are different from the raw
@@ -1336,12 +1337,10 @@ bool WriteMinidump(const char* filename, pid_t crashing_process,
return writer.Dump();
}
-bool WriteMinidumpFromCore(const char* filename,
- const char* core_path,
- const char* procfs_override) {
- MappingList mappings;
- LinuxCoreDumper dumper(0, core_path, procfs_override);
- MinidumpWriter writer(filename, NULL, mappings, &dumper);
+bool WriteMinidump(const char* filename,
+ const MappingList& mappings,
+ LinuxDumper* dumper) {
+ MinidumpWriter writer(filename, NULL, mappings, dumper);
if (!writer.Init())
return false;
return writer.Dump();
diff --git a/src/client/linux/minidump_writer/minidump_writer.h b/src/client/linux/minidump_writer/minidump_writer.h
index 731249e3..e79eb79b 100644
--- a/src/client/linux/minidump_writer/minidump_writer.h
+++ b/src/client/linux/minidump_writer/minidump_writer.h
@@ -36,12 +36,19 @@
#include <list>
#include <utility>
+#include "client/linux/minidump_writer/linux_dumper.h"
#include "google_breakpad/common/minidump_format.h"
namespace google_breakpad {
+class ExceptionHandler;
+
+struct MappingEntry {
+ MappingInfo first;
+ u_int8_t second[sizeof(MDGUID)];
+};
+
// A list of <MappingInfo, GUID>
-typedef std::pair<struct MappingInfo, u_int8_t[sizeof(MDGUID)]> MappingEntry;
typedef std::list<MappingEntry> MappingList;
// Write a minidump to the filesystem. This function does not malloc nor use
@@ -62,11 +69,9 @@ bool WriteMinidump(const char* filename, pid_t crashing_process,
const void* blob, size_t blob_size,
const MappingList& mappings);
-// Write a minidump to the filesystem. Same as above, but uses the given
-// core file and procfs directory to generate the minidump post mortem.
-bool WriteMinidumpFromCore(const char* filename,
- const char* core_path,
- const char* procfs_override);
+bool WriteMinidump(const char* filename,
+ const MappingList& mappings,
+ LinuxDumper* dumper);
} // namespace google_breakpad
diff --git a/src/common/dwarf_cu_to_module.cc b/src/common/dwarf_cu_to_module.cc
index 2a8b76ba..e3100a12 100644
--- a/src/common/dwarf_cu_to_module.cc
+++ b/src/common/dwarf_cu_to_module.cc
@@ -440,7 +440,11 @@ void DwarfCUToModule::FuncHandler::Finish() {
func->address = low_pc_;
func->size = high_pc_ - low_pc_;
func->parameter_size = 0;
- cu_context_->functions.push_back(func);
+ if (func->address) {
+ // If the function address is zero this is a sign that this function
+ // description is just empty debug data and should just be discarded.
+ cu_context_->functions.push_back(func);
+ }
} else if (inline_) {
AbstractOrigin origin(name_);
cu_context_->file_context->file_private->origins[offset_] = origin;
diff --git a/src/common/linux/file_id.cc b/src/common/linux/file_id.cc
index bffef621..ff2f29e2 100644
--- a/src/common/linux/file_id.cc
+++ b/src/common/linux/file_id.cc
@@ -36,10 +36,11 @@
#include <arpa/inet.h>
#include <assert.h>
-#include <elf.h>
#if defined(__ANDROID__)
+#include <linux/elf.h>
#include "client/linux/android_link.h"
#else
+#include <elf.h>
#include <link.h>
#endif
#include <string.h>
diff --git a/src/common/linux/memory_mapped_file.cc b/src/common/linux/memory_mapped_file.cc
index 6f450bd3..32fc3b18 100644
--- a/src/common/linux/memory_mapped_file.cc
+++ b/src/common/linux/memory_mapped_file.cc
@@ -34,6 +34,9 @@
#include <fcntl.h>
#include <sys/mman.h>
+#if defined(__ANDROID__)
+#include <sys/stat.h>
+#endif
#include <unistd.h>
#include "common/memory_range.h"
@@ -59,7 +62,10 @@ bool MemoryMappedFile::Map(const char* path) {
return false;
}
-#if defined(__x86_64__)
+#if defined(__ANDROID__)
+ struct stat st;
+ if (fstat(fd, &st) != 0) {
+#elif defined(__x86_64__)
struct kernel_stat st;
if (sys_fstat(fd, &st) == -1 || st.st_size < 0) {
#else
diff --git a/src/tools/linux/core2md/core2md.cc b/src/tools/linux/core2md/core2md.cc
index c8060b5e..641496ee 100644
--- a/src/tools/linux/core2md/core2md.cc
+++ b/src/tools/linux/core2md/core2md.cc
@@ -32,12 +32,24 @@
#include <stdio.h>
#include "client/linux/minidump_writer/minidump_writer.h"
+#include "client/linux/minidump_writer/linux_core_dumper.h"
+
+using google_breakpad::MappingList;
+using google_breakpad::LinuxCoreDumper;
static int ShowUsage(const char* argv0) {
fprintf(stderr, "Usage: %s <core file> <procfs dir> <output>\n", argv0);
return 1;
}
+bool WriteMinidumpFromCore(const char* filename,
+ const char* core_path,
+ const char* procfs_override) {
+ MappingList mappings;
+ LinuxCoreDumper dumper(0, core_path, procfs_override);
+ return google_breakpad::WriteMinidump(filename, mappings, &dumper);
+}
+
int main(int argc, char *argv[]) {
if (argc != 4) {
return ShowUsage(argv[0]);
@@ -46,9 +58,9 @@ int main(int argc, char *argv[]) {
const char* core_file = argv[1];
const char* procfs_dir = argv[2];
const char* minidump_file = argv[3];
- if (!google_breakpad::WriteMinidumpFromCore(minidump_file,
- core_file,
- procfs_dir)) {
+ if (!WriteMinidumpFromCore(minidump_file,
+ core_file,
+ procfs_dir)) {
fprintf(stderr, "Unable to generate minidump.\n");
return 1;
}