Chromium Code Reviews| Index: kernel_collector.cc |
| diff --git a/kernel_collector.cc b/kernel_collector.cc |
| index 652e7ff3a0d5875ca5e9d92f63161d03328d4000..7603cabc12253fdc1393bc7ec2cbb40a0381c1dc 100644 |
| --- a/kernel_collector.cc |
| +++ b/kernel_collector.cc |
| @@ -24,9 +24,26 @@ static const int kSignatureTimestampWindow = 2; |
| // Kernel log timestamp regular expression. |
| static const std::string kTimestampRegex("^<.*>\\[\\s*(\\d+\\.\\d+)\\]"); |
| +/* |
| + * For ARM we see: |
|
kmixter1
2011/04/05 00:09:26
Could you change the comment to be more descriptiv
sjg
2011/04/05 17:45:04
done
|
| + * "<5>[ 39.458982] PC is at write_breakme+0xd0/0x1b4" |
| + * For x86: |
| + * "<0>[ 37.474699] EIP: [<790ed488>] write_breakme+0x80/0x108 \ |
| + * SS:ESP 0068:e9dd3efc |
| + */ |
| +static const std::string pcRegex[KernelCollector::archCount] = { |
|
kmixter1
2011/04/05 00:09:26
I suspect that if archCount is greater than the nu
sjg
2011/04/05 17:45:04
OK have changed the varname and added a check in c
|
| + " PC is at ([^\\+ ]+).*", |
| + " EIP: \\[<.*>\\] ([^\\+ ]+).*", // X86 uses EIP for the program counter |
| + " Unsupported architecture" |
| +}; |
| + |
| KernelCollector::KernelCollector() |
| : is_enabled_(false), |
| preserved_dump_path_(kPreservedDumpPath) { |
| + // We expect crash dumps in the format of the architecture we are built for. |
| + arch_ = GetCompilerArch(); |
| + if (arch_ == archUnknown) |
| + LOG(WARNING) << "KernelCollector does not understand this architecture"; |
| } |
| KernelCollector::~KernelCollector() { |
| @@ -90,11 +107,19 @@ void KernelCollector::ProcessStackTrace( |
| unsigned *hash, |
| float *last_stack_timestamp) { |
| pcrecpp::RE line_re("(.+)", pcrecpp::MULTILINE()); |
| - pcrecpp::RE stack_trace_start_re(kTimestampRegex + " Call Trace:$"); |
| + pcrecpp::RE stack_trace_start_re(kTimestampRegex + |
| + " (Call Trace|Backtrace):$"); |
| // Match lines such as the following and grab out "error_code". |
| - // <4>[ 6066.849504] [<7937bcee>] error_code+0x66/0x6c |
| + // <4>[ 6066.849504] [<7937bcee>] ? error_code+0x66/0x6c |
| + // The ? may or may not be present |
| + |
| + // For ARM: |
|
kmixter1
2011/04/05 00:09:26
Could you add the x86 example? It may be easier t
sjg
2011/04/05 17:45:04
It is above - I have changed it around to be more
|
| + // <4>[ 3498.731164] [<c0057220>] (__bug+0x20/0x2c) from [<c018062c>] |
| + // (write_breakme+0xdc/0x1bc) |
| pcrecpp::RE stack_entry_re(kTimestampRegex + |
| - " \\[<.*>\\]([\\s\\?]+)([^\\+ ]+)"); |
| + "\\s+\\[<[[:xdigit:]]+>\\]" // Matches " [<7937bcee>]" |
| + "([\\s\\?(]+)" // Matches " ? (" |
|
kmixter1
2011/04/05 00:09:26
Matches " ? (" (ARM) or " ? " (x86).
sjg
2011/04/05 17:45:04
done
|
| + "([^\\+ )]+)"); // Matches until \ + space ) |
|
kmixter1
2011/04/05 00:09:26
nit: it took me a while to parse this comment. Ma
sjg
2011/04/05 17:45:04
done
|
| std::string line; |
| std::string hashable; |
| @@ -137,14 +162,33 @@ void KernelCollector::ProcessStackTrace( |
| } |
| } |
| +enum KernelCollector::ArchKind KernelCollector::GetCompilerArch(void) |
| +{ |
| +#if defined(COMPILER_GCC) && defined(ARCH_CPU_ARM_FAMILY) |
| + return archArm; |
| +#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) |
| + return archX86; |
| +#else |
| + return archUnknown; |
| +#endif |
| +} |
| + |
| +void KernelCollector::SetArch(enum ArchKind arch) |
| +{ |
| + arch_ = arch; |
| +} |
| + |
| bool KernelCollector::FindCrashingFunction( |
| - pcrecpp::StringPiece kernel_dump, |
| - bool print_diagnostics, |
| - float stack_trace_timestamp, |
| - std::string *crashing_function) { |
| - pcrecpp::RE eip_re(kTimestampRegex + " EIP: \\[<.*>\\] ([^\\+ ]+).*", |
| - pcrecpp::MULTILINE()); |
| + pcrecpp::StringPiece kernel_dump, |
| + bool print_diagnostics, |
| + float stack_trace_timestamp, |
| + std::string *crashing_function) { |
| float timestamp = 0; |
| + |
| + // Use the correct regex for this architecture. |
| + pcrecpp::RE eip_re(kTimestampRegex + pcRegex[arch_], |
| + pcrecpp::MULTILINE()); |
| + |
| while (eip_re.FindAndConsume(&kernel_dump, ×tamp, crashing_function)) { |
| if (print_diagnostics) { |
| printf("@%f: found crashing function %s\n", |