From 096992fac73756cfa0974a94754329f30fd4e786 Mon Sep 17 00:00:00 2001 From: nealsid Date: Tue, 1 Dec 2009 21:35:52 +0000 Subject: [PATCH] Upstreaming several patches from Chrome: Build fix for systems where sys/user.h needs sys/types.h.... http://breakpad.appspot.com/40002 MDRawSystemInfo.processor_level refers to the CPU family, not the cpuid level.. http://breakpad.appspot.com/40003 Use MD_MODULE_SIZE in place of sizeof(MDRawModule). http://breakpad.appspot.com/39003 Linux x64 compile fix. http://breakpad.appspot.com/40004 Include linux_syscall_support.h to get definition of NT_PRXFPREG. This is Chromium commit 23659. http://breakpad.appspot.com/40005 Build breakpad / crash reporting on Linux 64-bit. This is Chromium commit 23396. http://breakpad.appspot.com/40006 Fix #includes in a couple unit tests. http://breakpad.appspot.com/41001 Clean up unused headers / files for Linux dump_syms. http://breakpad.appspot.com/40002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@432 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../linux/handler/exception_handler_unittest.cc | 4 ++-- src/client/linux/minidump_writer/linux_dumper.cc | 4 +++- src/client/linux/minidump_writer/linux_dumper.h | 10 +++++++--- .../linux/minidump_writer/minidump_writer.cc | 16 ++++++++-------- src/common/linux/dump_symbols.cc | 4 +--- src/common/linux/linux_libc_support_unittest.cc | 2 +- src/common/linux/memory.h | 5 +++++ src/common/linux/memory_unittest.cc | 2 +- src/tools/linux/dump_syms/Makefile | 9 +-------- src/tools/linux/md2core/minidump-2-core.cc | 5 +++-- 10 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc index 157c495a..2f4e1045 100644 --- a/src/client/linux/handler/exception_handler_unittest.cc +++ b/src/client/linux/handler/exception_handler_unittest.cc @@ -84,7 +84,7 @@ static bool DoneCallback(const char* dump_path, if (!succeeded) return succeeded; - int fd = (int) context; + int fd = (intptr_t) context; uint32_t len = my_strlen(minidump_id); HANDLE_EINTR(sys_write(fd, &len, sizeof(len))); HANDLE_EINTR(sys_write(fd, minidump_id, len)); @@ -143,7 +143,7 @@ static const unsigned kControlMsgSize = static bool CrashHandler(const void* crash_context, size_t crash_context_size, void* context) { - const int fd = (int) context; + const int fd = (intptr_t) context; int fds[2]; pipe(fds); diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc index e821db7d..86ebb866 100644 --- a/src/client/linux/minidump_writer/linux_dumper.cc +++ b/src/client/linux/minidump_writer/linux_dumper.cc @@ -316,10 +316,12 @@ bool LinuxDumper::ThreadInfoGet(pid_t tid, ThreadInfo* info) { return false; } -#if defined(__i386) || defined(__x86_64) +#if defined(__i386) if (sys_ptrace(PTRACE_GETFPXREGS, tid, NULL, &info->fpxregs) == -1) return false; +#endif +#if defined(__i386) || defined(__x86_64) for (unsigned i = 0; i < ThreadInfo::kNumDebugRegisters; ++i) { if (sys_ptrace( PTRACE_PEEKUSER, tid, diff --git a/src/client/linux/minidump_writer/linux_dumper.h b/src/client/linux/minidump_writer/linux_dumper.h index 252e9ee6..d8e5e783 100644 --- a/src/client/linux/minidump_writer/linux_dumper.h +++ b/src/client/linux/minidump_writer/linux_dumper.h @@ -31,9 +31,10 @@ #define CLIENT_LINUX_MINIDUMP_WRITER_LINUX_DUMPER_H_ #include -#include -#include #include +#include +#include +#include #include "common/linux/memory.h" @@ -64,8 +65,11 @@ struct ThreadInfo { user_regs_struct regs; user_fpregs_struct fpregs; -#if defined(__i386) || defined(__x86_64) +#if defined(__i386) user_fpxregs_struct fpxregs; +#endif + +#if defined(__i386) || defined(__x86_64) static const unsigned kNumDebugRegisters = 8; debugreg_t dregs[8]; diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc index a99309f3..10041f77 100644 --- a/src/client/linux/minidump_writer/minidump_writer.cc +++ b/src/client/linux/minidump_writer/minidump_writer.cc @@ -248,21 +248,21 @@ static void CPUFillFromThreadInfo(MDRawContextAMD64 *out, out->flt_save.control_word = info.fpregs.cwd; out->flt_save.status_word = info.fpregs.swd; - out->flt_save.tag_word = info.fpregs.twd; + out->flt_save.tag_word = info.fpregs.ftw; out->flt_save.error_opcode = info.fpregs.fop; out->flt_save.error_offset = info.fpregs.rip; out->flt_save.error_selector = 0; // We don't have this. out->flt_save.data_offset = info.fpregs.rdp; out->flt_save.data_selector = 0; // We don't have this. out->flt_save.mx_csr = info.fpregs.mxcsr; - out->flt_save.mx_csr_mask = info.fpregs.mxcsr_mask; + out->flt_save.mx_csr_mask = info.fpregs.mxcr_mask; memcpy(&out->flt_save.float_registers, &info.fpregs.st_space, 8 * 16); memcpy(&out->flt_save.xmm_registers, &info.fpregs.xmm_space, 16 * 16); } static void CPUFillFromUContext(MDRawContextAMD64 *out, const ucontext *uc, const struct _libc_fpstate* fpregs) { - const greg_t* regs = uc->gregs; + const greg_t* regs = uc->uc_mcontext.gregs; out->context_flags = MD_CONTEXT_AMD64_FULL; @@ -302,7 +302,7 @@ static void CPUFillFromUContext(MDRawContextAMD64 *out, const ucontext *uc, out->flt_save.error_selector = 0; // We don't have this. out->flt_save.data_selector = 0; // We don't have this. out->flt_save.mx_csr = fpregs->mxcsr; - out->flt_save.mx_csr_mask = fpregs->mxcsr_mask; + out->flt_save.mx_csr_mask = fpregs->mxcr_mask; memcpy(&out->flt_save.float_registers, &fpregs->_st, 8 * 16); memcpy(&out->flt_save.xmm_registers, &fpregs->_xmm, 16 * 16); } @@ -510,7 +510,7 @@ class MinidumpWriter { } TypedMDRVA list(&minidump_writer_); - if (!list.AllocateObjectAndArray(num_output_mappings, sizeof(MDRawModule))) + if (!list.AllocateObjectAndArray(num_output_mappings, MD_MODULE_SIZE)) return false; dirent->stream_type = MD_MODULE_LIST_STREAM; @@ -523,7 +523,7 @@ class MinidumpWriter { continue; MDRawModule mod; - my_memset(&mod, 0, sizeof(mod)); + my_memset(&mod, 0, MD_MODULE_SIZE); mod.base_of_image = mapping.start_addr; mod.size_of_image = mapping.size; const size_t filepath_len = my_strlen(mapping.name); @@ -579,7 +579,7 @@ class MinidumpWriter { return false; mod.module_name_rva = ld.rva; - list.CopyIndexAfterObject(j++, &mod, sizeof(mod)); + list.CopyIndexAfterObject(j++, &mod, MD_MODULE_SIZE); } return true; @@ -650,7 +650,7 @@ class MinidumpWriter { { "processor", -1, false }, { "model", 0, false }, { "stepping", 0, false }, - { "cpuid level", 0, false }, + { "cpu family", 0, false }, }; // processor_architecture should always be set, do this first diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index 64fcb34b..a7888189 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -52,10 +52,8 @@ #include "common/linux/dump_symbols.h" #include "common/linux/file_id.h" -#include "common/linux/guid_creator.h" #include "common/linux/module.h" #include "common/linux/stabs_reader.h" -#include "processor/scoped_ptr.h" // This namespace contains helper functions. namespace { @@ -82,7 +80,7 @@ static std::string Demangle(const std::string &mangled) { // Fix offset into virtual address by adding the mapped base into offsets. // Make life easier when want to find something by offset. static void FixAddress(void *obj_base) { - ElfW(Word) base = reinterpret_cast(obj_base); + ElfW(Addr) base = reinterpret_cast(obj_base); ElfW(Ehdr) *elf_header = static_cast(obj_base); elf_header->e_phoff += base; elf_header->e_shoff += base; diff --git a/src/common/linux/linux_libc_support_unittest.cc b/src/common/linux/linux_libc_support_unittest.cc index 3b5d6114..d3907e94 100644 --- a/src/common/linux/linux_libc_support_unittest.cc +++ b/src/common/linux/linux_libc_support_unittest.cc @@ -27,7 +27,7 @@ // (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 "breakpad/linux/linux_libc_support.h" +#include "common/linux/linux_libc_support.h" #include "testing/gtest/include/gtest/gtest.h" namespace { diff --git a/src/common/linux/memory.h b/src/common/linux/memory.h index 7cae40ef..f10a194b 100644 --- a/src/common/linux/memory.h +++ b/src/common/linux/memory.h @@ -86,8 +86,13 @@ class PageAllocator { private: uint8_t *GetNPages(unsigned num_pages) { +#ifdef __x86_64 + void *a = sys_mmap(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +#else void *a = sys_mmap2(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +#endif if (a == MAP_FAILED) return NULL; diff --git a/src/common/linux/memory_unittest.cc b/src/common/linux/memory_unittest.cc index 22b64398..66c83465 100644 --- a/src/common/linux/memory_unittest.cc +++ b/src/common/linux/memory_unittest.cc @@ -27,7 +27,7 @@ // (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 "breakpad/linux/memory.h" +#include "common/linux/memory.h" #include "testing/gtest/include/gtest/gtest.h" using namespace google_breakpad; diff --git a/src/tools/linux/dump_syms/Makefile b/src/tools/linux/dump_syms/Makefile index 59db7374..289dc4d8 100644 --- a/src/tools/linux/dump_syms/Makefile +++ b/src/tools/linux/dump_syms/Makefile @@ -16,8 +16,7 @@ BIN=dump_syms all:$(BIN) -DUMP_OBJ=dump_symbols.o guid_creator.o dump_syms.o file_id.o md5.o \ - stabs_reader.o module.o +DUMP_OBJ=dump_symbols.o dump_syms.o file_id.o stabs_reader.o module.o dump_syms:$(DUMP_OBJ) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ @@ -31,14 +30,8 @@ stabs_reader.o:../../../common/linux/stabs_reader.cc module.o:../../../common/linux/module.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^ -guid_creator.o:../../../common/linux/guid_creator.cc - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^ - file_id.o:../../../common/linux/file_id.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^ -md5.o:../../../common/md5.c - $(CC) $(CPPFLAGS) $(CXXFLAGS) -c $^ - clean: rm -f $(BIN) $(DUMP_OBJ) diff --git a/src/tools/linux/md2core/minidump-2-core.cc b/src/tools/linux/md2core/minidump-2-core.cc index e333d119..29ae3280 100644 --- a/src/tools/linux/md2core/minidump-2-core.cc +++ b/src/tools/linux/md2core/minidump-2-core.cc @@ -47,7 +47,8 @@ #include "google_breakpad/common/minidump_format.h" #include "google_breakpad/common/minidump_cpu_x86.h" -#include "breakpad/linux/minidump_format_linux.h" +#include "common/linux/linux_syscall_support.h" +#include "common/linux/minidump_format_linux.h" #if __WORDSIZE == 64 #define ELF_CLASS ELFCLASS64 @@ -419,7 +420,7 @@ ParseModuleStream(CrashedProcess* crashinfo, MMappedRange range) { CrashedProcess::Mapping mapping; const MDRawModule* rawmodule = (MDRawModule*) range.GetArrayElement(sizeof(uint32_t), - sizeof(MDRawModule), i); + MD_MODULE_SIZE, i); mapping.start_address = rawmodule->base_of_image; mapping.end_address = rawmodule->size_of_image + rawmodule->base_of_image;