| OLD | NEW |
| 1 // Copyright (c) 2014, Google Inc. | 1 // Copyright (c) 2014, 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 void DumpOSInformation() { | 160 void DumpOSInformation() { |
| 161 const uint8_t n_cpus = static_cast<uint8_t>(sysconf(_SC_NPROCESSORS_CONF)); | 161 const uint8_t n_cpus = static_cast<uint8_t>(sysconf(_SC_NPROCESSORS_CONF)); |
| 162 | 162 |
| 163 #if defined(__ANDROID__) | 163 #if defined(__ANDROID__) |
| 164 const char kOSId[] = "A"; | 164 const char kOSId[] = "A"; |
| 165 #else | 165 #else |
| 166 const char kOSId[] = "L"; | 166 const char kOSId[] = "L"; |
| 167 #endif | 167 #endif |
| 168 | 168 |
| 169 // We cannot depend on uts.machine. On multiarch devices it always returns the | 169 // Dump the runtime architecture. On multiarch devices it might not match the |
| 170 // primary arch, not the one that match the executable being run. | 170 // hw architecture (the one returned by uname()), for instance in the case of |
| 171 // a 32-bit app running on a aarch64 device. |
| 171 #if defined(__aarch64__) | 172 #if defined(__aarch64__) |
| 172 const char kArch[] = "arm64"; | 173 const char kArch[] = "arm64"; |
| 173 #elif defined(__ARMEL__) | 174 #elif defined(__ARMEL__) |
| 174 const char kArch[] = "arm"; | 175 const char kArch[] = "arm"; |
| 175 #elif defined(__x86_64__) | 176 #elif defined(__x86_64__) |
| 176 const char kArch[] = "x86_64"; | 177 const char kArch[] = "x86_64"; |
| 177 #elif defined(__i386__) | 178 #elif defined(__i386__) |
| 178 const char kArch[] = "x86"; | 179 const char kArch[] = "x86"; |
| 179 #elif defined(__mips__) | 180 #elif defined(__mips__) |
| 180 const char kArch[] = "mips"; | 181 const char kArch[] = "mips"; |
| 181 #else | 182 #else |
| 182 #error "This code has not been ported to your platform yet" | 183 #error "This code has not been ported to your platform yet" |
| 183 #endif | 184 #endif |
| 184 | 185 |
| 185 LogAppend("O "); | 186 LogAppend("O "); |
| 186 LogAppend(kOSId); | 187 LogAppend(kOSId); |
| 187 LogAppend(" "); | 188 LogAppend(" "); |
| 188 LogAppend(kArch); | 189 LogAppend(kArch); |
| 189 LogAppend(" "); | 190 LogAppend(" "); |
| 190 LogAppend(n_cpus); | 191 LogAppend(n_cpus); |
| 191 LogAppend(" "); | 192 LogAppend(" "); |
| 193 |
| 194 // Dump the HW architecture (e.g., armv7l, aarch64). |
| 195 struct utsname uts; |
| 196 const bool has_uts_info = (uname(&uts) == 0); |
| 197 const char* hwArch = has_uts_info ? uts.machine : "unknown_hw_arch"; |
| 198 LogAppend(hwArch); |
| 199 LogAppend(" "); |
| 200 |
| 192 // If the client has attached a build fingerprint to the MinidumpDescriptor | 201 // If the client has attached a build fingerprint to the MinidumpDescriptor |
| 193 // use that one. Otherwise try to get some basic info from uname(). | 202 // use that one. Otherwise try to get some basic info from uname(). |
| 194 if (build_fingerprint_) { | 203 if (build_fingerprint_) { |
| 195 LogAppend(build_fingerprint_); | 204 LogAppend(build_fingerprint_); |
| 205 } else if (has_uts_info) { |
| 206 LogAppend(uts.release); |
| 207 LogAppend(" "); |
| 208 LogAppend(uts.version); |
| 196 } else { | 209 } else { |
| 197 struct utsname uts; | 210 LogAppend("no build fingerprint available"); |
| 198 if (uname(&uts) == 0) { | |
| 199 LogAppend(uts.machine); | |
| 200 LogAppend(" "); | |
| 201 LogAppend(uts.release); | |
| 202 LogAppend(" "); | |
| 203 LogAppend(uts.version); | |
| 204 } else { | |
| 205 LogAppend("no build fingerprint available"); | |
| 206 } | |
| 207 } | 211 } |
| 208 LogCommitLine(); | 212 LogCommitLine(); |
| 209 } | 213 } |
| 210 | 214 |
| 211 bool DumpThreadStack(uint32_t thread_id, | 215 bool DumpThreadStack(uint32_t thread_id, |
| 212 uintptr_t stack_pointer, | 216 uintptr_t stack_pointer, |
| 213 int max_stack_len, | 217 int max_stack_len, |
| 214 uint8_t** stack_copy) { | 218 uint8_t** stack_copy) { |
| 215 *stack_copy = NULL; | 219 *stack_copy = NULL; |
| 216 const void* stack; | 220 const void* stack; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 dumper.set_crash_thread(context->tid); | 418 dumper.set_crash_thread(context->tid); |
| 415 } | 419 } |
| 416 MicrodumpWriter writer(context, mappings, build_fingerprint, product_info, | 420 MicrodumpWriter writer(context, mappings, build_fingerprint, product_info, |
| 417 &dumper); | 421 &dumper); |
| 418 if (!writer.Init()) | 422 if (!writer.Init()) |
| 419 return false; | 423 return false; |
| 420 return writer.Dump(); | 424 return writer.Dump(); |
| 421 } | 425 } |
| 422 | 426 |
| 423 } // namespace google_breakpad | 427 } // namespace google_breakpad |
| OLD | NEW |