OLD | NEW |
1 // Copyright (c) 2012, Google Inc. | 1 // Copyright (c) 2012, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 20 matching lines...) Expand all Loading... |
31 // See linux_core_dumper.h for details. | 31 // See linux_core_dumper.h for details. |
32 | 32 |
33 #include "client/linux/minidump_writer/linux_core_dumper.h" | 33 #include "client/linux/minidump_writer/linux_core_dumper.h" |
34 | 34 |
35 #include <asm/ptrace.h> | 35 #include <asm/ptrace.h> |
36 #include <assert.h> | 36 #include <assert.h> |
37 #include <elf.h> | 37 #include <elf.h> |
38 #include <stdio.h> | 38 #include <stdio.h> |
39 #include <string.h> | 39 #include <string.h> |
40 #include <sys/procfs.h> | 40 #include <sys/procfs.h> |
| 41 #if defined(__mips__) && defined(__ANDROID__) |
| 42 // To get register definitions. |
| 43 #include <asm/reg.h> |
| 44 #endif |
41 | 45 |
42 #include "common/linux/linux_libc_support.h" | 46 #include "common/linux/linux_libc_support.h" |
43 | 47 |
44 namespace google_breakpad { | 48 namespace google_breakpad { |
45 | 49 |
46 LinuxCoreDumper::LinuxCoreDumper(pid_t pid, | 50 LinuxCoreDumper::LinuxCoreDumper(pid_t pid, |
47 const char* core_path, | 51 const char* core_path, |
48 const char* procfs_path) | 52 const char* procfs_path) |
49 : LinuxDumper(pid), | 53 : LinuxDumper(pid), |
50 core_path_(core_path), | 54 core_path_(core_path), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 #if defined(__i386) | 102 #if defined(__i386) |
99 memcpy(&stack_pointer, &info->regs.esp, sizeof(info->regs.esp)); | 103 memcpy(&stack_pointer, &info->regs.esp, sizeof(info->regs.esp)); |
100 #elif defined(__x86_64) | 104 #elif defined(__x86_64) |
101 memcpy(&stack_pointer, &info->regs.rsp, sizeof(info->regs.rsp)); | 105 memcpy(&stack_pointer, &info->regs.rsp, sizeof(info->regs.rsp)); |
102 #elif defined(__ARM_EABI__) | 106 #elif defined(__ARM_EABI__) |
103 memcpy(&stack_pointer, &info->regs.ARM_sp, sizeof(info->regs.ARM_sp)); | 107 memcpy(&stack_pointer, &info->regs.ARM_sp, sizeof(info->regs.ARM_sp)); |
104 #elif defined(__aarch64__) | 108 #elif defined(__aarch64__) |
105 memcpy(&stack_pointer, &info->regs.sp, sizeof(info->regs.sp)); | 109 memcpy(&stack_pointer, &info->regs.sp, sizeof(info->regs.sp)); |
106 #elif defined(__mips__) | 110 #elif defined(__mips__) |
107 stack_pointer = | 111 stack_pointer = |
108 reinterpret_cast<uint8_t*>(info->regs.regs[MD_CONTEXT_MIPS_REG_SP]); | 112 reinterpret_cast<uint8_t*>(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); |
109 #else | 113 #else |
110 #error "This code hasn't been ported to your platform yet." | 114 #error "This code hasn't been ported to your platform yet." |
111 #endif | 115 #endif |
112 info->stack_pointer = reinterpret_cast<uintptr_t>(stack_pointer); | 116 info->stack_pointer = reinterpret_cast<uintptr_t>(stack_pointer); |
113 return true; | 117 return true; |
114 } | 118 } |
115 | 119 |
116 bool LinuxCoreDumper::IsPostMortem() const { | 120 bool LinuxCoreDumper::IsPostMortem() const { |
117 return true; | 121 return true; |
118 } | 122 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 188 } |
185 | 189 |
186 const elf_prstatus* status = | 190 const elf_prstatus* status = |
187 reinterpret_cast<const elf_prstatus*>(description.data()); | 191 reinterpret_cast<const elf_prstatus*>(description.data()); |
188 pid_t pid = status->pr_pid; | 192 pid_t pid = status->pr_pid; |
189 ThreadInfo info; | 193 ThreadInfo info; |
190 memset(&info, 0, sizeof(ThreadInfo)); | 194 memset(&info, 0, sizeof(ThreadInfo)); |
191 info.tgid = status->pr_pgrp; | 195 info.tgid = status->pr_pgrp; |
192 info.ppid = status->pr_ppid; | 196 info.ppid = status->pr_ppid; |
193 #if defined(__mips__) | 197 #if defined(__mips__) |
| 198 #if defined(__ANDROID__) |
| 199 for (int i = EF_R0; i <= EF_R31; i++) |
| 200 info.mcontext.gregs[i - EF_R0] = status->pr_reg[i]; |
| 201 #else // __ANDROID__ |
194 for (int i = EF_REG0; i <= EF_REG31; i++) | 202 for (int i = EF_REG0; i <= EF_REG31; i++) |
195 info.regs.regs[i - EF_REG0] = status->pr_reg[i]; | 203 info.mcontext.gregs[i - EF_REG0] = status->pr_reg[i]; |
196 | 204 #endif // __ANDROID__ |
197 info.regs.lo = status->pr_reg[EF_LO]; | 205 info.mcontext.mdlo = status->pr_reg[EF_LO]; |
198 info.regs.hi = status->pr_reg[EF_HI]; | 206 info.mcontext.mdhi = status->pr_reg[EF_HI]; |
199 info.regs.epc = status->pr_reg[EF_CP0_EPC]; | 207 info.mcontext.pc = status->pr_reg[EF_CP0_EPC]; |
200 info.regs.badvaddr = status->pr_reg[EF_CP0_BADVADDR]; | 208 #else // __mips__ |
201 info.regs.status = status->pr_reg[EF_CP0_STATUS]; | |
202 info.regs.cause = status->pr_reg[EF_CP0_CAUSE]; | |
203 #else | |
204 memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); | 209 memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); |
205 #endif | 210 #endif // __mips__ |
206 if (first_thread) { | 211 if (first_thread) { |
207 crash_thread_ = pid; | 212 crash_thread_ = pid; |
208 crash_signal_ = status->pr_info.si_signo; | 213 crash_signal_ = status->pr_info.si_signo; |
209 } | 214 } |
210 first_thread = false; | 215 first_thread = false; |
211 threads_.push_back(pid); | 216 threads_.push_back(pid); |
212 thread_infos_.push_back(info); | 217 thread_infos_.push_back(info); |
213 break; | 218 break; |
214 } | 219 } |
215 #if defined(__i386) || defined(__x86_64) | 220 #if defined(__i386) || defined(__x86_64) |
(...skipping 27 matching lines...) Expand all Loading... |
243 } | 248 } |
244 #endif | 249 #endif |
245 } | 250 } |
246 note = note.GetNextNote(); | 251 note = note.GetNextNote(); |
247 } while (note.IsValid()); | 252 } while (note.IsValid()); |
248 | 253 |
249 return true; | 254 return true; |
250 } | 255 } |
251 | 256 |
252 } // namespace google_breakpad | 257 } // namespace google_breakpad |
OLD | NEW |