Play-/Source/BiosDebugInfoProvider.h

120 lines
2.9 KiB
C
Raw Normal View History

2022-08-28 09:28:15 -04:00
#pragma once
#include <string>
#include <vector>
#include <map>
2022-09-06 20:06:48 -04:00
#include <variant>
#include "Types.h"
2022-11-02 11:03:45 -04:00
#include "maybe_unused.h"
struct BIOS_DEBUG_MODULE_INFO
{
2018-04-30 21:01:23 +01:00
std::string name;
uint32 begin;
uint32 end;
void* param;
};
typedef std::vector<BIOS_DEBUG_MODULE_INFO> BiosDebugModuleInfoArray;
typedef BiosDebugModuleInfoArray::iterator BiosDebugModuleInfoIterator;
typedef std::variant<uint32, std::string> BIOS_DEBUG_OBJECT_FIELD;
struct BIOS_DEBUG_OBJECT
{
std::vector<BIOS_DEBUG_OBJECT_FIELD> fields;
};
typedef std::vector<BIOS_DEBUG_OBJECT> BiosDebugObjectArray;
enum class BIOS_DEBUG_OBJECT_FIELD_TYPE
{
UNKNOWN,
UINT32,
STRING,
};
enum class BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE
{
2022-09-10 12:47:16 -04:00
NONE = 0,
IDENTIFIER = (1 << 0),
TEXT_ADDRESS = (1 << 1),
DATA_ADDRESS = (1 << 2),
HIDDEN = (1 << 3),
LOCATION = (1 << 4),
STACK_POINTER = (1 << 5),
RETURN_ADDRESS = (1 << 6),
2022-09-10 12:07:01 -04:00
POSSIBLE_STR_POINTER = (1 << 7)
};
2022-11-02 11:03:45 -04:00
FRAMEWORK_MAYBE_UNUSED
2022-09-10 12:47:16 -04:00
static BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE operator|(BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE lhs, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE rhs)
{
auto result = static_cast<uint32>(lhs) | (static_cast<uint32>(rhs));
return static_cast<BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE>(result);
}
enum class BIOS_DEBUG_OBJECT_ACTION
{
NONE,
SHOW_LOCATION,
SHOW_STACK_OR_LOCATION,
};
struct BIOS_DEBUG_OBJECT_FIELD_INFO
{
std::string name;
BIOS_DEBUG_OBJECT_FIELD_TYPE type = BIOS_DEBUG_OBJECT_FIELD_TYPE::UNKNOWN;
BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE attributes = BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::NONE;
2022-09-10 12:47:16 -04:00
bool HasAttribute(BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE attr) const
{
return (static_cast<uint32>(attributes) & static_cast<uint32>(attr)) != 0;
}
};
typedef std::vector<BIOS_DEBUG_OBJECT_FIELD_INFO> BiosDebugObjectFieldInfoArray;
struct BIOS_DEBUG_OBJECT_INFO
{
std::string name;
BiosDebugObjectFieldInfoArray fields;
BIOS_DEBUG_OBJECT_ACTION selectionAction = BIOS_DEBUG_OBJECT_ACTION::NONE;
2022-09-10 12:47:16 -04:00
int32 FindFieldWithAttribute(BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE attribute)
{
for(int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
{
const auto& field = fields[fieldIndex];
if(field.HasAttribute(attribute))
{
return fieldIndex;
}
}
return -1;
}
};
typedef std::map<uint32, BIOS_DEBUG_OBJECT_INFO> BiosDebugObjectInfoMap;
2022-09-08 19:17:13 -04:00
enum BIOS_DEBUG_OBJECT_TYPE
{
BIOS_DEBUG_OBJECT_TYPE_NULL,
BIOS_DEBUG_OBJECT_TYPE_THREAD,
BIOS_DEBUG_OBJECT_TYPE_CUSTOM_START,
};
class CBiosDebugInfoProvider
{
public:
2022-08-28 09:28:15 -04:00
~CBiosDebugInfoProvider() = default;
#ifdef DEBUGGER_INCLUDED
2018-04-30 21:01:23 +01:00
virtual BiosDebugModuleInfoArray GetModulesDebugInfo() const = 0;
virtual BiosDebugObjectInfoMap GetBiosObjectsDebugInfo() const
{
return BiosDebugObjectInfoMap();
}
virtual BiosDebugObjectArray GetBiosObjects(uint32 typeId) const
{
return BiosDebugObjectArray();
}
#endif
};