Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/address_sanitizer.h" | 5 #include "platform/address_sanitizer.h" |
| 6 #include "platform/memory_sanitizer.h" | 6 #include "platform/memory_sanitizer.h" |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 | 8 |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 790 sizeof(fault_address), new_protect, &old_protect); | 790 sizeof(fault_address), new_protect, &old_protect); |
| 791 USE(success); | 791 USE(success); |
| 792 ASSERT(success); | 792 ASSERT(success); |
| 793 ASSERT(old_protect == PAGE_READWRITE); | 793 ASSERT(old_protect == PAGE_READWRITE); |
| 794 } | 794 } |
| 795 #endif | 795 #endif |
| 796 } | 796 } |
| 797 | 797 |
| 798 | 798 |
| 799 // Get |isolate|'s stack boundary and verify that |sp| and |fp| are within | 799 // Get |isolate|'s stack boundary and verify that |sp| and |fp| are within |
| 800 // it. Return |false| if anything looks suspicious. | 800 // it. If |get_os_thread_bounds| is true then if |isolate| stackbounds are |
| 801 static bool GetAndValidateIsolateStackBounds(Thread* thread, | 801 // not available we fallback to using underlying OS thread bounds. This only |
| 802 uintptr_t fp, | 802 // works for the current thread. |
| 803 uintptr_t sp, | 803 // Return |false| if anything looks suspicious. |
| 804 uword* stack_lower, | 804 static bool GetAndValidateIsolateStackBounds( |
|
Cutch
2017/02/09 16:45:24
While you're here, this could be renamed to GetAnd
Vyacheslav Egorov (Google)
2017/02/09 17:19:20
Done.
| |
| 805 uword* stack_upper) { | 805 Thread* thread, |
| 806 uintptr_t fp, | |
| 807 uintptr_t sp, | |
| 808 uword* stack_lower, | |
| 809 uword* stack_upper, | |
| 810 bool get_os_thread_bounds = false) { | |
| 806 ASSERT(thread != NULL); | 811 ASSERT(thread != NULL); |
| 807 OSThread* os_thread = thread->os_thread(); | 812 OSThread* os_thread = thread->os_thread(); |
| 808 ASSERT(os_thread != NULL); | 813 ASSERT(os_thread != NULL); |
| 809 ASSERT(stack_lower != NULL); | 814 ASSERT(stack_lower != NULL); |
| 810 ASSERT(stack_upper != NULL); | 815 ASSERT(stack_upper != NULL); |
| 816 ASSERT(!get_os_thread_bounds || (Thread::Current() == thread)); | |
| 817 | |
| 811 #if defined(USING_SIMULATOR) | 818 #if defined(USING_SIMULATOR) |
| 812 const bool in_dart_code = thread->IsExecutingDartCode(); | 819 const bool use_simulator_stack_bounds = thread->IsExecutingDartCode(); |
| 813 if (in_dart_code) { | 820 if (use_simulator_stack_bounds) { |
| 814 Isolate* isolate = thread->isolate(); | 821 Isolate* isolate = thread->isolate(); |
| 815 ASSERT(isolate != NULL); | 822 ASSERT(isolate != NULL); |
| 816 Simulator* simulator = isolate->simulator(); | 823 Simulator* simulator = isolate->simulator(); |
| 817 *stack_lower = simulator->StackBase(); | 824 *stack_lower = simulator->StackBase(); |
| 818 *stack_upper = simulator->StackTop(); | 825 *stack_upper = simulator->StackTop(); |
| 819 } else if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper)) { | 826 } |
| 827 #else | |
| 828 const bool use_simulator_stack_bounds = false; | |
| 829 #endif | |
| 830 | |
| 831 if (!use_simulator_stack_bounds && | |
| 832 !os_thread->GetProfilerStackBounds(stack_lower, stack_upper) && | |
| 833 !(get_os_thread_bounds && | |
| 834 OSThread::GetCurrentStackBounds(stack_lower, stack_upper))) { | |
| 820 // Could not get stack boundary. | 835 // Could not get stack boundary. |
| 821 return false; | 836 return false; |
| 822 } | 837 } |
| 838 | |
| 823 if ((*stack_lower == 0) || (*stack_upper == 0)) { | 839 if ((*stack_lower == 0) || (*stack_upper == 0)) { |
| 824 return false; | 840 return false; |
| 825 } | 841 } |
| 826 #else | |
| 827 if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper) || | |
| 828 (*stack_lower == 0) || (*stack_upper == 0)) { | |
| 829 // Could not get stack boundary. | |
| 830 return false; | |
| 831 } | |
| 832 #endif | |
| 833 | 842 |
| 834 #if defined(TARGET_ARCH_DBC) | 843 if (!use_simulator_stack_bounds && (sp > *stack_lower)) { |
| 835 if (!in_dart_code && (sp > *stack_lower)) { | |
| 836 // The stack pointer gives us a tighter lower bound. | 844 // The stack pointer gives us a tighter lower bound. |
| 837 *stack_lower = sp; | 845 *stack_lower = sp; |
| 838 } | 846 } |
| 839 #else | |
| 840 if (sp > *stack_lower) { | |
| 841 // The stack pointer gives us a tighter lower bound. | |
| 842 *stack_lower = sp; | |
| 843 } | |
| 844 #endif | |
| 845 | 847 |
| 846 if (*stack_lower >= *stack_upper) { | 848 if (*stack_lower >= *stack_upper) { |
| 847 // Stack boundary is invalid. | 849 // Stack boundary is invalid. |
| 848 return false; | 850 return false; |
| 849 } | 851 } |
| 850 | 852 |
| 851 if ((sp < *stack_lower) || (sp >= *stack_upper)) { | 853 if ((sp < *stack_lower) || (sp >= *stack_upper)) { |
| 852 // Stack pointer is outside thread's stack boundary. | 854 // Stack pointer is outside thread's stack boundary. |
| 853 return false; | 855 return false; |
| 854 } | 856 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 | 978 |
| 977 uword stack_lower = 0; | 979 uword stack_lower = 0; |
| 978 uword stack_upper = 0; | 980 uword stack_upper = 0; |
| 979 | 981 |
| 980 if (!InitialRegisterCheck(pc, fp, sp)) { | 982 if (!InitialRegisterCheck(pc, fp, sp)) { |
| 981 OS::PrintErr("Stack dump aborted because InitialRegisterCheck.\n"); | 983 OS::PrintErr("Stack dump aborted because InitialRegisterCheck.\n"); |
| 982 return; | 984 return; |
| 983 } | 985 } |
| 984 | 986 |
| 985 if (!GetAndValidateIsolateStackBounds(thread, fp, sp, &stack_lower, | 987 if (!GetAndValidateIsolateStackBounds(thread, fp, sp, &stack_lower, |
| 986 &stack_upper)) { | 988 &stack_upper, |
| 989 /*get_os_thread_bounds=*/true)) { | |
|
Cutch
2017/02/09 16:45:24
I wonder why this isn't the default now?
Vyacheslav Egorov (Google)
2017/02/09 17:19:20
Because it only works if thread == Thread::Current
| |
| 987 OS::PrintErr( | 990 OS::PrintErr( |
| 988 "Stack dump aborted because GetAndValidateIsolateStackBounds.\n"); | 991 "Stack dump aborted because GetAndValidateIsolateStackBounds.\n"); |
| 989 return; | 992 return; |
| 990 } | 993 } |
| 991 | 994 |
| 992 ProfilerNativeStackWalker native_stack_walker( | 995 ProfilerNativeStackWalker native_stack_walker( |
| 993 isolate, NULL, NULL, stack_lower, stack_upper, pc, fp, sp); | 996 isolate, NULL, NULL, stack_lower, stack_upper, pc, fp, sp); |
| 994 native_stack_walker.walk(); | 997 native_stack_walker.walk(); |
| 995 OS::PrintErr("-- End of DumpStackTrace\n"); | 998 OS::PrintErr("-- End of DumpStackTrace\n"); |
| 996 } | 999 } |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1513 | 1516 |
| 1514 | 1517 |
| 1515 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1518 ProcessedSampleBuffer::ProcessedSampleBuffer() |
| 1516 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1519 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
| 1517 ASSERT(code_lookup_table_ != NULL); | 1520 ASSERT(code_lookup_table_ != NULL); |
| 1518 } | 1521 } |
| 1519 | 1522 |
| 1520 #endif // !PRODUCT | 1523 #endif // !PRODUCT |
| 1521 | 1524 |
| 1522 } // namespace dart | 1525 } // namespace dart |
| OLD | NEW |