StackFrameUtils.cpp 612 B

12345678910111213141516171819202122
  1. /*
  2. * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "StackFrameUtils.h"
  7. namespace Debug::StackFrameUtils {
  8. Optional<StackFrameInfo> get_info(ProcessInspector const& inspector, FlatPtr current_ebp)
  9. {
  10. auto return_address = inspector.peek(reinterpret_cast<u32*>(current_ebp + sizeof(FlatPtr)));
  11. auto next_ebp = inspector.peek(reinterpret_cast<u32*>(current_ebp));
  12. if (!return_address.has_value() || !next_ebp.has_value())
  13. return {};
  14. StackFrameInfo info = { return_address.value(), next_ebp.value() };
  15. return info;
  16. }
  17. }