chrome_unwinder_android.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 "base/profiler/unwinder.h"
  7. #include "base/base_export.h"
  8. #include "base/optional.h"
  9. #include "base/profiler/arm_cfi_table.h"
  10. #include "base/profiler/module_cache.h"
  11. #include "base/profiler/register_context.h"
  12. namespace base {
  13. // Chrome unwinder implementation for Android, using ArmCfiTable.
  14. class BASE_EXPORT ChromeUnwinderAndroid : public Unwinder {
  15. public:
  16. ChromeUnwinderAndroid(const ArmCFITable* cfi_table,
  17. uintptr_t chrome_module_base_address);
  18. ~ChromeUnwinderAndroid() override;
  19. ChromeUnwinderAndroid(const ChromeUnwinderAndroid&) = delete;
  20. ChromeUnwinderAndroid& operator=(const ChromeUnwinderAndroid&) = delete;
  21. // Unwinder:
  22. bool CanUnwindFrom(const Frame& current_frame) const override;
  23. UnwindResult TryUnwind(RegisterContext* thread_context,
  24. uintptr_t stack_top,
  25. ModuleCache* module_cache,
  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. const ArmCFITable* cfi_table_;
  40. const uintptr_t chrome_module_base_address_;
  41. };
  42. } // namespace base
  43. #endif // BASE_PROFILER_CHROME_UNWINDER_ANDROID_H_