OLD | NEW |
---|---|
1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 AsanBlockInfo block_info = {}; | 309 AsanBlockInfo block_info = {}; |
310 InitAsanBlockInfo(&block_info); | 310 InitAsanBlockInfo(&block_info); |
311 | 311 |
312 { | 312 { |
313 crashdata::Value info; | 313 crashdata::Value info; |
314 PopulateBlockInfo(runtime_->shadow(), block_info, false, &info, nullptr); | 314 PopulateBlockInfo(runtime_->shadow(), block_info, false, &info, nullptr); |
315 std::string json; | 315 std::string json; |
316 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 316 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
317 const char kExpected[] = | 317 const char kExpected[] = |
318 "{\n" | 318 "{\n" |
319 #ifndef _WIN64 | |
319 " \"header\": \"0x%08X\",\n" | 320 " \"header\": \"0x%08X\",\n" |
321 #else | |
322 " \"header\": \"0x%08llX\",\n" | |
323 #endif | |
320 " \"user-size\": 8,\n" | 324 " \"user-size\": 8,\n" |
321 " \"state\": \"allocated\",\n" | 325 " \"state\": \"allocated\",\n" |
322 " \"heap-type\": \"WinHeap\",\n" | 326 " \"heap-type\": \"WinHeap\",\n" |
323 " \"analysis\": {\n" | 327 " \"analysis\": {\n" |
324 " \"block\": \"corrupt\",\n" | 328 " \"block\": \"corrupt\",\n" |
325 " \"header\": \"corrupt\",\n" | 329 " \"header\": \"corrupt\",\n" |
326 " \"body\": \"(unknown)\",\n" | 330 " \"body\": \"(unknown)\",\n" |
327 " \"trailer\": \"clean\"\n" | 331 " \"trailer\": \"clean\"\n" |
328 " },\n" | 332 " },\n" |
329 " \"alloc-thread-id\": 47,\n" | 333 " \"alloc-thread-id\": 47,\n" |
(...skipping 15 matching lines...) Expand all Loading... | |
345 block_info.free_stack_size = 3; | 349 block_info.free_stack_size = 3; |
346 block_info.heap_type = kWinHeap; | 350 block_info.heap_type = kWinHeap; |
347 block_info.milliseconds_since_free = 100; | 351 block_info.milliseconds_since_free = 100; |
348 | 352 |
349 crashdata::Value value; | 353 crashdata::Value value; |
350 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, nullptr); | 354 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, nullptr); |
351 std::string json; | 355 std::string json; |
352 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); | 356 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); |
353 const char kExpected[] = | 357 const char kExpected[] = |
354 "{\n" | 358 "{\n" |
359 #ifndef _WIN64 | |
355 " \"header\": \"0x%08X\",\n" | 360 " \"header\": \"0x%08X\",\n" |
361 #else | |
362 " \"header\": \"0x%08llX\",\n" | |
363 #endif | |
356 " \"user-size\": 8,\n" | 364 " \"user-size\": 8,\n" |
357 " \"state\": \"quarantined (flooded)\",\n" | 365 " \"state\": \"quarantined (flooded)\",\n" |
358 " \"heap-type\": \"WinHeap\",\n" | 366 " \"heap-type\": \"WinHeap\",\n" |
359 " \"analysis\": {\n" | 367 " \"analysis\": {\n" |
360 " \"block\": \"corrupt\",\n" | 368 " \"block\": \"corrupt\",\n" |
361 " \"header\": \"corrupt\",\n" | 369 " \"header\": \"corrupt\",\n" |
362 " \"body\": \"(unknown)\",\n" | 370 " \"body\": \"(unknown)\",\n" |
363 " \"trailer\": \"clean\"\n" | 371 " \"trailer\": \"clean\"\n" |
364 " },\n" | 372 " },\n" |
365 " \"alloc-thread-id\": 47,\n" | 373 " \"alloc-thread-id\": 47,\n" |
366 " \"alloc-stack\": [\n" | 374 " \"alloc-stack\": [\n" |
367 " \"0x00000001\", \"0x00000002\"\n" | 375 " \"0x00000001\", \"0x00000002\"\n" |
368 " ],\n" | 376 " ],\n" |
369 " \"free-thread-id\": 32,\n" | 377 " \"free-thread-id\": 32,\n" |
370 " \"free-stack\": [\n" | 378 " \"free-stack\": [\n" |
371 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" | 379 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" |
372 " ],\n" | 380 " ],\n" |
373 " \"milliseconds-since-free\": 100,\n" | 381 " \"milliseconds-since-free\": 100,\n" |
374 " \"contents\": {\n" | 382 " \"contents\": {\n" |
375 " \"type\": \"blob\",\n" | 383 " \"type\": \"blob\",\n" |
384 #ifndef _WIN64 | |
376 " \"address\": \"0x%08X\",\n" | 385 " \"address\": \"0x%08X\",\n" |
386 #else | |
387 " \"address\": \"0x%08llX\",\n" | |
388 #endif | |
377 " \"size\": null,\n" | 389 " \"size\": null,\n" |
378 " \"data\": [\n" | 390 " \"data\": [\n" |
379 " \"0x80\", \"0xCA\", \"0x00\", \"0x00\", \"0x20\", \"0x00\"," | 391 " \"0x80\", \"0xCA\", \"0x00\", \"0x00\", \"0x20\", \"0x00\"," |
380 " \"0x00\", \"0x00\",\n" | 392 " \"0x00\", \"0x00\",\n" |
381 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 393 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
382 " \"0x00\", \"0x00\",\n" | 394 " \"0x00\", \"0x00\",\n" |
383 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 395 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
384 " \"0x00\", \"0x00\",\n" | 396 " \"0x00\", \"0x00\",\n" |
385 #ifdef _WIN64 | 397 #ifdef _WIN64 |
386 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 398 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
387 " \"0x00\", \"0x00\",\n" | 399 " \"0x00\", \"0x00\",\n" |
388 #endif | 400 #endif |
389 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," | 401 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," |
390 " \"0x00\", \"0x00\",\n" | 402 " \"0x00\", \"0x00\",\n" |
403 #ifdef _WIN64 | |
404 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | |
405 " \"0x00\", \"0x00\",\n" | |
406 #endif | |
391 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 407 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
392 " \"0x00\", \"0x00\",\n" | 408 " \"0x00\", \"0x00\",\n" |
393 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 409 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
394 " \"0x00\", \"0x00\"\n" | 410 " \"0x00\", \"0x00\"\n" |
395 " ]\n" | 411 " ]\n" |
396 " },\n" | 412 " },\n" |
397 " \"shadow\": {\n" | 413 " \"shadow\": {\n" |
398 " \"type\": \"blob\",\n" | 414 " \"type\": \"blob\",\n" |
399 " \"address\": \"0x%08zX\",\n" | 415 #ifndef _WIN64 |
Ignat Loskutov
2016/09/22 22:00:36
What's wrong about %08zX?
| |
416 " \"address\": \"0x%08X\",\n" | |
417 #else | |
418 " \"address\": \"0x%08llX\",\n" | |
419 #endif | |
400 " \"size\": null,\n" | 420 " \"size\": null,\n" |
401 " \"data\": [\n" | 421 " \"data\": [\n" |
402 #ifndef _WIN64 | 422 #ifndef _WIN64 |
403 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" | 423 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" |
404 #else | 424 #else |
405 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," | 425 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," |
406 " \"0xF4\"\n" | 426 " \"0xFB\", \"0xF4\"\n" |
407 #endif | 427 #endif |
408 " ]\n" | 428 " ]\n" |
409 " }\n" | 429 " }\n" |
410 "}"; | 430 "}"; |
411 std::string expected = base::StringPrintf( | 431 std::string expected = base::StringPrintf( |
412 kExpected, | 432 kExpected, |
413 block_info.header, | 433 block_info.header, |
414 block_info.header, | 434 block_info.header, |
415 BlockShadowAddress()); | 435 BlockShadowAddress()); |
416 EXPECT_EQ(expected, json); | 436 EXPECT_EQ(expected, json); |
417 } | 437 } |
418 } | 438 } |
419 | 439 |
420 TEST_F(AsanErrorInfoTest, PopulateBlockInfoWithMemoryRanges) { | 440 TEST_F(AsanErrorInfoTest, PopulateBlockInfoWithMemoryRanges) { |
421 AsanBlockInfo block_info = {}; | 441 AsanBlockInfo block_info = {}; |
422 InitAsanBlockInfo(&block_info); | 442 InitAsanBlockInfo(&block_info); |
423 | 443 |
424 { | 444 { |
425 crashdata::Value info; | 445 crashdata::Value info; |
426 PopulateBlockInfo(runtime_->shadow(), block_info, false, &info, nullptr); | 446 PopulateBlockInfo(runtime_->shadow(), block_info, false, &info, nullptr); |
427 std::string json; | 447 std::string json; |
428 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 448 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
429 const char kExpected[] = | 449 const char kExpected[] = |
430 "{\n" | 450 "{\n" |
451 #ifndef _WIN64 | |
431 " \"header\": \"0x%08X\",\n" | 452 " \"header\": \"0x%08X\",\n" |
453 #else | |
454 " \"header\": \"0x%08llX\",\n" | |
455 #endif | |
432 " \"user-size\": 8,\n" | 456 " \"user-size\": 8,\n" |
433 " \"state\": \"allocated\",\n" | 457 " \"state\": \"allocated\",\n" |
434 " \"heap-type\": \"WinHeap\",\n" | 458 " \"heap-type\": \"WinHeap\",\n" |
435 " \"analysis\": {\n" | 459 " \"analysis\": {\n" |
436 " \"block\": \"corrupt\",\n" | 460 " \"block\": \"corrupt\",\n" |
437 " \"header\": \"corrupt\",\n" | 461 " \"header\": \"corrupt\",\n" |
438 " \"body\": \"(unknown)\",\n" | 462 " \"body\": \"(unknown)\",\n" |
439 " \"trailer\": \"clean\"\n" | 463 " \"trailer\": \"clean\"\n" |
440 " },\n" | 464 " },\n" |
441 " \"alloc-thread-id\": 47,\n" | 465 " \"alloc-thread-id\": 47,\n" |
(...skipping 16 matching lines...) Expand all Loading... | |
458 block_info.milliseconds_since_free = 100; | 482 block_info.milliseconds_since_free = 100; |
459 | 483 |
460 crashdata::Value value; | 484 crashdata::Value value; |
461 MemoryRanges memory_ranges; | 485 MemoryRanges memory_ranges; |
462 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, | 486 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, |
463 &memory_ranges); | 487 &memory_ranges); |
464 std::string json; | 488 std::string json; |
465 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); | 489 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); |
466 const char kExpected[] = | 490 const char kExpected[] = |
467 "{\n" | 491 "{\n" |
492 #ifndef _WIN64 | |
468 " \"header\": \"0x%08X\",\n" | 493 " \"header\": \"0x%08X\",\n" |
494 #else | |
495 " \"header\": \"0x%08llX\",\n" | |
496 #endif | |
469 " \"user-size\": 8,\n" | 497 " \"user-size\": 8,\n" |
470 " \"state\": \"quarantined (flooded)\",\n" | 498 " \"state\": \"quarantined (flooded)\",\n" |
471 " \"heap-type\": \"WinHeap\",\n" | 499 " \"heap-type\": \"WinHeap\",\n" |
472 " \"analysis\": {\n" | 500 " \"analysis\": {\n" |
473 " \"block\": \"corrupt\",\n" | 501 " \"block\": \"corrupt\",\n" |
474 " \"header\": \"corrupt\",\n" | 502 " \"header\": \"corrupt\",\n" |
475 " \"body\": \"(unknown)\",\n" | 503 " \"body\": \"(unknown)\",\n" |
476 " \"trailer\": \"clean\"\n" | 504 " \"trailer\": \"clean\"\n" |
477 " },\n" | 505 " },\n" |
478 " \"alloc-thread-id\": 47,\n" | 506 " \"alloc-thread-id\": 47,\n" |
479 " \"alloc-stack\": [\n" | 507 " \"alloc-stack\": [\n" |
480 " \"0x00000001\", \"0x00000002\"\n" | 508 " \"0x00000001\", \"0x00000002\"\n" |
481 " ],\n" | 509 " ],\n" |
482 " \"free-thread-id\": 32,\n" | 510 " \"free-thread-id\": 32,\n" |
483 " \"free-stack\": [\n" | 511 " \"free-stack\": [\n" |
484 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" | 512 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" |
485 " ],\n" | 513 " ],\n" |
486 " \"milliseconds-since-free\": 100,\n" | 514 " \"milliseconds-since-free\": 100,\n" |
487 " \"contents\": {\n" | 515 " \"contents\": {\n" |
488 " \"type\": \"blob\",\n" | 516 " \"type\": \"blob\",\n" |
489 " \"address\": \"0x%08zX\",\n" | 517 " \"address\": \"0x%08zX\",\n" |
490 #ifndef _WIN64 | 518 #ifndef _WIN64 |
491 " \"size\": 48,\n" | 519 " \"size\": 48,\n" |
492 #else | 520 #else |
493 " \"size\": 56,\n" | 521 " \"size\": 64,\n" |
494 #endif | 522 #endif |
495 " \"data\": null\n" | 523 " \"data\": null\n" |
496 " },\n" | 524 " },\n" |
497 " \"shadow\": {\n" | 525 " \"shadow\": {\n" |
498 " \"type\": \"blob\",\n" | 526 " \"type\": \"blob\",\n" |
499 " \"address\": \"0x%08zX\",\n" | 527 " \"address\": \"0x%08zX\",\n" |
500 #ifndef _WIN64 | 528 #ifndef _WIN64 |
501 " \"size\": 6,\n" | 529 " \"size\": 6,\n" |
502 #else | 530 #else |
503 " \"size\": 7,\n" | 531 " \"size\": 8,\n" |
504 #endif | 532 #endif |
505 " \"data\": null\n" | 533 " \"data\": null\n" |
506 " }\n" | 534 " }\n" |
507 "}"; | 535 "}"; |
508 std::string expected = base::StringPrintf( | 536 std::string expected = base::StringPrintf( |
509 kExpected, block_info.header, block_info.header, BlockShadowAddress()); | 537 kExpected, block_info.header, block_info.header, BlockShadowAddress()); |
510 EXPECT_EQ(expected, json); | 538 EXPECT_EQ(expected, json); |
511 | 539 |
512 ASSERT_EQ(2, memory_ranges.size()); | 540 ASSERT_EQ(2, memory_ranges.size()); |
513 const char* kExpectedMemoryRangesAddresses[] = { | 541 const char* kExpectedMemoryRangesAddresses[] = { |
514 reinterpret_cast<const char*>(block_info.header), | 542 reinterpret_cast<const char*>(block_info.header), |
515 reinterpret_cast<const char*>(BlockShadowAddress())}; | 543 reinterpret_cast<const char*>(BlockShadowAddress())}; |
516 #ifndef _WIN64 | 544 #ifndef _WIN64 |
517 size_t kExpectedMemoryRangesSize[] = {48, 6}; | 545 size_t kExpectedMemoryRangesSize[] = {48, 6}; |
518 #else | 546 #else |
519 size_t kExpectedMemoryRangesSize[] = {56, 7}; | 547 size_t kExpectedMemoryRangesSize[] = {64, 8}; |
520 #endif | 548 #endif |
521 for (int i = 0; i < 2; i++) { | 549 for (int i = 0; i < 2; i++) { |
522 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first); | 550 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first); |
523 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second); | 551 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second); |
524 } | 552 } |
525 } | 553 } |
526 } | 554 } |
527 | 555 |
528 TEST_F(AsanErrorInfoTest, PopulateCorruptBlockRange) { | 556 TEST_F(AsanErrorInfoTest, PopulateCorruptBlockRange) { |
529 AsanBlockInfo block_info = {}; | 557 AsanBlockInfo block_info = {}; |
(...skipping 11 matching lines...) Expand all Loading... | |
541 | 569 |
542 std::string json; | 570 std::string json; |
543 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 571 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
544 const char kExpected[] = | 572 const char kExpected[] = |
545 "{\n" | 573 "{\n" |
546 " \"address\": \"0xBAADF00D\",\n" | 574 " \"address\": \"0xBAADF00D\",\n" |
547 " \"length\": 1048576,\n" | 575 " \"length\": 1048576,\n" |
548 " \"block-count\": 100,\n" | 576 " \"block-count\": 100,\n" |
549 " \"blocks\": [\n" | 577 " \"blocks\": [\n" |
550 " {\n" | 578 " {\n" |
579 #ifndef _WIN64 | |
551 " \"header\": \"0x%08X\",\n" | 580 " \"header\": \"0x%08X\",\n" |
581 #else | |
582 " \"header\": \"0x%08llX\",\n" | |
583 #endif | |
552 " \"user-size\": 8,\n" | 584 " \"user-size\": 8,\n" |
553 " \"state\": \"allocated\",\n" | 585 " \"state\": \"allocated\",\n" |
554 " \"heap-type\": \"WinHeap\",\n" | 586 " \"heap-type\": \"WinHeap\",\n" |
555 " \"analysis\": {\n" | 587 " \"analysis\": {\n" |
556 " \"block\": \"corrupt\",\n" | 588 " \"block\": \"corrupt\",\n" |
557 " \"header\": \"corrupt\",\n" | 589 " \"header\": \"corrupt\",\n" |
558 " \"body\": \"(unknown)\",\n" | 590 " \"body\": \"(unknown)\",\n" |
559 " \"trailer\": \"clean\"\n" | 591 " \"trailer\": \"clean\"\n" |
560 " },\n" | 592 " },\n" |
561 " \"alloc-thread-id\": 47,\n" | 593 " \"alloc-thread-id\": 47,\n" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 crashdata::Value info; | 639 crashdata::Value info; |
608 PopulateErrorInfo(runtime_->shadow(), error_info, &info, nullptr); | 640 PopulateErrorInfo(runtime_->shadow(), error_info, &info, nullptr); |
609 | 641 |
610 std::string json; | 642 std::string json; |
611 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 643 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
612 const char kExpected[] = | 644 const char kExpected[] = |
613 "{\n" | 645 "{\n" |
614 " \"location\": \"0x00001000\",\n" | 646 " \"location\": \"0x00001000\",\n" |
615 " \"crash-stack-id\": 1234,\n" | 647 " \"crash-stack-id\": 1234,\n" |
616 " \"block-info\": {\n" | 648 " \"block-info\": {\n" |
649 #ifndef _WIN64 | |
617 " \"header\": \"0x%08X\",\n" | 650 " \"header\": \"0x%08X\",\n" |
651 #else | |
652 " \"header\": \"0x%08llX\",\n" | |
653 #endif | |
618 " \"user-size\": 8,\n" | 654 " \"user-size\": 8,\n" |
619 " \"state\": \"allocated\",\n" | 655 " \"state\": \"allocated\",\n" |
620 " \"heap-type\": \"WinHeap\",\n" | 656 " \"heap-type\": \"WinHeap\",\n" |
621 " \"analysis\": {\n" | 657 " \"analysis\": {\n" |
622 " \"block\": \"corrupt\",\n" | 658 " \"block\": \"corrupt\",\n" |
623 " \"header\": \"corrupt\",\n" | 659 " \"header\": \"corrupt\",\n" |
624 " \"body\": \"(unknown)\",\n" | 660 " \"body\": \"(unknown)\",\n" |
625 " \"trailer\": \"clean\"\n" | 661 " \"trailer\": \"clean\"\n" |
626 " },\n" | 662 " },\n" |
627 " \"alloc-thread-id\": 47,\n" | 663 " \"alloc-thread-id\": 47,\n" |
(...skipping 10 matching lines...) Expand all Loading... | |
638 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 674 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
639 " \"0x00\", \"0x00\",\n" | 675 " \"0x00\", \"0x00\",\n" |
640 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 676 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
641 " \"0x00\", \"0x00\",\n" | 677 " \"0x00\", \"0x00\",\n" |
642 #ifdef _WIN64 | 678 #ifdef _WIN64 |
643 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 679 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
644 " \"0x00\", \"0x00\",\n" | 680 " \"0x00\", \"0x00\",\n" |
645 #endif | 681 #endif |
646 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," | 682 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," |
647 " \"0x00\", \"0x00\",\n" | 683 " \"0x00\", \"0x00\",\n" |
684 #ifdef _WIN64 | |
685 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | |
686 " \"0x00\", \"0x00\",\n" | |
687 #endif | |
648 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 688 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
649 " \"0x00\", \"0x00\",\n" | 689 " \"0x00\", \"0x00\",\n" |
650 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 690 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
651 " \"0x00\", \"0x00\"\n" | 691 " \"0x00\", \"0x00\"\n" |
652 " ]\n" | 692 " ]\n" |
653 " },\n" | 693 " },\n" |
654 " \"shadow\": {\n" | 694 " \"shadow\": {\n" |
655 " \"type\": \"blob\",\n" | 695 " \"type\": \"blob\",\n" |
656 " \"address\": \"0x%08zX\",\n" | 696 " \"address\": \"0x%08zX\",\n" |
657 " \"size\": null,\n" | 697 " \"size\": null,\n" |
658 " \"data\": [\n" | 698 " \"data\": [\n" |
659 #ifndef _WIN64 | 699 #ifndef _WIN64 |
660 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" | 700 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" |
661 #else | 701 #else |
662 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," | 702 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," |
663 " \"0xF4\"\n" | 703 " \"0xFB\", \"0xF4\"\n" |
664 #endif | 704 #endif |
665 " ]\n" | 705 " ]\n" |
666 " }\n" | 706 " }\n" |
667 " },\n" | 707 " },\n" |
668 " \"error-type\": \"wild-access\",\n" | 708 " \"error-type\": \"wild-access\",\n" |
669 " \"access-mode\": \"read\",\n" | 709 " \"access-mode\": \"read\",\n" |
670 " \"access-size\": 4,\n" | 710 " \"access-size\": 4,\n" |
671 " \"shadow-memory-index\": 512,\n" | 711 " \"shadow-memory-index\": 512,\n" |
672 " \"shadow-memory\": {\n" | 712 " \"shadow-memory\": {\n" |
673 " \"type\": \"blob\",\n" | 713 " \"type\": \"blob\",\n" |
(...skipping 30 matching lines...) Expand all Loading... | |
704 " \"heap-is-corrupt\": 1,\n" | 744 " \"heap-is-corrupt\": 1,\n" |
705 " \"corrupt-range-count\": 10,\n" | 745 " \"corrupt-range-count\": 10,\n" |
706 " \"corrupt-block-count\": 200,\n" | 746 " \"corrupt-block-count\": 200,\n" |
707 " \"corrupt-ranges\": [\n" | 747 " \"corrupt-ranges\": [\n" |
708 " {\n" | 748 " {\n" |
709 " \"address\": \"0xBAADF00D\",\n" | 749 " \"address\": \"0xBAADF00D\",\n" |
710 " \"length\": 1048576,\n" | 750 " \"length\": 1048576,\n" |
711 " \"block-count\": 100,\n" | 751 " \"block-count\": 100,\n" |
712 " \"blocks\": [\n" | 752 " \"blocks\": [\n" |
713 " {\n" | 753 " {\n" |
754 #ifndef _WIN64 | |
714 " \"header\": \"0x%08X\",\n" | 755 " \"header\": \"0x%08X\",\n" |
756 #else | |
757 " \"header\": \"0x%08llX\",\n" | |
758 #endif | |
715 " \"user-size\": 8,\n" | 759 " \"user-size\": 8,\n" |
716 " \"state\": \"allocated\",\n" | 760 " \"state\": \"allocated\",\n" |
717 " \"heap-type\": \"WinHeap\",\n" | 761 " \"heap-type\": \"WinHeap\",\n" |
718 " \"analysis\": {\n" | 762 " \"analysis\": {\n" |
719 " \"block\": \"corrupt\",\n" | 763 " \"block\": \"corrupt\",\n" |
720 " \"header\": \"corrupt\",\n" | 764 " \"header\": \"corrupt\",\n" |
721 " \"body\": \"(unknown)\",\n" | 765 " \"body\": \"(unknown)\",\n" |
722 " \"trailer\": \"clean\"\n" | 766 " \"trailer\": \"clean\"\n" |
723 " },\n" | 767 " },\n" |
724 " \"alloc-thread-id\": 47,\n" | 768 " \"alloc-thread-id\": 47,\n" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 MemoryRanges memory_ranges; | 835 MemoryRanges memory_ranges; |
792 PopulateErrorInfo(runtime_->shadow(), error_info, &info, &memory_ranges); | 836 PopulateErrorInfo(runtime_->shadow(), error_info, &info, &memory_ranges); |
793 | 837 |
794 std::string json; | 838 std::string json; |
795 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 839 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
796 const char kExpected[] = | 840 const char kExpected[] = |
797 "{\n" | 841 "{\n" |
798 " \"location\": \"0x00001000\",\n" | 842 " \"location\": \"0x00001000\",\n" |
799 " \"crash-stack-id\": 1234,\n" | 843 " \"crash-stack-id\": 1234,\n" |
800 " \"block-info\": {\n" | 844 " \"block-info\": {\n" |
845 #ifndef _WIN64 | |
801 " \"header\": \"0x%08X\",\n" | 846 " \"header\": \"0x%08X\",\n" |
847 #else | |
848 " \"header\": \"0x%08llX\",\n" | |
849 #endif | |
802 " \"user-size\": 8,\n" | 850 " \"user-size\": 8,\n" |
803 " \"state\": \"allocated\",\n" | 851 " \"state\": \"allocated\",\n" |
804 " \"heap-type\": \"WinHeap\",\n" | 852 " \"heap-type\": \"WinHeap\",\n" |
805 " \"analysis\": {\n" | 853 " \"analysis\": {\n" |
806 " \"block\": \"corrupt\",\n" | 854 " \"block\": \"corrupt\",\n" |
807 " \"header\": \"corrupt\",\n" | 855 " \"header\": \"corrupt\",\n" |
808 " \"body\": \"(unknown)\",\n" | 856 " \"body\": \"(unknown)\",\n" |
809 " \"trailer\": \"clean\"\n" | 857 " \"trailer\": \"clean\"\n" |
810 " },\n" | 858 " },\n" |
811 " \"alloc-thread-id\": 47,\n" | 859 " \"alloc-thread-id\": 47,\n" |
812 " \"alloc-stack\": [\n" | 860 " \"alloc-stack\": [\n" |
813 " \"0x00000001\", \"0x00000002\"\n" | 861 " \"0x00000001\", \"0x00000002\"\n" |
814 " ],\n" | 862 " ],\n" |
815 " \"contents\": {\n" | 863 " \"contents\": {\n" |
816 " \"type\": \"blob\",\n" | 864 " \"type\": \"blob\",\n" |
865 #ifndef _WIN64 | |
817 " \"address\": \"0x%08zX\",\n" | 866 " \"address\": \"0x%08zX\",\n" |
818 #ifndef _WIN64 | |
819 " \"size\": 48,\n" | 867 " \"size\": 48,\n" |
820 #else | 868 #else |
821 " \"size\": 56,\n" | 869 " \"address\": \"0x%08llX\",\n" |
870 " \"size\": 64,\n" | |
822 #endif | 871 #endif |
823 " \"data\": null\n" | 872 " \"data\": null\n" |
824 " },\n" | 873 " },\n" |
825 " \"shadow\": {\n" | 874 " \"shadow\": {\n" |
826 " \"type\": \"blob\",\n" | 875 " \"type\": \"blob\",\n" |
876 #ifndef _WIN64 | |
827 " \"address\": \"0x%08zX\",\n" | 877 " \"address\": \"0x%08zX\",\n" |
828 #ifndef _WIN64 | |
829 " \"size\": 6,\n" | 878 " \"size\": 6,\n" |
830 #else | 879 #else |
831 " \"size\": 7,\n" | 880 " \"address\": \"0x%08llX\",\n" |
881 " \"size\": 8,\n" | |
832 #endif | 882 #endif |
833 " \"data\": null\n" | 883 " \"data\": null\n" |
834 " }\n" | 884 " }\n" |
835 " },\n" | 885 " },\n" |
836 " \"error-type\": \"wild-access\",\n" | 886 " \"error-type\": \"wild-access\",\n" |
837 " \"access-mode\": \"read\",\n" | 887 " \"access-mode\": \"read\",\n" |
838 " \"access-size\": 4,\n" | 888 " \"access-size\": 4,\n" |
839 " \"shadow-memory-index\": 512,\n" | 889 " \"shadow-memory-index\": 512,\n" |
840 " \"shadow-memory\": {\n" | 890 " \"shadow-memory\": {\n" |
841 " \"type\": \"blob\",\n" | 891 " \"type\": \"blob\",\n" |
892 #ifndef _WIN64 | |
842 " \"address\": \"0x%08zX\",\n" | 893 " \"address\": \"0x%08zX\",\n" |
894 #else | |
895 " \"address\": \"0x%08llX\",\n" | |
896 #endif | |
843 " \"size\": 64,\n" | 897 " \"size\": 64,\n" |
844 " \"data\": null\n" | 898 " \"data\": null\n" |
845 " },\n" | 899 " },\n" |
846 " \"page-bits-index\": 0,\n" | 900 " \"page-bits-index\": 0,\n" |
847 " \"page-bits\": {\n" | 901 " \"page-bits\": {\n" |
848 " \"type\": \"blob\",\n" | 902 " \"type\": \"blob\",\n" |
903 #ifndef _WIN64 | |
849 " \"address\": \"0x%08zX\",\n" | 904 " \"address\": \"0x%08zX\",\n" |
905 #else | |
906 " \"address\": \"0x%08llX\",\n" | |
907 #endif | |
850 " \"size\": 3,\n" | 908 " \"size\": 3,\n" |
851 " \"data\": null\n" | 909 " \"data\": null\n" |
852 " },\n" | 910 " },\n" |
853 " \"heap-is-corrupt\": 1,\n" | 911 " \"heap-is-corrupt\": 1,\n" |
854 " \"corrupt-range-count\": 10,\n" | 912 " \"corrupt-range-count\": 10,\n" |
855 " \"corrupt-block-count\": 200,\n" | 913 " \"corrupt-block-count\": 200,\n" |
856 " \"corrupt-ranges\": [\n" | 914 " \"corrupt-ranges\": [\n" |
857 " {\n" | 915 " {\n" |
858 " \"address\": \"0xBAADF00D\",\n" | 916 " \"address\": \"0xBAADF00D\",\n" |
859 " \"length\": 1048576,\n" | 917 " \"length\": 1048576,\n" |
860 " \"block-count\": 100,\n" | 918 " \"block-count\": 100,\n" |
861 " \"blocks\": [\n" | 919 " \"blocks\": [\n" |
862 " {\n" | 920 " {\n" |
921 #ifndef _WIN64 | |
863 " \"header\": \"0x%08X\",\n" | 922 " \"header\": \"0x%08X\",\n" |
923 #else | |
924 " \"header\": \"0x%08llX\",\n" | |
925 #endif | |
864 " \"user-size\": 8,\n" | 926 " \"user-size\": 8,\n" |
865 " \"state\": \"allocated\",\n" | 927 " \"state\": \"allocated\",\n" |
866 " \"heap-type\": \"WinHeap\",\n" | 928 " \"heap-type\": \"WinHeap\",\n" |
867 " \"analysis\": {\n" | 929 " \"analysis\": {\n" |
868 " \"block\": \"corrupt\",\n" | 930 " \"block\": \"corrupt\",\n" |
869 " \"header\": \"corrupt\",\n" | 931 " \"header\": \"corrupt\",\n" |
870 " \"body\": \"(unknown)\",\n" | 932 " \"body\": \"(unknown)\",\n" |
871 " \"trailer\": \"clean\"\n" | 933 " \"trailer\": \"clean\"\n" |
872 " },\n" | 934 " },\n" |
873 " \"alloc-thread-id\": 47,\n" | 935 " \"alloc-thread-id\": 47,\n" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 // Check memory ranges. | 967 // Check memory ranges. |
906 ASSERT_EQ(4, memory_ranges.size()); | 968 ASSERT_EQ(4, memory_ranges.size()); |
907 const char* kExpectedMemoryRangesAddresses[] = { | 969 const char* kExpectedMemoryRangesAddresses[] = { |
908 reinterpret_cast<const char*>(block_info.header), | 970 reinterpret_cast<const char*>(block_info.header), |
909 reinterpret_cast<const char*>(BlockShadowAddress()), | 971 reinterpret_cast<const char*>(BlockShadowAddress()), |
910 reinterpret_cast<const char*>(shadow_memory.address), | 972 reinterpret_cast<const char*>(shadow_memory.address), |
911 reinterpret_cast<const char*>(runtime_->shadow()->page_bits())}; | 973 reinterpret_cast<const char*>(runtime_->shadow()->page_bits())}; |
912 #ifndef _WIN64 | 974 #ifndef _WIN64 |
913 size_t kExpectedMemoryRangesSize[] = {48, 6, 64, 3}; | 975 size_t kExpectedMemoryRangesSize[] = {48, 6, 64, 3}; |
914 #else | 976 #else |
915 size_t kExpectedMemoryRangesSize[] = {56, 7, 64, 3}; | 977 size_t kExpectedMemoryRangesSize[] = {64, 8, 64, 3}; |
916 #endif | 978 #endif |
917 for (int i = 0; i < memory_ranges.size(); i++) { | 979 for (int i = 0; i < memory_ranges.size(); i++) { |
918 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first) | 980 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first) |
919 << " Where i = " << i; | 981 << " Where i = " << i; |
920 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second) | 982 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second) |
921 << " Where i = " << i; | 983 << " Where i = " << i; |
922 } | 984 } |
923 } | 985 } |
924 | 986 |
925 TEST_F(AsanErrorInfoTest, CrashdataProtobufToErrorInfo) { | 987 TEST_F(AsanErrorInfoTest, CrashdataProtobufToErrorInfo) { |
(...skipping 20 matching lines...) Expand all Loading... | |
946 EXPECT_EQ(block_info.state, error_info_from_proto.block_info.state); | 1008 EXPECT_EQ(block_info.state, error_info_from_proto.block_info.state); |
947 EXPECT_EQ(block_info.heap_type, error_info_from_proto.block_info.heap_type); | 1009 EXPECT_EQ(block_info.heap_type, error_info_from_proto.block_info.heap_type); |
948 EXPECT_EQ(block_info.alloc_tid, error_info_from_proto.block_info.alloc_tid); | 1010 EXPECT_EQ(block_info.alloc_tid, error_info_from_proto.block_info.alloc_tid); |
949 EXPECT_EQ(block_info.free_tid, error_info_from_proto.block_info.free_tid); | 1011 EXPECT_EQ(block_info.free_tid, error_info_from_proto.block_info.free_tid); |
950 EXPECT_EQ(block_info.milliseconds_since_free, | 1012 EXPECT_EQ(block_info.milliseconds_since_free, |
951 error_info_from_proto.block_info.milliseconds_since_free); | 1013 error_info_from_proto.block_info.milliseconds_since_free); |
952 } | 1014 } |
953 | 1015 |
954 } // namespace asan | 1016 } // namespace asan |
955 } // namespace agent | 1017 } // namespace agent |
OLD | NEW |