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