| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 heap_profiler_free((void*)(i * 32), 32, NULL); | 420 heap_profiler_free((void*)(i * 32), 32, NULL); |
| 421 | 421 |
| 422 EXPECT_EQ(0, stats_.num_allocs); | 422 EXPECT_EQ(0, stats_.num_allocs); |
| 423 EXPECT_EQ(0, stats_.total_alloc_bytes); | 423 EXPECT_EQ(0, stats_.total_alloc_bytes); |
| 424 EXPECT_EQ(0, stats_.num_stack_traces); | 424 EXPECT_EQ(0, stats_.num_stack_traces); |
| 425 } | 425 } |
| 426 | 426 |
| 427 #ifdef __LP64__ | 427 #ifdef __LP64__ |
| 428 TEST_F(HeapProfilerTest, Test64Bit) { | 428 TEST_F(HeapProfilerTest, Test64Bit) { |
| 429 StackTrace st1 = GenStackTrace(8, 0x0); | 429 StackTrace st1 = GenStackTrace(8, 0x0); |
| 430 StackTrace st2 = GenStackTrace(10, 0x7fffffff70000000LL); | 430 StackTrace st2 = GenStackTrace(10, 0x7fffffff70000000L); |
| 431 StackTrace st3 = GenStackTrace(10, 0xffffffff70000000LL); | 431 StackTrace st3 = GenStackTrace(10, 0xffffffff70000000L); |
| 432 heap_profiler_alloc((void*)0x1000, 4096, st1.frames, st1.depth, 0); | 432 heap_profiler_alloc((void*)0x1000, 4096, st1.frames, st1.depth, 0); |
| 433 heap_profiler_alloc((void*)0x7ffffffffffff000LL, 4096, st2.frames, st2.depth); | 433 heap_profiler_alloc( |
| 434 heap_profiler_alloc((void*)0xfffffffffffff000LL, 4096, st3.frames, st3.depth); | 434 (void*)0x7ffffffffffff000L, 4096, st2.frames, st2.depth, 0); |
| 435 heap_profiler_alloc( |
| 436 (void*)0xfffffffffffff000L, 4096, st3.frames, st3.depth, 0); |
| 435 EXPECT_EQ(3, stats_.num_allocs); | 437 EXPECT_EQ(3, stats_.num_allocs); |
| 436 EXPECT_EQ(3, stats_.num_stack_traces); | 438 EXPECT_EQ(3, stats_.num_stack_traces); |
| 437 EXPECT_EQ(4096 + 4096 + 4096, stats_.total_alloc_bytes); | 439 EXPECT_EQ(4096 + 4096 + 4096, stats_.total_alloc_bytes); |
| 438 | 440 |
| 439 heap_profiler_free((void*)0x1000, 4096, NULL); | 441 heap_profiler_free((void*)0x1000, 4096, NULL); |
| 440 EXPECT_EQ(2, stats_.num_allocs); | 442 EXPECT_EQ(2, stats_.num_allocs); |
| 441 EXPECT_EQ(2, stats_.num_stack_traces); | 443 EXPECT_EQ(2, stats_.num_stack_traces); |
| 442 EXPECT_EQ(4096 + 4096, stats_.total_alloc_bytes); | 444 EXPECT_EQ(4096 + 4096, stats_.total_alloc_bytes); |
| 443 | 445 |
| 444 heap_profiler_free((void*)0x7ffffffffffff000LL, 4096, NULL); | 446 heap_profiler_free((void*)0x7ffffffffffff000L, 4096, NULL); |
| 445 EXPECT_EQ(1, stats_.num_allocs); | 447 EXPECT_EQ(1, stats_.num_allocs); |
| 446 EXPECT_EQ(1, stats_.num_stack_traces); | 448 EXPECT_EQ(1, stats_.num_stack_traces); |
| 447 EXPECT_EQ(4096, stats_.total_alloc_bytes); | 449 EXPECT_EQ(4096, stats_.total_alloc_bytes); |
| 448 | 450 |
| 449 heap_profiler_free((void*)0xfffffffffffff000LL, 4096, NULL); | 451 heap_profiler_free((void*)0xfffffffffffff000L, 4096, NULL); |
| 450 EXPECT_EQ(0, stats_.num_allocs); | 452 EXPECT_EQ(0, stats_.num_allocs); |
| 451 EXPECT_EQ(0, stats_.num_stack_traces); | 453 EXPECT_EQ(0, stats_.num_stack_traces); |
| 452 EXPECT_EQ(0, stats_.total_alloc_bytes); | 454 EXPECT_EQ(0, stats_.total_alloc_bytes); |
| 453 } | 455 } |
| 454 #endif | 456 #endif |
| 455 | 457 |
| 456 } // namespace | 458 } // namespace |
| OLD | NEW |