summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibDebug/StackFrameUtils.cpp
blob: aac6336644a2f0af5c844cb7aee25b9a7e5ad9d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include "StackFrameUtils.h"

namespace Debug::StackFrameUtils {

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;
}

}