OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <unistd.h> | 5 #include <unistd.h> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chromeos/syslog_logging.h" | 9 #include "chromeos/syslog_logging.h" |
10 #include "chromeos/test_helpers.h" | 10 #include "chromeos/test_helpers.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 filename = filename.substr(0, end_pos); | 155 filename = filename.substr(0, end_pos); |
156 ASSERT_EQ(0, filename.find(kTestCrashDirectory)); | 156 ASSERT_EQ(0, filename.find(kTestCrashDirectory)); |
157 ASSERT_TRUE(file_util::PathExists(FilePath(filename))); | 157 ASSERT_TRUE(file_util::PathExists(FilePath(filename))); |
158 std::string contents; | 158 std::string contents; |
159 ASSERT_TRUE(file_util::ReadFileToString(FilePath(filename), &contents)); | 159 ASSERT_TRUE(file_util::ReadFileToString(FilePath(filename), &contents)); |
160 ASSERT_EQ("something", contents); | 160 ASSERT_EQ("something", contents); |
161 | 161 |
162 CheckPreservedDumpClear(); | 162 CheckPreservedDumpClear(); |
163 } | 163 } |
164 | 164 |
165 TEST_F(KernelCollectorTest, ComputeKernelStackSignature) { | 165 TEST_F(KernelCollectorTest, ComputeKernelStackSignatureARM) { |
166 const char kBugToPanic[] = | |
167 "<5>[ 123.412524] Modules linked in:\n" | |
168 "<5>[ 123.412534] CPU: 0 Tainted: G W " | |
169 "(2.6.37-01030-g51cee64 #153)\n" | |
170 "<5>[ 123.412552] PC is at write_breakme+0xd0/0x1b4\n" | |
171 "<5>[ 123.412560] LR is at write_breakme+0xc8/0x1b4\n" | |
172 "<5>[ 123.412569] pc : [<c0058220>] lr : [<c005821c>] " | |
173 "psr: 60000013\n" | |
174 "<5>[ 123.412574] sp : f4e0ded8 ip : c04d104c fp : 000e45e0\n" | |
175 "<5>[ 123.412581] r10: 400ff000 r9 : f4e0c000 r8 : 00000004\n" | |
176 "<5>[ 123.412589] r7 : f4e0df80 r6 : f4820c80 r5 : 00000004 " | |
177 "r4 : f4e0dee8\n" | |
178 "<5>[ 123.412598] r3 : 00000000 r2 : f4e0decc r1 : c05f88a9 " | |
179 "r0 : 00000039\n" | |
180 "<5>[ 123.412608] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA " | |
181 "ARM Segment user\n" | |
182 "<5>[ 123.412617] Control: 10c53c7d Table: 34dcc04a DAC: 00000015\n" | |
183 "<0>[ 123.412626] Process bash (pid: 1014, stack limit = 0xf4e0c2f8)\n" | |
184 "<0>[ 123.412634] Stack: (0xf4e0ded8 to 0xf4e0e000)\n" | |
185 "<0>[ 123.412641] dec0: " | |
186 " f4e0dee8 c0183678\n" | |
187 "<0>[ 123.412654] dee0: 00000000 00000000 00677562 0000081f c06a6a78 " | |
188 "400ff000 f4e0dfb0 00000000\n" | |
189 "<0>[ 123.412666] df00: bec7ab44 000b1719 bec7ab0c c004f498 bec7a314 " | |
190 "c024acc8 00000001 c018359c\n" | |
191 "<0>[ 123.412679] df20: f4e0df34 c04d10fc f5803c80 271beb39 000e45e0 " | |
192 "f5803c80 c018359c c017bfe0\n" | |
193 "<0>[ 123.412691] df40: 00000004 f4820c80 400ff000 f4e0df80 00000004 " | |
194 "f4e0c000 00000000 c01383e4\n" | |
195 "<0>[ 123.412703] df60: f4820c80 400ff000 f4820c80 400ff000 00000000 " | |
196 "00000000 00000004 c0138578\n" | |
197 "<0>[ 123.412715] df80: 00000000 00000000 00000004 00000000 00000004 " | |
198 "402f95d0 00000004 00000004\n" | |
199 "<0>[ 123.412727] dfa0: c0054984 c00547c0 00000004 402f95d0 00000001 " | |
200 "400ff000 00000004 00000000\n" | |
201 "<0>[ 123.412739] dfc0: 00000004 402f95d0 00000004 00000004 400ff000 " | |
202 "000c194c bec7ab58 000e45e0\n" | |
203 "<0>[ 123.412751] dfe0: 00000000 bec7aad8 40232520 40284e9c 60000010 " | |
204 "00000001 00000000 00000000\n" | |
205 "<5>[ 39.496577] Backtrace:\n" | |
206 "<5>[ 123.412782] [<c0058220>] (__bug+0x20/0x2c) from [<c0183678>] " | |
207 "(write_breakme+0xdc/0x1bc)\n" | |
208 "<5>[ 123.412798] [<c0183678>] (write_breakme+0xdc/0x1bc) from " | |
209 "[<c017bfe0>] (proc_reg_write+0x88/0x9c)\n"; | |
210 std::string signature; | |
211 | |
212 // Make sure the normal build architecture is detected | |
213 EXPECT_TRUE(collector_.GetArch() != KernelCollector::archUnknown); | |
kmixter1
2011/04/05 00:09:26
I would separate this into a separate test functio
sjg
2011/04/05 17:45:04
done
| |
214 | |
215 collector_.SetArch(KernelCollector::archArm); | |
216 EXPECT_TRUE( | |
217 collector_.ComputeKernelStackSignature(kBugToPanic, &signature, false)); | |
218 EXPECT_EQ("kernel-write_breakme-97D3E92F", signature); | |
219 | |
220 const char kPCButNoStack[] = | |
kmixter1
2011/04/05 00:09:26
Instead of copying this code directly from the x86
sjg
2011/04/05 17:45:04
OK have done this. In fact I could create differen
| |
221 "<5>[ 123.412552] PC is at write_breakme+0xd0/0x1b4"; | |
222 EXPECT_TRUE( | |
223 collector_.ComputeKernelStackSignature(kPCButNoStack, &signature, false)); | |
224 EXPECT_EQ("kernel-write_breakme-00000000", signature); | |
225 | |
226 const char kStackButNoPC[] = | |
227 "<4>[ 6066.829029] [<790340af>] __do_softirq+0xa6/0x143\n"; | |
228 EXPECT_TRUE( | |
229 collector_.ComputeKernelStackSignature(kStackButNoPC, &signature, false)); | |
230 EXPECT_EQ("kernel--83615F0A", signature); | |
231 | |
232 const char kMissingEverything[] = | |
233 "<4>[ 6066.829029] [<790340af>] ? __do_softirq+0xa6/0x143\n"; | |
234 EXPECT_FALSE( | |
235 collector_.ComputeKernelStackSignature(kMissingEverything, | |
236 &signature, | |
237 false)); | |
238 | |
239 const char kPCLineTooOld[] = | |
240 "<4>[ 123.402137] [<790970c6>] ignored_function+0x67f/0x96d\n" | |
241 "<5>[ 123.412552] PC is at write_breakme+0xd0/0x1b4\n" | |
242 "<4>[ 180.502026] Backtrace:\n" | |
243 "<0>[ 180.502026] Kernel panic - not syncing: Fatal exception\n" | |
244 "<4>[ 180.502806] [<79379aba>] printk+0x14/0x1a\n"; | |
245 | |
246 EXPECT_TRUE( | |
247 collector_.ComputeKernelStackSignature(kPCLineTooOld, &signature, false)); | |
248 EXPECT_EQ("kernel-Fatal exception-ED4C84FE", signature); | |
249 | |
250 // Panic without EIP line. | |
251 const char kExamplePanicOnly[] = | |
252 "<0>[ 39.543808] Kernel panic - not syncing: Testing panic\n" | |
253 "<5>[ 39.543815] Backtrace:\n" | |
254 "<5>[ 39.543840] [<c005ca30>] (unwind_backtrace+0x0/0xf8) from " | |
255 "[<c04caf38>] (panic+0x68/0x190)\n" | |
256 "<5>[ 39.543856] [<c04caf38>] (panic+0x68/0x190) from [<c005a93c>] " | |
257 "(die+0x2bc/0x330)\n" | |
258 "<5>[ 39.543871] [<c005a93c>] (die+0x2bc/0x330) from [<c00511e0>] " | |
259 "(do_undefinstr+0x120/0x138)\n" | |
260 "<5>[ 39.543892] [<c00511e0>] (do_undefinstr+0x120/0x138) from " | |
261 "[<c04ced84>] (__und_svc+0x44/0x60)\n"; | |
262 EXPECT_TRUE( | |
263 collector_.ComputeKernelStackSignature(kExamplePanicOnly, | |
264 &signature, | |
265 false)); | |
266 EXPECT_EQ("kernel-Testing panic-735A6297", signature); | |
267 | |
268 // Long message. | |
269 const char kTruncatedMessage[] = | |
270 "<0>[ 87.485611] Kernel panic - not syncing: 01234567890123456789" | |
271 "01234567890123456789X\n"; | |
272 EXPECT_TRUE( | |
273 collector_.ComputeKernelStackSignature(kTruncatedMessage, | |
274 &signature, | |
275 false)); | |
276 EXPECT_EQ("kernel-0123456789012345678901234567890123456789-00000000", | |
277 signature); | |
278 } | |
279 | |
280 | |
281 TEST_F(KernelCollectorTest, ComputeKernelStackSignatureX86) { | |
166 const char kBugToPanic[] = | 282 const char kBugToPanic[] = |
167 "<4>[ 6066.829029] [<79039d16>] ? run_timer_softirq+0x165/0x1e6\n" | 283 "<4>[ 6066.829029] [<79039d16>] ? run_timer_softirq+0x165/0x1e6\n" |
168 "<4>[ 6066.829029] [<790340af>] ignore_old_stack+0xa6/0x143\n" | 284 "<4>[ 6066.829029] [<790340af>] ignore_old_stack+0xa6/0x143\n" |
169 "<0>[ 6066.829029] EIP: [<b82d7c15>] ieee80211_stop_tx_ba_session+" | 285 "<0>[ 6066.829029] EIP: [<b82d7c15>] ieee80211_stop_tx_ba_session+" |
170 "0xa3/0xb5 [mac80211] SS:ESP 0068:7951febc\n" | 286 "0xa3/0xb5 [mac80211] SS:ESP 0068:7951febc\n" |
171 "<0>[ 6066.829029] CR2: 00000000323038a7\n" | 287 "<0>[ 6066.829029] CR2: 00000000323038a7\n" |
172 "<4>[ 6066.845422] ---[ end trace 12b058bb46c43500 ]---\n" | 288 "<4>[ 6066.845422] ---[ end trace 12b058bb46c43500 ]---\n" |
173 "<0>[ 6066.845747] Kernel panic - not syncing: Fatal exception " | 289 "<0>[ 6066.845747] Kernel panic - not syncing: Fatal exception " |
174 "in interrupt\n" | 290 "in interrupt\n" |
175 "<0>[ 6066.846902] Call Trace:\n" | 291 "<0>[ 6066.846902] Call Trace:\n" |
176 "<4>[ 6066.846902] [<7937a07b>] ? printk+0x14/0x19\n" | 292 "<4>[ 6066.846902] [<7937a07b>] ? printk+0x14/0x19\n" |
177 "<4>[ 6066.949779] [<79379fc1>] panic+0x3e/0xe4\n" | 293 "<4>[ 6066.949779] [<79379fc1>] panic+0x3e/0xe4\n" |
178 "<4>[ 6066.949971] [<7937c5c5>] oops_end+0x73/0x81\n" | 294 "<4>[ 6066.949971] [<7937c5c5>] oops_end+0x73/0x81\n" |
179 "<4>[ 6066.950208] [<7901b260>] no_context+0x10d/0x117\n"; | 295 "<4>[ 6066.950208] [<7901b260>] no_context+0x10d/0x117\n"; |
180 std::string signature; | 296 std::string signature; |
297 | |
298 collector_.SetArch(KernelCollector::archX86); | |
181 EXPECT_TRUE( | 299 EXPECT_TRUE( |
182 collector_.ComputeKernelStackSignature(kBugToPanic, &signature, false)); | 300 collector_.ComputeKernelStackSignature(kBugToPanic, &signature, false)); |
183 EXPECT_EQ("kernel-ieee80211_stop_tx_ba_session-DE253569", signature); | 301 EXPECT_EQ("kernel-ieee80211_stop_tx_ba_session-DE253569", signature); |
184 | 302 |
185 const char kPCButNoStack[] = | 303 const char kPCButNoStack[] = |
186 "<0>[ 6066.829029] EIP: [<b82d7c15>] ieee80211_stop_tx_ba_session+"; | 304 "<0>[ 6066.829029] EIP: [<b82d7c15>] ieee80211_stop_tx_ba_session+"; |
187 EXPECT_TRUE( | 305 EXPECT_TRUE( |
188 collector_.ComputeKernelStackSignature(kPCButNoStack, &signature, false)); | 306 collector_.ComputeKernelStackSignature(kPCButNoStack, &signature, false)); |
189 EXPECT_EQ("kernel-ieee80211_stop_tx_ba_session-00000000", signature); | 307 EXPECT_EQ("kernel-ieee80211_stop_tx_ba_session-00000000", signature); |
190 | 308 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 false)); | 384 false)); |
267 EXPECT_EQ("kernel-0123456789012345678901234567890123456789-00000000", | 385 EXPECT_EQ("kernel-0123456789012345678901234567890123456789-00000000", |
268 signature); | 386 signature); |
269 | 387 |
270 } | 388 } |
271 | 389 |
272 int main(int argc, char **argv) { | 390 int main(int argc, char **argv) { |
273 SetUpTests(&argc, argv, false); | 391 SetUpTests(&argc, argv, false); |
274 return RUN_ALL_TESTS(); | 392 return RUN_ALL_TESTS(); |
275 } | 393 } |
OLD | NEW |