Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/Debugger/MemBlockInfo.h
3186 views
1
// Copyright (c) 2021- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include <cstdint>
21
#include <string>
22
#include <vector>
23
#include <cstring>
24
25
#include "Common/Common.h"
26
27
class PointerWrap;
28
29
static constexpr uint32_t MEMINFO_MIN_SIZE = 0x100;
30
31
enum class MemBlockFlags {
32
ALLOC = 0x0001,
33
SUB_ALLOC = 0x0002,
34
WRITE = 0x0004,
35
TEXTURE = 0x0008,
36
// Not actually logged.
37
READ = 0x0800,
38
FREE = 0x1000,
39
SUB_FREE = 0x2000,
40
41
SKIP_MEMCHECK = 0x00010000,
42
};
43
ENUM_CLASS_BITOPS(MemBlockFlags);
44
45
struct MemBlockInfo {
46
MemBlockFlags flags;
47
uint32_t start;
48
uint32_t size;
49
uint64_t ticks;
50
uint32_t pc;
51
std::string tag;
52
bool allocated;
53
};
54
55
void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const char *tag, size_t tagLength);
56
void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_t pc, const char *tag, size_t tagLength);
57
void NotifyMemInfoCopy(uint32_t destPtr, uint32_t srcPtr, uint32_t size, const char *prefix);
58
59
// This lets us avoid calling strlen on string constants, instead the string length (including null,
60
// so we have to subtract 1) is computed at compile time.
61
template<size_t count>
62
inline void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const char(&str)[count]) {
63
NotifyMemInfo(flags, start, size, str, count - 1);
64
}
65
66
inline void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const char *str) {
67
NotifyMemInfo(flags, start, size, str, strlen(str));
68
}
69
70
std::vector<MemBlockInfo> FindMemInfo(uint32_t start, uint32_t size);
71
std::vector<MemBlockInfo> FindMemInfoByFlag(MemBlockFlags flags, uint32_t start, uint32_t size);
72
73
size_t FormatMemWriteTagAt(char *buf, size_t sz, const char *prefix, uint32_t start, uint32_t size);
74
75
void MemBlockInfoInit();
76
void MemBlockInfoShutdown();
77
void MemBlockInfoDoState(PointerWrap &p);
78
79
void MemBlockOverrideDetailed();
80
void MemBlockReleaseDetailed();
81
bool MemBlockInfoDetailed();
82
83
static inline bool MemBlockInfoDetailed(uint32_t size) {
84
return size >= MEMINFO_MIN_SIZE || MemBlockInfoDetailed();
85
}
86
87
static inline bool MemBlockInfoDetailed(uint32_t size1, uint32_t size2) {
88
return size1 >= MEMINFO_MIN_SIZE || size2 >= MEMINFO_MIN_SIZE || MemBlockInfoDetailed();
89
}
90
91