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 " \"header\": \"0x%08X\",\n" | 319 " \"header\": \"0x%08IX\",\n" |
320 " \"user-size\": 8,\n" | 320 " \"user-size\": 8,\n" |
321 " \"state\": \"allocated\",\n" | 321 " \"state\": \"allocated\",\n" |
322 " \"heap-type\": \"WinHeap\",\n" | 322 " \"heap-type\": \"WinHeap\",\n" |
323 " \"analysis\": {\n" | 323 " \"analysis\": {\n" |
324 " \"block\": \"corrupt\",\n" | 324 " \"block\": \"corrupt\",\n" |
325 " \"header\": \"corrupt\",\n" | 325 " \"header\": \"corrupt\",\n" |
326 " \"body\": \"(unknown)\",\n" | 326 " \"body\": \"(unknown)\",\n" |
327 " \"trailer\": \"clean\"\n" | 327 " \"trailer\": \"clean\"\n" |
328 " },\n" | 328 " },\n" |
329 " \"alloc-thread-id\": 47,\n" | 329 " \"alloc-thread-id\": 47,\n" |
(...skipping 15 matching lines...) Expand all Loading... |
345 block_info.free_stack_size = 3; | 345 block_info.free_stack_size = 3; |
346 block_info.heap_type = kWinHeap; | 346 block_info.heap_type = kWinHeap; |
347 block_info.milliseconds_since_free = 100; | 347 block_info.milliseconds_since_free = 100; |
348 | 348 |
349 crashdata::Value value; | 349 crashdata::Value value; |
350 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, nullptr); | 350 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, nullptr); |
351 std::string json; | 351 std::string json; |
352 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); | 352 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); |
353 const char kExpected[] = | 353 const char kExpected[] = |
354 "{\n" | 354 "{\n" |
355 " \"header\": \"0x%08X\",\n" | 355 " \"header\": \"0x%08IX\",\n" |
356 " \"user-size\": 8,\n" | 356 " \"user-size\": 8,\n" |
357 " \"state\": \"quarantined (flooded)\",\n" | 357 " \"state\": \"quarantined (flooded)\",\n" |
358 " \"heap-type\": \"WinHeap\",\n" | 358 " \"heap-type\": \"WinHeap\",\n" |
359 " \"analysis\": {\n" | 359 " \"analysis\": {\n" |
360 " \"block\": \"corrupt\",\n" | 360 " \"block\": \"corrupt\",\n" |
361 " \"header\": \"corrupt\",\n" | 361 " \"header\": \"corrupt\",\n" |
362 " \"body\": \"(unknown)\",\n" | 362 " \"body\": \"(unknown)\",\n" |
363 " \"trailer\": \"clean\"\n" | 363 " \"trailer\": \"clean\"\n" |
364 " },\n" | 364 " },\n" |
365 " \"alloc-thread-id\": 47,\n" | 365 " \"alloc-thread-id\": 47,\n" |
366 " \"alloc-stack\": [\n" | 366 " \"alloc-stack\": [\n" |
367 " \"0x00000001\", \"0x00000002\"\n" | 367 " \"0x00000001\", \"0x00000002\"\n" |
368 " ],\n" | 368 " ],\n" |
369 " \"free-thread-id\": 32,\n" | 369 " \"free-thread-id\": 32,\n" |
370 " \"free-stack\": [\n" | 370 " \"free-stack\": [\n" |
371 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" | 371 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" |
372 " ],\n" | 372 " ],\n" |
373 " \"milliseconds-since-free\": 100,\n" | 373 " \"milliseconds-since-free\": 100,\n" |
374 " \"contents\": {\n" | 374 " \"contents\": {\n" |
375 " \"type\": \"blob\",\n" | 375 " \"type\": \"blob\",\n" |
376 " \"address\": \"0x%08X\",\n" | 376 " \"address\": \"0x%08IX\",\n" |
377 " \"size\": null,\n" | 377 " \"size\": null,\n" |
378 " \"data\": [\n" | 378 " \"data\": [\n" |
379 " \"0x80\", \"0xCA\", \"0x00\", \"0x00\", \"0x20\", \"0x00\"," | 379 " \"0x80\", \"0xCA\", \"0x00\", \"0x00\", \"0x20\", \"0x00\"," |
380 " \"0x00\", \"0x00\",\n" | 380 " \"0x00\", \"0x00\",\n" |
381 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 381 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
382 " \"0x00\", \"0x00\",\n" | 382 " \"0x00\", \"0x00\",\n" |
383 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 383 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
384 " \"0x00\", \"0x00\",\n" | 384 " \"0x00\", \"0x00\",\n" |
385 #ifdef _WIN64 | 385 #ifdef _WIN64 |
386 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 386 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
387 " \"0x00\", \"0x00\",\n" | 387 " \"0x00\", \"0x00\",\n" |
388 #endif | 388 #endif |
389 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," | 389 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," |
390 " \"0x00\", \"0x00\",\n" | 390 " \"0x00\", \"0x00\",\n" |
| 391 #ifdef _WIN64 |
| 392 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
| 393 " \"0x00\", \"0x00\",\n" |
| 394 #endif |
391 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 395 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
392 " \"0x00\", \"0x00\",\n" | 396 " \"0x00\", \"0x00\",\n" |
393 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 397 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
394 " \"0x00\", \"0x00\"\n" | 398 " \"0x00\", \"0x00\"\n" |
395 " ]\n" | 399 " ]\n" |
396 " },\n" | 400 " },\n" |
397 " \"shadow\": {\n" | 401 " \"shadow\": {\n" |
398 " \"type\": \"blob\",\n" | 402 " \"type\": \"blob\",\n" |
399 " \"address\": \"0x%08zX\",\n" | 403 " \"address\": \"0x%08IX\",\n" |
400 " \"size\": null,\n" | 404 " \"size\": null,\n" |
401 " \"data\": [\n" | 405 " \"data\": [\n" |
402 #ifndef _WIN64 | 406 #ifndef _WIN64 |
403 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" | 407 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" |
404 #else | 408 #else |
405 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," | 409 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," |
406 " \"0xF4\"\n" | 410 " \"0xFB\", \"0xF4\"\n" |
407 #endif | 411 #endif |
408 " ]\n" | 412 " ]\n" |
409 " }\n" | 413 " }\n" |
410 "}"; | 414 "}"; |
411 std::string expected = base::StringPrintf( | 415 std::string expected = base::StringPrintf( |
412 kExpected, | 416 kExpected, |
413 block_info.header, | 417 block_info.header, |
414 block_info.header, | 418 block_info.header, |
415 BlockShadowAddress()); | 419 BlockShadowAddress()); |
416 EXPECT_EQ(expected, json); | 420 EXPECT_EQ(expected, json); |
417 } | 421 } |
418 } | 422 } |
419 | 423 |
420 TEST_F(AsanErrorInfoTest, PopulateBlockInfoWithMemoryRanges) { | 424 TEST_F(AsanErrorInfoTest, PopulateBlockInfoWithMemoryRanges) { |
421 AsanBlockInfo block_info = {}; | 425 AsanBlockInfo block_info = {}; |
422 InitAsanBlockInfo(&block_info); | 426 InitAsanBlockInfo(&block_info); |
423 | 427 |
424 { | 428 { |
425 crashdata::Value info; | 429 crashdata::Value info; |
426 PopulateBlockInfo(runtime_->shadow(), block_info, false, &info, nullptr); | 430 PopulateBlockInfo(runtime_->shadow(), block_info, false, &info, nullptr); |
427 std::string json; | 431 std::string json; |
428 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 432 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
429 const char kExpected[] = | 433 const char kExpected[] = |
430 "{\n" | 434 "{\n" |
431 " \"header\": \"0x%08X\",\n" | 435 " \"header\": \"0x%08IX\",\n" |
432 " \"user-size\": 8,\n" | 436 " \"user-size\": 8,\n" |
433 " \"state\": \"allocated\",\n" | 437 " \"state\": \"allocated\",\n" |
434 " \"heap-type\": \"WinHeap\",\n" | 438 " \"heap-type\": \"WinHeap\",\n" |
435 " \"analysis\": {\n" | 439 " \"analysis\": {\n" |
436 " \"block\": \"corrupt\",\n" | 440 " \"block\": \"corrupt\",\n" |
437 " \"header\": \"corrupt\",\n" | 441 " \"header\": \"corrupt\",\n" |
438 " \"body\": \"(unknown)\",\n" | 442 " \"body\": \"(unknown)\",\n" |
439 " \"trailer\": \"clean\"\n" | 443 " \"trailer\": \"clean\"\n" |
440 " },\n" | 444 " },\n" |
441 " \"alloc-thread-id\": 47,\n" | 445 " \"alloc-thread-id\": 47,\n" |
(...skipping 16 matching lines...) Expand all Loading... |
458 block_info.milliseconds_since_free = 100; | 462 block_info.milliseconds_since_free = 100; |
459 | 463 |
460 crashdata::Value value; | 464 crashdata::Value value; |
461 MemoryRanges memory_ranges; | 465 MemoryRanges memory_ranges; |
462 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, | 466 PopulateBlockInfo(runtime_->shadow(), block_info, true, &value, |
463 &memory_ranges); | 467 &memory_ranges); |
464 std::string json; | 468 std::string json; |
465 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); | 469 EXPECT_TRUE(crashdata::ToJson(true, &value, &json)); |
466 const char kExpected[] = | 470 const char kExpected[] = |
467 "{\n" | 471 "{\n" |
468 " \"header\": \"0x%08X\",\n" | 472 " \"header\": \"0x%08IX\",\n" |
469 " \"user-size\": 8,\n" | 473 " \"user-size\": 8,\n" |
470 " \"state\": \"quarantined (flooded)\",\n" | 474 " \"state\": \"quarantined (flooded)\",\n" |
471 " \"heap-type\": \"WinHeap\",\n" | 475 " \"heap-type\": \"WinHeap\",\n" |
472 " \"analysis\": {\n" | 476 " \"analysis\": {\n" |
473 " \"block\": \"corrupt\",\n" | 477 " \"block\": \"corrupt\",\n" |
474 " \"header\": \"corrupt\",\n" | 478 " \"header\": \"corrupt\",\n" |
475 " \"body\": \"(unknown)\",\n" | 479 " \"body\": \"(unknown)\",\n" |
476 " \"trailer\": \"clean\"\n" | 480 " \"trailer\": \"clean\"\n" |
477 " },\n" | 481 " },\n" |
478 " \"alloc-thread-id\": 47,\n" | 482 " \"alloc-thread-id\": 47,\n" |
479 " \"alloc-stack\": [\n" | 483 " \"alloc-stack\": [\n" |
480 " \"0x00000001\", \"0x00000002\"\n" | 484 " \"0x00000001\", \"0x00000002\"\n" |
481 " ],\n" | 485 " ],\n" |
482 " \"free-thread-id\": 32,\n" | 486 " \"free-thread-id\": 32,\n" |
483 " \"free-stack\": [\n" | 487 " \"free-stack\": [\n" |
484 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" | 488 " \"0x00000003\", \"0x00000004\", \"0x00000005\"\n" |
485 " ],\n" | 489 " ],\n" |
486 " \"milliseconds-since-free\": 100,\n" | 490 " \"milliseconds-since-free\": 100,\n" |
487 " \"contents\": {\n" | 491 " \"contents\": {\n" |
488 " \"type\": \"blob\",\n" | 492 " \"type\": \"blob\",\n" |
489 " \"address\": \"0x%08zX\",\n" | 493 " \"address\": \"0x%08zX\",\n" |
490 #ifndef _WIN64 | 494 #ifndef _WIN64 |
491 " \"size\": 48,\n" | 495 " \"size\": 48,\n" |
492 #else | 496 #else |
493 " \"size\": 56,\n" | 497 " \"size\": 64,\n" |
494 #endif | 498 #endif |
495 " \"data\": null\n" | 499 " \"data\": null\n" |
496 " },\n" | 500 " },\n" |
497 " \"shadow\": {\n" | 501 " \"shadow\": {\n" |
498 " \"type\": \"blob\",\n" | 502 " \"type\": \"blob\",\n" |
499 " \"address\": \"0x%08zX\",\n" | 503 " \"address\": \"0x%08zX\",\n" |
500 #ifndef _WIN64 | 504 #ifndef _WIN64 |
501 " \"size\": 6,\n" | 505 " \"size\": 6,\n" |
502 #else | 506 #else |
503 " \"size\": 7,\n" | 507 " \"size\": 8,\n" |
504 #endif | 508 #endif |
505 " \"data\": null\n" | 509 " \"data\": null\n" |
506 " }\n" | 510 " }\n" |
507 "}"; | 511 "}"; |
508 std::string expected = base::StringPrintf( | 512 std::string expected = base::StringPrintf( |
509 kExpected, block_info.header, block_info.header, BlockShadowAddress()); | 513 kExpected, block_info.header, block_info.header, BlockShadowAddress()); |
510 EXPECT_EQ(expected, json); | 514 EXPECT_EQ(expected, json); |
511 | 515 |
512 ASSERT_EQ(2, memory_ranges.size()); | 516 ASSERT_EQ(2, memory_ranges.size()); |
513 const char* kExpectedMemoryRangesAddresses[] = { | 517 const char* kExpectedMemoryRangesAddresses[] = { |
514 reinterpret_cast<const char*>(block_info.header), | 518 reinterpret_cast<const char*>(block_info.header), |
515 reinterpret_cast<const char*>(BlockShadowAddress())}; | 519 reinterpret_cast<const char*>(BlockShadowAddress())}; |
516 #ifndef _WIN64 | 520 #ifndef _WIN64 |
517 size_t kExpectedMemoryRangesSize[] = {48, 6}; | 521 size_t kExpectedMemoryRangesSize[] = {48, 6}; |
518 #else | 522 #else |
519 size_t kExpectedMemoryRangesSize[] = {56, 7}; | 523 size_t kExpectedMemoryRangesSize[] = {64, 8}; |
520 #endif | 524 #endif |
521 for (int i = 0; i < 2; i++) { | 525 for (int i = 0; i < 2; i++) { |
522 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first); | 526 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first); |
523 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second); | 527 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second); |
524 } | 528 } |
525 } | 529 } |
526 } | 530 } |
527 | 531 |
528 TEST_F(AsanErrorInfoTest, PopulateCorruptBlockRange) { | 532 TEST_F(AsanErrorInfoTest, PopulateCorruptBlockRange) { |
529 AsanBlockInfo block_info = {}; | 533 AsanBlockInfo block_info = {}; |
(...skipping 11 matching lines...) Expand all Loading... |
541 | 545 |
542 std::string json; | 546 std::string json; |
543 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 547 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
544 const char kExpected[] = | 548 const char kExpected[] = |
545 "{\n" | 549 "{\n" |
546 " \"address\": \"0xBAADF00D\",\n" | 550 " \"address\": \"0xBAADF00D\",\n" |
547 " \"length\": 1048576,\n" | 551 " \"length\": 1048576,\n" |
548 " \"block-count\": 100,\n" | 552 " \"block-count\": 100,\n" |
549 " \"blocks\": [\n" | 553 " \"blocks\": [\n" |
550 " {\n" | 554 " {\n" |
551 " \"header\": \"0x%08X\",\n" | 555 " \"header\": \"0x%08IX\",\n" |
552 " \"user-size\": 8,\n" | 556 " \"user-size\": 8,\n" |
553 " \"state\": \"allocated\",\n" | 557 " \"state\": \"allocated\",\n" |
554 " \"heap-type\": \"WinHeap\",\n" | 558 " \"heap-type\": \"WinHeap\",\n" |
555 " \"analysis\": {\n" | 559 " \"analysis\": {\n" |
556 " \"block\": \"corrupt\",\n" | 560 " \"block\": \"corrupt\",\n" |
557 " \"header\": \"corrupt\",\n" | 561 " \"header\": \"corrupt\",\n" |
558 " \"body\": \"(unknown)\",\n" | 562 " \"body\": \"(unknown)\",\n" |
559 " \"trailer\": \"clean\"\n" | 563 " \"trailer\": \"clean\"\n" |
560 " },\n" | 564 " },\n" |
561 " \"alloc-thread-id\": 47,\n" | 565 " \"alloc-thread-id\": 47,\n" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 crashdata::Value info; | 611 crashdata::Value info; |
608 PopulateErrorInfo(runtime_->shadow(), error_info, &info, nullptr); | 612 PopulateErrorInfo(runtime_->shadow(), error_info, &info, nullptr); |
609 | 613 |
610 std::string json; | 614 std::string json; |
611 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 615 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
612 const char kExpected[] = | 616 const char kExpected[] = |
613 "{\n" | 617 "{\n" |
614 " \"location\": \"0x00001000\",\n" | 618 " \"location\": \"0x00001000\",\n" |
615 " \"crash-stack-id\": 1234,\n" | 619 " \"crash-stack-id\": 1234,\n" |
616 " \"block-info\": {\n" | 620 " \"block-info\": {\n" |
617 " \"header\": \"0x%08X\",\n" | 621 " \"header\": \"0x%08IX\",\n" |
618 " \"user-size\": 8,\n" | 622 " \"user-size\": 8,\n" |
619 " \"state\": \"allocated\",\n" | 623 " \"state\": \"allocated\",\n" |
620 " \"heap-type\": \"WinHeap\",\n" | 624 " \"heap-type\": \"WinHeap\",\n" |
621 " \"analysis\": {\n" | 625 " \"analysis\": {\n" |
622 " \"block\": \"corrupt\",\n" | 626 " \"block\": \"corrupt\",\n" |
623 " \"header\": \"corrupt\",\n" | 627 " \"header\": \"corrupt\",\n" |
624 " \"body\": \"(unknown)\",\n" | 628 " \"body\": \"(unknown)\",\n" |
625 " \"trailer\": \"clean\"\n" | 629 " \"trailer\": \"clean\"\n" |
626 " },\n" | 630 " },\n" |
627 " \"alloc-thread-id\": 47,\n" | 631 " \"alloc-thread-id\": 47,\n" |
(...skipping 10 matching lines...) Expand all Loading... |
638 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 642 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
639 " \"0x00\", \"0x00\",\n" | 643 " \"0x00\", \"0x00\",\n" |
640 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 644 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
641 " \"0x00\", \"0x00\",\n" | 645 " \"0x00\", \"0x00\",\n" |
642 #ifdef _WIN64 | 646 #ifdef _WIN64 |
643 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 647 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
644 " \"0x00\", \"0x00\",\n" | 648 " \"0x00\", \"0x00\",\n" |
645 #endif | 649 #endif |
646 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," | 650 " \"0xC3\", \"0xC3\", \"0xC3\", \"0xC3\", \"0x00\", \"0x00\"," |
647 " \"0x00\", \"0x00\",\n" | 651 " \"0x00\", \"0x00\",\n" |
| 652 #ifdef _WIN64 |
| 653 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
| 654 " \"0x00\", \"0x00\",\n" |
| 655 #endif |
648 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 656 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
649 " \"0x00\", \"0x00\",\n" | 657 " \"0x00\", \"0x00\",\n" |
650 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," | 658 " \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\", \"0x00\"," |
651 " \"0x00\", \"0x00\"\n" | 659 " \"0x00\", \"0x00\"\n" |
652 " ]\n" | 660 " ]\n" |
653 " },\n" | 661 " },\n" |
654 " \"shadow\": {\n" | 662 " \"shadow\": {\n" |
655 " \"type\": \"blob\",\n" | 663 " \"type\": \"blob\",\n" |
656 " \"address\": \"0x%08zX\",\n" | 664 " \"address\": \"0x%08zX\",\n" |
657 " \"size\": null,\n" | 665 " \"size\": null,\n" |
658 " \"data\": [\n" | 666 " \"data\": [\n" |
659 #ifndef _WIN64 | 667 #ifndef _WIN64 |
660 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" | 668 " \"0xE0\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\", \"0xF4\"\n" |
661 #else | 669 #else |
662 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," | 670 " \"0xE0\", \"0xFA\", \"0xFA\", \"0x00\", \"0xFB\", \"0xFB\"," |
663 " \"0xF4\"\n" | 671 " \"0xFB\", \"0xF4\"\n" |
664 #endif | 672 #endif |
665 " ]\n" | 673 " ]\n" |
666 " }\n" | 674 " }\n" |
667 " },\n" | 675 " },\n" |
668 " \"error-type\": \"wild-access\",\n" | 676 " \"error-type\": \"wild-access\",\n" |
669 " \"access-mode\": \"read\",\n" | 677 " \"access-mode\": \"read\",\n" |
670 " \"access-size\": 4,\n" | 678 " \"access-size\": 4,\n" |
671 " \"shadow-memory-index\": 512,\n" | 679 " \"shadow-memory-index\": 512,\n" |
672 " \"shadow-memory\": {\n" | 680 " \"shadow-memory\": {\n" |
673 " \"type\": \"blob\",\n" | 681 " \"type\": \"blob\",\n" |
(...skipping 30 matching lines...) Expand all Loading... |
704 " \"heap-is-corrupt\": 1,\n" | 712 " \"heap-is-corrupt\": 1,\n" |
705 " \"corrupt-range-count\": 10,\n" | 713 " \"corrupt-range-count\": 10,\n" |
706 " \"corrupt-block-count\": 200,\n" | 714 " \"corrupt-block-count\": 200,\n" |
707 " \"corrupt-ranges\": [\n" | 715 " \"corrupt-ranges\": [\n" |
708 " {\n" | 716 " {\n" |
709 " \"address\": \"0xBAADF00D\",\n" | 717 " \"address\": \"0xBAADF00D\",\n" |
710 " \"length\": 1048576,\n" | 718 " \"length\": 1048576,\n" |
711 " \"block-count\": 100,\n" | 719 " \"block-count\": 100,\n" |
712 " \"blocks\": [\n" | 720 " \"blocks\": [\n" |
713 " {\n" | 721 " {\n" |
714 " \"header\": \"0x%08X\",\n" | 722 " \"header\": \"0x%08IX\",\n" |
715 " \"user-size\": 8,\n" | 723 " \"user-size\": 8,\n" |
716 " \"state\": \"allocated\",\n" | 724 " \"state\": \"allocated\",\n" |
717 " \"heap-type\": \"WinHeap\",\n" | 725 " \"heap-type\": \"WinHeap\",\n" |
718 " \"analysis\": {\n" | 726 " \"analysis\": {\n" |
719 " \"block\": \"corrupt\",\n" | 727 " \"block\": \"corrupt\",\n" |
720 " \"header\": \"corrupt\",\n" | 728 " \"header\": \"corrupt\",\n" |
721 " \"body\": \"(unknown)\",\n" | 729 " \"body\": \"(unknown)\",\n" |
722 " \"trailer\": \"clean\"\n" | 730 " \"trailer\": \"clean\"\n" |
723 " },\n" | 731 " },\n" |
724 " \"alloc-thread-id\": 47,\n" | 732 " \"alloc-thread-id\": 47,\n" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 MemoryRanges memory_ranges; | 799 MemoryRanges memory_ranges; |
792 PopulateErrorInfo(runtime_->shadow(), error_info, &info, &memory_ranges); | 800 PopulateErrorInfo(runtime_->shadow(), error_info, &info, &memory_ranges); |
793 | 801 |
794 std::string json; | 802 std::string json; |
795 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); | 803 EXPECT_TRUE(crashdata::ToJson(true, &info, &json)); |
796 const char kExpected[] = | 804 const char kExpected[] = |
797 "{\n" | 805 "{\n" |
798 " \"location\": \"0x00001000\",\n" | 806 " \"location\": \"0x00001000\",\n" |
799 " \"crash-stack-id\": 1234,\n" | 807 " \"crash-stack-id\": 1234,\n" |
800 " \"block-info\": {\n" | 808 " \"block-info\": {\n" |
801 " \"header\": \"0x%08X\",\n" | 809 " \"header\": \"0x%08IX\",\n" |
802 " \"user-size\": 8,\n" | 810 " \"user-size\": 8,\n" |
803 " \"state\": \"allocated\",\n" | 811 " \"state\": \"allocated\",\n" |
804 " \"heap-type\": \"WinHeap\",\n" | 812 " \"heap-type\": \"WinHeap\",\n" |
805 " \"analysis\": {\n" | 813 " \"analysis\": {\n" |
806 " \"block\": \"corrupt\",\n" | 814 " \"block\": \"corrupt\",\n" |
807 " \"header\": \"corrupt\",\n" | 815 " \"header\": \"corrupt\",\n" |
808 " \"body\": \"(unknown)\",\n" | 816 " \"body\": \"(unknown)\",\n" |
809 " \"trailer\": \"clean\"\n" | 817 " \"trailer\": \"clean\"\n" |
810 " },\n" | 818 " },\n" |
811 " \"alloc-thread-id\": 47,\n" | 819 " \"alloc-thread-id\": 47,\n" |
812 " \"alloc-stack\": [\n" | 820 " \"alloc-stack\": [\n" |
813 " \"0x00000001\", \"0x00000002\"\n" | 821 " \"0x00000001\", \"0x00000002\"\n" |
814 " ],\n" | 822 " ],\n" |
815 " \"contents\": {\n" | 823 " \"contents\": {\n" |
816 " \"type\": \"blob\",\n" | 824 " \"type\": \"blob\",\n" |
817 " \"address\": \"0x%08zX\",\n" | 825 " \"address\": \"0x%08IX\",\n" |
818 #ifndef _WIN64 | 826 #ifndef _WIN64 |
819 " \"size\": 48,\n" | 827 " \"size\": 48,\n" |
820 #else | 828 #else |
821 " \"size\": 56,\n" | 829 " \"size\": 64,\n" |
822 #endif | 830 #endif |
823 " \"data\": null\n" | 831 " \"data\": null\n" |
824 " },\n" | 832 " },\n" |
825 " \"shadow\": {\n" | 833 " \"shadow\": {\n" |
826 " \"type\": \"blob\",\n" | 834 " \"type\": \"blob\",\n" |
827 " \"address\": \"0x%08zX\",\n" | 835 " \"address\": \"0x%08IX\",\n" |
828 #ifndef _WIN64 | 836 #ifndef _WIN64 |
829 " \"size\": 6,\n" | 837 " \"size\": 6,\n" |
830 #else | 838 #else |
831 " \"size\": 7,\n" | 839 " \"size\": 8,\n" |
832 #endif | 840 #endif |
833 " \"data\": null\n" | 841 " \"data\": null\n" |
834 " }\n" | 842 " }\n" |
835 " },\n" | 843 " },\n" |
836 " \"error-type\": \"wild-access\",\n" | 844 " \"error-type\": \"wild-access\",\n" |
837 " \"access-mode\": \"read\",\n" | 845 " \"access-mode\": \"read\",\n" |
838 " \"access-size\": 4,\n" | 846 " \"access-size\": 4,\n" |
839 " \"shadow-memory-index\": 512,\n" | 847 " \"shadow-memory-index\": 512,\n" |
840 " \"shadow-memory\": {\n" | 848 " \"shadow-memory\": {\n" |
841 " \"type\": \"blob\",\n" | 849 " \"type\": \"blob\",\n" |
842 " \"address\": \"0x%08zX\",\n" | 850 " \"address\": \"0x%08IX\",\n" |
843 " \"size\": 64,\n" | 851 " \"size\": 64,\n" |
844 " \"data\": null\n" | 852 " \"data\": null\n" |
845 " },\n" | 853 " },\n" |
846 " \"page-bits-index\": 0,\n" | 854 " \"page-bits-index\": 0,\n" |
847 " \"page-bits\": {\n" | 855 " \"page-bits\": {\n" |
848 " \"type\": \"blob\",\n" | 856 " \"type\": \"blob\",\n" |
849 " \"address\": \"0x%08zX\",\n" | 857 " \"address\": \"0x%08IX\",\n" |
850 " \"size\": 3,\n" | 858 " \"size\": 3,\n" |
851 " \"data\": null\n" | 859 " \"data\": null\n" |
852 " },\n" | 860 " },\n" |
853 " \"heap-is-corrupt\": 1,\n" | 861 " \"heap-is-corrupt\": 1,\n" |
854 " \"corrupt-range-count\": 10,\n" | 862 " \"corrupt-range-count\": 10,\n" |
855 " \"corrupt-block-count\": 200,\n" | 863 " \"corrupt-block-count\": 200,\n" |
856 " \"corrupt-ranges\": [\n" | 864 " \"corrupt-ranges\": [\n" |
857 " {\n" | 865 " {\n" |
858 " \"address\": \"0xBAADF00D\",\n" | 866 " \"address\": \"0xBAADF00D\",\n" |
859 " \"length\": 1048576,\n" | 867 " \"length\": 1048576,\n" |
860 " \"block-count\": 100,\n" | 868 " \"block-count\": 100,\n" |
861 " \"blocks\": [\n" | 869 " \"blocks\": [\n" |
862 " {\n" | 870 " {\n" |
863 " \"header\": \"0x%08X\",\n" | 871 " \"header\": \"0x%08IX\",\n" |
864 " \"user-size\": 8,\n" | 872 " \"user-size\": 8,\n" |
865 " \"state\": \"allocated\",\n" | 873 " \"state\": \"allocated\",\n" |
866 " \"heap-type\": \"WinHeap\",\n" | 874 " \"heap-type\": \"WinHeap\",\n" |
867 " \"analysis\": {\n" | 875 " \"analysis\": {\n" |
868 " \"block\": \"corrupt\",\n" | 876 " \"block\": \"corrupt\",\n" |
869 " \"header\": \"corrupt\",\n" | 877 " \"header\": \"corrupt\",\n" |
870 " \"body\": \"(unknown)\",\n" | 878 " \"body\": \"(unknown)\",\n" |
871 " \"trailer\": \"clean\"\n" | 879 " \"trailer\": \"clean\"\n" |
872 " },\n" | 880 " },\n" |
873 " \"alloc-thread-id\": 47,\n" | 881 " \"alloc-thread-id\": 47,\n" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 // Check memory ranges. | 913 // Check memory ranges. |
906 ASSERT_EQ(4, memory_ranges.size()); | 914 ASSERT_EQ(4, memory_ranges.size()); |
907 const char* kExpectedMemoryRangesAddresses[] = { | 915 const char* kExpectedMemoryRangesAddresses[] = { |
908 reinterpret_cast<const char*>(block_info.header), | 916 reinterpret_cast<const char*>(block_info.header), |
909 reinterpret_cast<const char*>(BlockShadowAddress()), | 917 reinterpret_cast<const char*>(BlockShadowAddress()), |
910 reinterpret_cast<const char*>(shadow_memory.address), | 918 reinterpret_cast<const char*>(shadow_memory.address), |
911 reinterpret_cast<const char*>(runtime_->shadow()->page_bits())}; | 919 reinterpret_cast<const char*>(runtime_->shadow()->page_bits())}; |
912 #ifndef _WIN64 | 920 #ifndef _WIN64 |
913 size_t kExpectedMemoryRangesSize[] = {48, 6, 64, 3}; | 921 size_t kExpectedMemoryRangesSize[] = {48, 6, 64, 3}; |
914 #else | 922 #else |
915 size_t kExpectedMemoryRangesSize[] = {56, 7, 64, 3}; | 923 size_t kExpectedMemoryRangesSize[] = {64, 8, 64, 3}; |
916 #endif | 924 #endif |
917 for (int i = 0; i < memory_ranges.size(); i++) { | 925 for (int i = 0; i < memory_ranges.size(); i++) { |
918 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first) | 926 EXPECT_EQ(kExpectedMemoryRangesAddresses[i], memory_ranges[i].first) |
919 << " Where i = " << i; | 927 << " Where i = " << i; |
920 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second) | 928 EXPECT_EQ(kExpectedMemoryRangesSize[i], memory_ranges[i].second) |
921 << " Where i = " << i; | 929 << " Where i = " << i; |
922 } | 930 } |
923 } | 931 } |
924 | 932 |
925 TEST_F(AsanErrorInfoTest, CrashdataProtobufToErrorInfo) { | 933 TEST_F(AsanErrorInfoTest, CrashdataProtobufToErrorInfo) { |
(...skipping 20 matching lines...) Expand all Loading... |
946 EXPECT_EQ(block_info.state, error_info_from_proto.block_info.state); | 954 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); | 955 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); | 956 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); | 957 EXPECT_EQ(block_info.free_tid, error_info_from_proto.block_info.free_tid); |
950 EXPECT_EQ(block_info.milliseconds_since_free, | 958 EXPECT_EQ(block_info.milliseconds_since_free, |
951 error_info_from_proto.block_info.milliseconds_since_free); | 959 error_info_from_proto.block_info.milliseconds_since_free); |
952 } | 960 } |
953 | 961 |
954 } // namespace asan | 962 } // namespace asan |
955 } // namespace agent | 963 } // namespace agent |
OLD | NEW |