summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibDebug/Dwarf/AddressRanges.h
blob: 7849b9778db4df3dc896e596cebcc778e7918a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright (c) 2020-2021, Itamar S. <itamar8910@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "CompilationUnit.h"
#include <AK/Forward.h>
#include <AK/Function.h>
#include <AK/Noncopyable.h>
#include <LibCore/Stream.h>

namespace Debug::Dwarf {

struct Range {
    FlatPtr start { 0 };
    FlatPtr end { 0 };
};

class AddressRangesV5 {
    AK_MAKE_NONCOPYABLE(AddressRangesV5);
    AK_MAKE_NONMOVABLE(AddressRangesV5);

public:
    // FIXME: This should be fine with using a non-owned stream.
    AddressRangesV5(NonnullOwnPtr<AK::Stream> range_lists_stream, CompilationUnit const& compilation_unit);

    ErrorOr<void> for_each_range(Function<void(Range)>);

private:
    NonnullOwnPtr<AK::Stream> m_range_lists_stream;
    CompilationUnit const& m_compilation_unit;
};

class AddressRangesV4 {
    AK_MAKE_NONCOPYABLE(AddressRangesV4);
    AK_MAKE_NONMOVABLE(AddressRangesV4);

public:
    AddressRangesV4(NonnullOwnPtr<AK::Stream> ranges_stream, CompilationUnit const&);

    ErrorOr<void> for_each_range(Function<void(Range)>);

private:
    NonnullOwnPtr<AK::Stream> m_ranges_stream;
    CompilationUnit const& m_compilation_unit;
};

}