chrome_unwinder_android.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_PROFILER_CHROME_UNWINDER_ANDROID_H_
  5. #define BASE_PROFILER_CHROME_UNWINDER_ANDROID_H_
  6. #include <vector>
  7. #include "base/memory/raw_ptr.h"
  8. #include "base/profiler/unwinder.h"
  9. #include "base/base_export.h"
  10. #include "base/profiler/arm_cfi_table.h"
  11. #include "base/profiler/module_cache.h"
  12. #include "base/profiler/register_context.h"
  13. namespace base {
  14. // Chrome unwinder implementation for Android, using ArmCfiTable.
  15. class BASE_EXPORT ChromeUnwinderAndroid : public Unwinder {
  16. public:
  17. ChromeUnwinderAndroid(const ArmCFITable* cfi_table,
  18. uintptr_t chrome_module_base_address);
  19. ~ChromeUnwinderAndroid() override;
  20. ChromeUnwinderAndroid(const ChromeUnwinderAndroid&) = delete;
  21. ChromeUnwinderAndroid& operator=(const ChromeUnwinderAndroid&) = delete;
  22. // Unwinder:
  23. bool CanUnwindFrom(const Frame& current_frame) const override;
  24. UnwindResult TryUnwind(RegisterContext* thread_context,
  25. uintptr_t stack_top,
  26. std::vector<Frame>* stack) const override;
  27. static bool StepForTesting(RegisterContext* thread_context,
  28. uintptr_t stack_top,
  29. const ArmCFITable::FrameEntry& entry) {
  30. return Step(thread_context, stack_top, entry);
  31. }
  32. private:
  33. static bool Step(RegisterContext* thread_context,
  34. uintptr_t stack_top,
  35. const ArmCFITable::FrameEntry& entry);
  36. // Fallback setp that attempts to use lr as return address.
  37. static bool StepUsingLrRegister(RegisterContext* thread_context,
  38. uintptr_t stack_top);
  39. raw_ptr<const ArmCFITable> cfi_table_;
  40. const uintptr_t chrome_module_base_address_;
  41. };
  42. } // namespace base
  43. #endif // BASE_PROFILER_CHROME_UNWINDER_ANDROID_H_