2020-08-21 12:27:15 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-21 12:27:15 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "StackFrameUtils.h"
|
|
|
|
|
|
2020-08-25 04:33:07 +01:00
|
|
|
namespace Debug::StackFrameUtils {
|
|
|
|
|
|
2020-08-21 12:27:15 +03:00
|
|
|
Optional<StackFrameInfo> get_info(const DebugSession& session, FlatPtr current_ebp)
|
|
|
|
|
{
|
|
|
|
|
auto return_address = session.peek(reinterpret_cast<u32*>(current_ebp + sizeof(FlatPtr)));
|
|
|
|
|
auto next_ebp = session.peek(reinterpret_cast<u32*>(current_ebp));
|
|
|
|
|
if (!return_address.has_value() || !next_ebp.has_value())
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
StackFrameInfo info = { return_address.value(), next_ebp.value() };
|
|
|
|
|
return info;
|
|
|
|
|
}
|
2020-08-25 04:33:07 +01:00
|
|
|
|
2020-08-21 12:27:15 +03:00
|
|
|
}
|