get debugger onto new location info & symbol format

This commit is contained in:
Ryan Fleury
2026-04-20 09:57:33 -07:00
parent 6764e1281e
commit 881e19c842
29 changed files with 352 additions and 1653 deletions
+1 -10
View File
@@ -10,7 +10,7 @@
#ifndef RDI_C
#define RDI_C
RDI_U16 rdi_section_element_size_table[53] =
RDI_U16 rdi_section_element_size_table[44] =
{
sizeof(RDI_U8),
sizeof(RDI_TopLevelInfo),
@@ -35,17 +35,10 @@ sizeof(RDI_TypeNode),
sizeof(RDI_UDT),
sizeof(RDI_Member),
sizeof(RDI_EnumMember),
sizeof(RDI_GlobalVariable),
sizeof(RDI_ThreadVariable),
sizeof(RDI_Constant),
sizeof(RDI_Procedure),
sizeof(RDI_Local),
sizeof(RDI_Scope),
sizeof(RDI_U64),
sizeof(RDI_VMapEntry),
sizeof(RDI_InlineSite),
sizeof(RDI_LocationBlock),
sizeof(RDI_U8),
sizeof(RDI_Symbol),
sizeof(RDI_VMapEntry),
sizeof(RDI_Symbol),
@@ -55,8 +48,6 @@ sizeof(RDI_Symbol),
sizeof(RDI_U8),
sizeof(RDI_U8),
sizeof(RDI_LocationSetElement),
sizeof(RDI_U8),
sizeof(RDI_U32),
sizeof(RDI_MD5),
sizeof(RDI_SHA1),
sizeof(RDI_SHA256),
+24 -238
View File
@@ -67,7 +67,7 @@ union RDI_GUID {RDI_U8 u8[16]; RDI_U64 u64[2];};
// "raddbg\0\0"
#define RDI_MAGIC_CONSTANT 0x0000676264646172
#define RDI_ENCODING_VERSION 21
#define RDI_ENCODING_VERSION 22
////////////////////////////////////////////////////////////////
//~ Format Types & Functions
@@ -98,36 +98,27 @@ RDI_SectionKind_TypeNodes = 0x0013,
RDI_SectionKind_UDTs = 0x0014,
RDI_SectionKind_Members = 0x0015,
RDI_SectionKind_EnumMembers = 0x0016,
RDI_SectionKind_GlobalVariables = 0x0017,
RDI_SectionKind_ThreadVariables = 0x0018,
RDI_SectionKind_Constants = 0x0019,
RDI_SectionKind_Procedures = 0x001A,
RDI_SectionKind_Locals = 0x001B,
RDI_SectionKind_Scopes = 0x001C,
RDI_SectionKind_ScopeVOffData = 0x001D,
RDI_SectionKind_ScopeVMap = 0x001E,
RDI_SectionKind_InlineSites = 0x001F,
RDI_SectionKind_LocationBlocks = 0x0020,
RDI_SectionKind_LocationData = 0x0021,
RDI_SectionKind_GlobalVariableSymbols = 0x0022,
RDI_SectionKind_GlobalVMap = 0x0023,
RDI_SectionKind_ThreadVariableSymbols = 0x0024,
RDI_SectionKind_ConstantSymbols = 0x0025,
RDI_SectionKind_ProcedureSymbols = 0x0026,
RDI_SectionKind_LocalVariableSymbols = 0x0027,
RDI_SectionKind_LocationsBytecodeData = 0x0028,
RDI_SectionKind_LocationsConstantData = 0x0029,
RDI_SectionKind_LocationsSetElements = 0x002A,
RDI_SectionKind_ConstantValueData = 0x002B,
RDI_SectionKind_ConstantValueTable = 0x002C,
RDI_SectionKind_MD5Checksums = 0x002D,
RDI_SectionKind_SHA1Checksums = 0x002E,
RDI_SectionKind_SHA256Checksums = 0x002F,
RDI_SectionKind_Timestamps = 0x0030,
RDI_SectionKind_NameMaps = 0x0031,
RDI_SectionKind_NameMapBuckets = 0x0032,
RDI_SectionKind_NameMapNodes = 0x0033,
RDI_SectionKind_COUNT = 0x0034,
RDI_SectionKind_Scopes = 0x0017,
RDI_SectionKind_ScopeVOffData = 0x0018,
RDI_SectionKind_ScopeVMap = 0x0019,
RDI_SectionKind_InlineSites = 0x001A,
RDI_SectionKind_GlobalVariableSymbols = 0x001B,
RDI_SectionKind_GlobalVMap = 0x001C,
RDI_SectionKind_ThreadVariableSymbols = 0x001D,
RDI_SectionKind_ConstantSymbols = 0x001E,
RDI_SectionKind_ProcedureSymbols = 0x001F,
RDI_SectionKind_LocalVariableSymbols = 0x0020,
RDI_SectionKind_LocationsBytecodeData = 0x0021,
RDI_SectionKind_LocationsConstantData = 0x0022,
RDI_SectionKind_LocationsSetElements = 0x0023,
RDI_SectionKind_MD5Checksums = 0x0024,
RDI_SectionKind_SHA1Checksums = 0x0025,
RDI_SectionKind_SHA256Checksums = 0x0026,
RDI_SectionKind_Timestamps = 0x0027,
RDI_SectionKind_NameMaps = 0x0028,
RDI_SectionKind_NameMapBuckets = 0x0029,
RDI_SectionKind_NameMapNodes = 0x002A,
RDI_SectionKind_COUNT = 0x002B,
} RDI_SectionKindEnum;
typedef RDI_U32 RDI_SectionEncoding;
@@ -400,22 +391,6 @@ RDI_ContainerFlag_External = 1u<<7,
RDI_ContainerFlag_KindMask = 0x7f,
} RDI_ContainerFlagsEnum;
typedef RDI_U32 RDI_LinkFlags;
typedef enum RDI_LinkFlagsEnum
{
RDI_LinkFlag_External = 1<<0,
RDI_LinkFlag_TypeScoped = 1<<1,
RDI_LinkFlag_ProcScoped = 1<<2,
} RDI_LinkFlagsEnum;
typedef RDI_U32 RDI_LocalKind;
typedef enum RDI_LocalKindEnum
{
RDI_LocalKind_NULL = 0x0,
RDI_LocalKind_Parameter = 0x1,
RDI_LocalKind_Variable = 0x2,
} RDI_LocalKindEnum;
typedef RDI_U8 RDI_SymbolFlags;
typedef enum RDI_SymbolFlagsEnum
{
@@ -564,17 +539,10 @@ X(TypeNodes, type_nodes, RDI_TypeNode)\
X(UDTs, udts, RDI_UDT)\
X(Members, members, RDI_Member)\
X(EnumMembers, enum_members, RDI_EnumMember)\
X(GlobalVariables, global_variables, RDI_GlobalVariable)\
X(ThreadVariables, thread_variables, RDI_ThreadVariable)\
X(Constants, constants, RDI_Constant)\
X(Procedures, procedures, RDI_Procedure)\
X(Locals, locals, RDI_Local)\
X(Scopes, scopes, RDI_Scope)\
X(ScopeVOffData, scope_voff_data, RDI_U64)\
X(ScopeVMap, scope_vmap, RDI_VMapEntry)\
X(InlineSites, inline_sites, RDI_InlineSite)\
X(LocationBlocks, location_blocks, RDI_LocationBlock)\
X(LocationData, location_data, RDI_U8)\
X(GlobalVariableSymbols, global_variable_symbols, RDI_Symbol)\
X(GlobalVMap, global_vmap, RDI_VMapEntry)\
X(ThreadVariableSymbols, thread_variable_symbols, RDI_Symbol)\
@@ -584,8 +552,6 @@ X(LocalVariableSymbols, local_variable_symbols, RDI_Symbol)\
X(LocationsBytecodeData, locations_bytecode_data, RDI_U8)\
X(LocationsConstantData, locations_constant_data, RDI_U8)\
X(LocationsSetElements, locations_set_elements, RDI_LocationSetElement)\
X(ConstantValueData, constant_value_data, RDI_U8)\
X(ConstantValueTable, constant_value_table, RDI_U32)\
X(MD5Checksums, md5_checksums, RDI_MD5)\
X(SHA1Checksums, sha1_checksums, RDI_SHA1)\
X(SHA256Checksums, sha256_checksums, RDI_SHA256)\
@@ -913,14 +879,7 @@ X(RDI_U32, pad)\
X(RDI_U64, val)\
#define RDI_LinkFlags_XList \
X(External)\
X(TypeScoped)\
X(ProcScoped)\
#define RDI_LocalKind_XList \
X(NULL)\
X(Parameter)\
X(Variable)\
X($(a.name != COUNT -> a.name))\
#define RDI_LocationKind_XList \
X(NULL)\
@@ -950,30 +909,6 @@ X(RDI_U32, type_idx)\
X(RDI_U32, root_scope_idx)\
X(RDI_U32, link_name_string_idx)\
#define RDI_GlobalVariable_XList \
X(RDI_U32, name_string_idx)\
X(RDI_LinkFlags, link_flags)\
X(RDI_U64, voff)\
X(RDI_U32, type_idx)\
X(RDI_U32, container_idx)\
#define RDI_ThreadVariable_XList \
X(type, name_string_idx)\
X(type, link_flags)\
X(type, tls_off)\
X(type, type_idx)\
X(type, container_idx)\
#define RDI_Procedure_XList \
X(RDI_U32, name_string_idx)\
X(RDI_U32, link_name_string_idx)\
X(RDI_LinkFlags, link_flags)\
X(RDI_U32, type_idx)\
X(RDI_U32, root_scope_idx)\
X(RDI_U32, container_idx)\
X(RDI_U32, frame_base_location_first)\
X(RDI_U32, frame_base_location_opl)\
#define RDI_Scope_XList \
X(RDI_U32, proc_idx)\
X(RDI_U32, parent_scope_idx)\
@@ -991,40 +926,6 @@ X(RDI_U32, type_idx)\
X(RDI_U32, owner_type_idx)\
X(RDI_U32, line_table_idx)\
#define RDI_Local_XList \
X(RDI_LocalKind, kind)\
X(RDI_U32, name_string_idx)\
X(RDI_U32, type_idx)\
X(RDI_U32, pad)\
X(RDI_U32, location_first)\
X(RDI_U32, location_opl)\
#define RDI_LocationBlock_XList \
X(RDI_U32, scope_off_first)\
X(RDI_U32, scope_off_opl)\
X(RDI_U32, location_data_off)\
#define RDI_LocationBytecodeStream_XList \
X(RDI_LocationKind, kind)\
#define RDI_LocationRegPlusU16_XList \
X(RDI_LocationKind, kind)\
X(RDI_RegCode, reg_code)\
X(RDI_U16, offset)\
#define RDI_LocationReg_XList \
X(RDI_LocationKind, kind)\
X(RDI_RegCode, reg_code)\
#define RDI_RegAndOffsetU16_XList \
X(RDI_RegCode, reg_code)\
X(RDI_U16, offset)\
#define RDI_LocationSetElement_XList \
X(RDI_U64, voff_first)\
X(RDI_U64, voff_opl)\
X(RDI_Location, location)\
#define RDI_EvalOp_XList \
X(Stop)\
X(Noop)\
@@ -1141,16 +1042,9 @@ typedef struct RDI_U32_TypeNodes { RDI_U32 v; } RDI_U32_TypeNo
typedef struct RDI_U32_UDTs { RDI_U32 v; } RDI_U32_UDTs;
typedef struct RDI_U32_Members { RDI_U32 v; } RDI_U32_Members;
typedef struct RDI_U32_EnumMembers { RDI_U32 v; } RDI_U32_EnumMembers;
typedef struct RDI_U32_GlobalVariables { RDI_U32 v; } RDI_U32_GlobalVariables;
typedef struct RDI_U32_ThreadVariables { RDI_U32 v; } RDI_U32_ThreadVariables;
typedef struct RDI_U32_Constants { RDI_U32 v; } RDI_U32_Constants;
typedef struct RDI_U32_Procedures { RDI_U32 v; } RDI_U32_Procedures;
typedef struct RDI_U32_Locals { RDI_U32 v; } RDI_U32_Locals;
typedef struct RDI_U32_Scopes { RDI_U32 v; } RDI_U32_Scopes;
typedef struct RDI_U32_ScopeVOffData { RDI_U32 v; } RDI_U32_ScopeVOffData;
typedef struct RDI_U32_InlineSites { RDI_U32 v; } RDI_U32_InlineSites;
typedef struct RDI_U32_LocationBlocks { RDI_U32 v; } RDI_U32_LocationBlocks;
typedef struct RDI_U32_LocationData { RDI_U32 v; } RDI_U32_LocationData;
typedef struct RDI_U32_GlobalVariableSymbols { RDI_U32 v; } RDI_U32_GlobalVariableSymbols;
typedef struct RDI_U32_ThreadVariableSymbols { RDI_U32 v; } RDI_U32_ThreadVariableSymbols;
typedef struct RDI_U32_ConstantSymbols { RDI_U32 v; } RDI_U32_ConstantSymbols;
@@ -1159,8 +1053,6 @@ typedef struct RDI_U32_LocalVariableSymbols { RDI_U32 v; } RDI_U32_LocalV
typedef struct RDI_U32_LocationsBytecodeData { RDI_U32 v; } RDI_U32_LocationsBytecodeData;
typedef struct RDI_U32_LocationsConstantData { RDI_U32 v; } RDI_U32_LocationsConstantData;
typedef struct RDI_U32_LocationsSetElements { RDI_U32 v; } RDI_U32_LocationsSetElements;
typedef struct RDI_U32_ConstantValueData { RDI_U32 v; } RDI_U32_ConstantValueData;
typedef struct RDI_U32_ConstantValueTable { RDI_U32 v; } RDI_U32_ConstantValueTable;
typedef struct RDI_U32_MD5Checksums { RDI_U32 v; } RDI_U32_MD5Checksums;
typedef struct RDI_U32_SHA1Checksums { RDI_U32 v; } RDI_U32_SHA1Checksums;
typedef struct RDI_U32_SHA256Checksums { RDI_U32 v; } RDI_U32_SHA256Checksums;
@@ -1190,16 +1082,9 @@ typedef RDI_U32_Table RDI_U32_TypeNodes;
typedef RDI_U32_Table RDI_U32_UDTs;
typedef RDI_U32_Table RDI_U32_Members;
typedef RDI_U32_Table RDI_U32_EnumMembers;
typedef RDI_U32_Table RDI_U32_GlobalVariables;
typedef RDI_U32_Table RDI_U32_ThreadVariables;
typedef RDI_U32_Table RDI_U32_Constants;
typedef RDI_U32_Table RDI_U32_Procedures;
typedef RDI_U32_Table RDI_U32_Locals;
typedef RDI_U32_Table RDI_U32_Scopes;
typedef RDI_U32_Table RDI_U32_ScopeVOffData;
typedef RDI_U32_Table RDI_U32_InlineSites;
typedef RDI_U32_Table RDI_U32_LocationBlocks;
typedef RDI_U32_Table RDI_U32_LocationData;
typedef RDI_U32_Table RDI_U32_GlobalVariableSymbols;
typedef RDI_U32_Table RDI_U32_ThreadVariableSymbols;
typedef RDI_U32_Table RDI_U32_ConstantSymbols;
@@ -1208,8 +1093,6 @@ typedef RDI_U32_Table RDI_U32_LocalVariableSymbols;
typedef RDI_U32_Table RDI_U32_LocationsBytecodeData;
typedef RDI_U32_Table RDI_U32_LocationsConstantData;
typedef RDI_U32_Table RDI_U32_LocationsSetElements;
typedef RDI_U32_Table RDI_U32_ConstantValueData;
typedef RDI_U32_Table RDI_U32_ConstantValueTable;
typedef RDI_U32_Table RDI_U32_MD5Checksums;
typedef RDI_U32_Table RDI_U32_SHA1Checksums;
typedef RDI_U32_Table RDI_U32_SHA256Checksums;
@@ -1481,47 +1364,6 @@ RDI_U32 root_scope_idx;
RDI_U32 link_name_string_idx;
};
typedef struct RDI_GlobalVariable RDI_GlobalVariable;
struct RDI_GlobalVariable
{
RDI_U32 name_string_idx;
RDI_LinkFlags link_flags;
RDI_U64 voff;
RDI_U32 type_idx;
RDI_U32 container_idx;
};
typedef struct RDI_ThreadVariable RDI_ThreadVariable;
struct RDI_ThreadVariable
{
RDI_U32 name_string_idx;
RDI_LinkFlags link_flags;
RDI_U32 tls_off;
RDI_U32 type_idx;
RDI_U32 container_idx;
};
typedef struct RDI_Constant RDI_Constant;
struct RDI_Constant
{
RDI_U32 name_string_idx;
RDI_U32 type_idx;
RDI_U32 constant_value_idx;
};
typedef struct RDI_Procedure RDI_Procedure;
struct RDI_Procedure
{
RDI_U32 name_string_idx;
RDI_U32 link_name_string_idx;
RDI_LinkFlags link_flags;
RDI_U32 type_idx;
RDI_U32 root_scope_idx;
RDI_U32 container_idx;
RDI_U32 frame_base_location_first;
RDI_U32 frame_base_location_opl;
};
typedef struct RDI_Scope RDI_Scope;
struct RDI_Scope
{
@@ -1545,53 +1387,6 @@ RDI_U32 owner_type_idx;
RDI_U32 line_table_idx;
};
typedef struct RDI_Local RDI_Local;
struct RDI_Local
{
RDI_LocalKind kind;
RDI_U32 name_string_idx;
RDI_U32 type_idx;
RDI_U32 pad;
RDI_U32 location_first;
RDI_U32 location_opl;
};
typedef struct RDI_LocationBlock RDI_LocationBlock;
struct RDI_LocationBlock
{
RDI_U32 scope_off_first;
RDI_U32 scope_off_opl;
RDI_U32 location_data_off;
};
typedef struct RDI_LocationBytecodeStream RDI_LocationBytecodeStream;
struct RDI_LocationBytecodeStream
{
RDI_LocationKind kind;
};
typedef struct RDI_LocationRegPlusU16 RDI_LocationRegPlusU16;
struct RDI_LocationRegPlusU16
{
RDI_LocationKind kind;
RDI_RegCode reg_code;
RDI_U16 offset;
};
typedef struct RDI_LocationReg RDI_LocationReg;
struct RDI_LocationReg
{
RDI_LocationKind kind;
RDI_RegCode reg_code;
};
typedef struct RDI_RegAndOffsetU16 RDI_RegAndOffsetU16;
struct RDI_RegAndOffsetU16
{
RDI_RegCode reg_code;
RDI_U16 offset;
};
typedef struct RDI_LocationSetElement RDI_LocationSetElement;
struct RDI_LocationSetElement
{
@@ -1646,17 +1441,10 @@ typedef RDI_TypeNode RDI_SectionElementType_TypeNodes;
typedef RDI_UDT RDI_SectionElementType_UDTs;
typedef RDI_Member RDI_SectionElementType_Members;
typedef RDI_EnumMember RDI_SectionElementType_EnumMembers;
typedef RDI_GlobalVariable RDI_SectionElementType_GlobalVariables;
typedef RDI_ThreadVariable RDI_SectionElementType_ThreadVariables;
typedef RDI_Constant RDI_SectionElementType_Constants;
typedef RDI_Procedure RDI_SectionElementType_Procedures;
typedef RDI_Local RDI_SectionElementType_Locals;
typedef RDI_Scope RDI_SectionElementType_Scopes;
typedef RDI_U64 RDI_SectionElementType_ScopeVOffData;
typedef RDI_VMapEntry RDI_SectionElementType_ScopeVMap;
typedef RDI_InlineSite RDI_SectionElementType_InlineSites;
typedef RDI_LocationBlock RDI_SectionElementType_LocationBlocks;
typedef RDI_U8 RDI_SectionElementType_LocationData;
typedef RDI_Symbol RDI_SectionElementType_GlobalVariableSymbols;
typedef RDI_VMapEntry RDI_SectionElementType_GlobalVMap;
typedef RDI_Symbol RDI_SectionElementType_ThreadVariableSymbols;
@@ -1666,8 +1454,6 @@ typedef RDI_Symbol RDI_SectionElementType_LocalVariableSym
typedef RDI_U8 RDI_SectionElementType_LocationsBytecodeData;
typedef RDI_U8 RDI_SectionElementType_LocationsConstantData;
typedef RDI_LocationSetElement RDI_SectionElementType_LocationsSetElements;
typedef RDI_U8 RDI_SectionElementType_ConstantValueData;
typedef RDI_U32 RDI_SectionElementType_ConstantValueTable;
typedef RDI_MD5 RDI_SectionElementType_MD5Checksums;
typedef RDI_SHA1 RDI_SectionElementType_SHA1Checksums;
typedef RDI_SHA256 RDI_SectionElementType_SHA256Checksums;
@@ -1684,7 +1470,7 @@ RDI_PROC RDI_EvalConversionKind rdi_eval_conversion_kind_from_typegroups(RDI_Eva
RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTypeGroup group);
RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out);
extern RDI_U16 rdi_section_element_size_table[53];
extern RDI_U16 rdi_section_element_size_table[44];
extern RDI_U16 rdi_eval_op_ctrlbits_table[54];
#endif // RDI_H
+56 -21
View File
@@ -728,7 +728,7 @@ rdi_matches_from_map_node(RDI_Parsed *p, RDI_NameMapNode *node, RDI_U32 *n_out)
//- procedures
RDI_PROC RDI_Procedure *
RDI_PROC RDI_Symbol *
rdi_procedure_from_name(RDI_Parsed *rdi, RDI_U8 *name, RDI_U64 name_size)
{
RDI_NameMap *map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Procedures);
@@ -742,35 +742,35 @@ rdi_procedure_from_name(RDI_Parsed *rdi, RDI_U8 *name, RDI_U64 name_size)
{
procedure_idx = ids[0];
}
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, procedure_idx);
RDI_Symbol *procedure = rdi_element_from_name_idx(rdi, ProcedureSymbols, procedure_idx);
return procedure;
}
RDI_PROC RDI_Procedure *
RDI_PROC RDI_Symbol *
rdi_procedure_from_name_cstr(RDI_Parsed *rdi, char *cstr)
{
RDI_Procedure *result = rdi_procedure_from_name(rdi, (RDI_U8 *)cstr, rdi_cstring_length(cstr));
RDI_Symbol *result = rdi_procedure_from_name(rdi, (RDI_U8 *)cstr, rdi_cstring_length(cstr));
return result;
}
RDI_PROC RDI_U8 *
rdi_name_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure, RDI_U64 *len_out)
rdi_name_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure, RDI_U64 *len_out)
{
return rdi_string_from_idx(rdi, procedure->name_string_idx, len_out);
}
RDI_PROC RDI_Scope *
rdi_root_scope_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure)
rdi_root_scope_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure)
{
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
return scope;
}
RDI_PROC RDI_UDT *
rdi_container_udt_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure)
rdi_container_udt_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure)
{
RDI_U64 idx = 0;
if(procedure->link_flags & RDI_LinkFlag_TypeScoped)
if(procedure->container_flags & RDI_ContainerFlag_KindMask == RDI_ContainerKind_Type)
{
idx = procedure->container_idx;
}
@@ -778,20 +778,20 @@ rdi_container_udt_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure)
return udt;
}
RDI_PROC RDI_Procedure *
rdi_container_procedure_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure)
RDI_PROC RDI_Scope *
rdi_container_scope_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure)
{
RDI_U64 idx = 0;
if(procedure->link_flags & RDI_LinkFlag_ProcScoped)
if(procedure->container_flags & RDI_ContainerFlag_KindMask == RDI_ContainerKind_Scope)
{
idx = procedure->container_idx;
}
RDI_Procedure *container_procedure = rdi_element_from_name_idx(rdi, Procedures, idx);
return container_procedure;
RDI_Scope *container_scope = rdi_element_from_name_idx(rdi, Scopes, idx);
return container_scope;
}
RDI_PROC RDI_U64
rdi_first_voff_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure)
rdi_first_voff_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure)
{
RDI_Scope *scope = rdi_root_scope_from_procedure(rdi, procedure);
RDI_U64 result = rdi_first_voff_from_scope(rdi, scope);
@@ -799,18 +799,18 @@ rdi_first_voff_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure)
}
RDI_PROC RDI_U64
rdi_opl_voff_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure)
rdi_opl_voff_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure)
{
RDI_Scope *scope = rdi_root_scope_from_procedure(rdi, procedure);
RDI_U64 result = rdi_opl_voff_from_scope(rdi, scope);
return result;
}
RDI_PROC RDI_Procedure *
RDI_PROC RDI_Symbol *
rdi_procedure_from_voff(RDI_Parsed *rdi, RDI_U64 voff)
{
RDI_Scope *scope = rdi_scope_from_voff(rdi, voff);
RDI_Procedure *procedure = rdi_procedure_from_scope(rdi, scope);
RDI_Symbol *procedure = rdi_procedure_from_scope(rdi, scope);
return procedure;
}
@@ -851,10 +851,10 @@ rdi_parent_from_scope(RDI_Parsed *rdi, RDI_Scope *scope)
return parent;
}
RDI_PROC RDI_Procedure *
RDI_PROC RDI_Symbol *
rdi_procedure_from_scope(RDI_Parsed *rdi, RDI_Scope *scope)
{
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, scope->proc_idx);
RDI_Symbol *procedure = rdi_element_from_name_idx(rdi, ProcedureSymbols, scope->proc_idx);
return procedure;
}
@@ -867,14 +867,49 @@ rdi_inline_site_from_scope(RDI_Parsed *rdi, RDI_Scope *scope)
//- global variables
RDI_PROC RDI_GlobalVariable *
RDI_PROC RDI_Symbol *
rdi_global_variable_from_voff(RDI_Parsed *rdi, RDI_U64 voff)
{
RDI_U32 idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_GlobalVMap, voff);
RDI_GlobalVariable *gvar = rdi_element_from_name_idx(rdi, GlobalVariables, idx);
RDI_Symbol *gvar = rdi_element_from_name_idx(rdi, GlobalVariableSymbols, idx);
return gvar;
}
//- location picking
RDI_PROC RDI_Location
rdi_location_from_location_voff(RDI_Parsed *rdi, RDI_Location location, RDI_U64 voff)
{
RDI_Location result = 0;
if(rdi_kind_from_location(location) != RDI_LocationKind_Set)
{
result = location;
}
else
{
RDI_U64 set_first_idx = rdi_set_first_index_from_location(location);
RDI_U64 set_count = rdi_set_count_from_location(location);
RDI_U64 set_opl_idx = set_first_idx + set_count;
RDI_U64 all_elems_count = 0;
RDI_LocationSetElement *all_elems = rdi_table_from_name(rdi, LocationsSetElements, &all_elems_count);
if(set_opl_idx > all_elems_count)
{
set_opl_idx = all_elems_count;
}
RDI_LocationSetElement *set_first = all_elems + set_first_idx;
RDI_LocationSetElement *set_opl = all_elems + set_opl_idx;
for(RDI_LocationSetElement *e = set_first; e < set_opl; e += 1)
{
if(e->voff_first <= voff && voff <= e->voff_opl)
{
result = e->location;
break;
}
}
}
return result;
}
//- units
RDI_PROC RDI_Unit *
+16 -16
View File
@@ -122,13 +122,10 @@ static union
RDI_UDT udt;
RDI_Member member;
RDI_EnumMember enum_member;
RDI_GlobalVariable global_variable;
RDI_ThreadVariable thread_variable;
RDI_Procedure procedure;
RDI_Symbol symbol;
RDI_Scope scope;
RDI_U64 voff;
RDI_LocationBlock location_block;
RDI_Local local;
RDI_LocationSetElement location_set_element;
}
rdi_nil_element_union = {0};
static RDI_Parsed rdi_parsed_nil = {0};
@@ -179,26 +176,29 @@ RDI_PROC RDI_U32 *rdi_matches_from_map_node(RDI_Parsed *p, RDI_NameMapNode *node
//~ High-Level Composite Lookup Functions
//- procedures
RDI_PROC RDI_Procedure *rdi_procedure_from_name(RDI_Parsed *rdi, RDI_U8 *name, RDI_U64 name_size);
RDI_PROC RDI_Procedure *rdi_procedure_from_name_cstr(RDI_Parsed *rdi, char *cstr);
RDI_PROC RDI_U8 *rdi_name_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure, RDI_U64 *len_out);
RDI_PROC RDI_Scope *rdi_root_scope_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure);
RDI_PROC RDI_UDT *rdi_container_udt_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure);
RDI_PROC RDI_Procedure *rdi_container_procedure_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure);
RDI_PROC RDI_U64 rdi_first_voff_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure);
RDI_PROC RDI_U64 rdi_opl_voff_from_procedure(RDI_Parsed *rdi, RDI_Procedure *procedure);
RDI_PROC RDI_Procedure *rdi_procedure_from_voff(RDI_Parsed *rdi, RDI_U64 voff);
RDI_PROC RDI_Symbol *rdi_procedure_from_name(RDI_Parsed *rdi, RDI_U8 *name, RDI_U64 name_size);
RDI_PROC RDI_Symbol *rdi_procedure_from_name_cstr(RDI_Parsed *rdi, char *cstr);
RDI_PROC RDI_U8 *rdi_name_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure, RDI_U64 *len_out);
RDI_PROC RDI_Scope *rdi_root_scope_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure);
RDI_PROC RDI_UDT *rdi_container_udt_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure);
RDI_PROC RDI_Scope *rdi_container_scope_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure);
RDI_PROC RDI_U64 rdi_first_voff_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure);
RDI_PROC RDI_U64 rdi_opl_voff_from_procedure(RDI_Parsed *rdi, RDI_Symbol *procedure);
RDI_PROC RDI_Symbol *rdi_procedure_from_voff(RDI_Parsed *rdi, RDI_U64 voff);
//- scopes
RDI_PROC RDI_U64 rdi_first_voff_from_scope(RDI_Parsed *rdi, RDI_Scope *scope);
RDI_PROC RDI_U64 rdi_opl_voff_from_scope(RDI_Parsed *rdi, RDI_Scope *scope);
RDI_PROC RDI_Scope *rdi_scope_from_voff(RDI_Parsed *rdi, RDI_U64 voff);
RDI_PROC RDI_Scope *rdi_parent_from_scope(RDI_Parsed *rdi, RDI_Scope *scope);
RDI_PROC RDI_Procedure *rdi_procedure_from_scope(RDI_Parsed *rdi, RDI_Scope *scope);
RDI_PROC RDI_Symbol *rdi_procedure_from_scope(RDI_Parsed *rdi, RDI_Scope *scope);
RDI_PROC RDI_InlineSite *rdi_inline_site_from_scope(RDI_Parsed *rdi, RDI_Scope *scope);
//- global variables
RDI_PROC RDI_GlobalVariable *rdi_global_variable_from_voff(RDI_Parsed *rdi, RDI_U64 voff);
RDI_PROC RDI_Symbol *rdi_global_variable_from_voff(RDI_Parsed *rdi, RDI_U64 voff);
//- location picking
RDI_PROC RDI_Location rdi_location_from_location_voff(RDI_Parsed *rdi, RDI_Location location, RDI_U64 voff);
//- units
RDI_PROC RDI_Unit *rdi_unit_from_voff(RDI_Parsed *rdi, RDI_U64 voff);