| OLD | NEW |
| 1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 // and 3 is to account for some hook daisy chaining. | 670 // and 3 is to account for some hook daisy chaining. |
| 671 static const int kStackSize = kMaxSkip + 1; | 671 static const int kStackSize = kMaxSkip + 1; |
| 672 void* stack[kStackSize]; | 672 void* stack[kStackSize]; |
| 673 int depth = GetStackTrace(stack, kStackSize, 1); // skip this function frame | 673 int depth = GetStackTrace(stack, kStackSize, 1); // skip this function frame |
| 674 if (depth == 0) // silenty propagate cases when GetStackTrace does not work | 674 if (depth == 0) // silenty propagate cases when GetStackTrace does not work |
| 675 return 0; | 675 return 0; |
| 676 for (int i = 0; i < depth; ++i) { // stack[0] is our immediate caller | 676 for (int i = 0; i < depth; ++i) { // stack[0] is our immediate caller |
| 677 if (InHookCaller(stack[i])) { | 677 if (InHookCaller(stack[i])) { |
| 678 RAW_VLOG(10, "Found hooked allocator at %d: %p <- %p", | 678 RAW_VLOG(10, "Found hooked allocator at %d: %p <- %p", |
| 679 i, stack[i], stack[i+1]); | 679 i, stack[i], stack[i+1]); |
| 680 i += 1; // skip hook caller frame | 680 // i += 1; // skip hook caller frame |
| 681 // In deep profiler, we want to know the caller frame to |
| 682 // distinguish mmap from tcmalloc |
| 683 |
| 681 depth -= i; // correct depth | 684 depth -= i; // correct depth |
| 682 if (depth > max_depth) depth = max_depth; | 685 if (depth > max_depth) depth = max_depth; |
| 683 copy(stack + i, stack + i + depth, result); | 686 copy(stack + i, stack + i + depth, result); |
| 684 if (depth < max_depth && depth + i == kStackSize) { | 687 if (depth < max_depth && depth + i == kStackSize) { |
| 685 // get frames for the missing depth | 688 // get frames for the missing depth |
| 686 depth += | 689 depth += |
| 687 GetStackTrace(result + depth, max_depth - depth, 1 + kStackSize); | 690 GetStackTrace(result + depth, max_depth - depth, 1 + kStackSize); |
| 688 } | 691 } |
| 689 return depth; | 692 return depth; |
| 690 } | 693 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 /*static*/int MallocHook::UnhookedMUnmap(void *start, size_t length) { | 900 /*static*/int MallocHook::UnhookedMUnmap(void *start, size_t length) { |
| 898 int result; | 901 int result; |
| 899 if (!MallocHook::InvokeMunmapReplacement(start, length, &result)) { | 902 if (!MallocHook::InvokeMunmapReplacement(start, length, &result)) { |
| 900 result = munmap(start, length); | 903 result = munmap(start, length); |
| 901 } | 904 } |
| 902 return result; | 905 return result; |
| 903 } | 906 } |
| 904 | 907 |
| 905 #endif // defined(__linux) && | 908 #endif // defined(__linux) && |
| 906 // (defined(__i386__) || defined(__x86_64__) || defined(__PPC__)) | 909 // (defined(__i386__) || defined(__x86_64__) || defined(__PPC__)) |
| OLD | NEW |