mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-23 12:15:00 -07:00
initial upload
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- GENERATED CODE
|
||||
|
||||
#ifndef TYPE_GRAPH_META_H
|
||||
#define TYPE_GRAPH_META_H
|
||||
|
||||
typedef enum TG_Kind
|
||||
{
|
||||
TG_Kind_Null,
|
||||
TG_Kind_Void,
|
||||
TG_Kind_Handle,
|
||||
TG_Kind_Char8,
|
||||
TG_Kind_Char16,
|
||||
TG_Kind_Char32,
|
||||
TG_Kind_UChar8,
|
||||
TG_Kind_UChar16,
|
||||
TG_Kind_UChar32,
|
||||
TG_Kind_U8,
|
||||
TG_Kind_U16,
|
||||
TG_Kind_U32,
|
||||
TG_Kind_U64,
|
||||
TG_Kind_U128,
|
||||
TG_Kind_U256,
|
||||
TG_Kind_U512,
|
||||
TG_Kind_S8,
|
||||
TG_Kind_S16,
|
||||
TG_Kind_S32,
|
||||
TG_Kind_S64,
|
||||
TG_Kind_S128,
|
||||
TG_Kind_S256,
|
||||
TG_Kind_S512,
|
||||
TG_Kind_Bool,
|
||||
TG_Kind_F16,
|
||||
TG_Kind_F32,
|
||||
TG_Kind_F32PP,
|
||||
TG_Kind_F48,
|
||||
TG_Kind_F64,
|
||||
TG_Kind_F80,
|
||||
TG_Kind_F128,
|
||||
TG_Kind_ComplexF32,
|
||||
TG_Kind_ComplexF64,
|
||||
TG_Kind_ComplexF80,
|
||||
TG_Kind_ComplexF128,
|
||||
TG_Kind_Modifier,
|
||||
TG_Kind_Ptr,
|
||||
TG_Kind_LRef,
|
||||
TG_Kind_RRef,
|
||||
TG_Kind_Array,
|
||||
TG_Kind_Function,
|
||||
TG_Kind_Method,
|
||||
TG_Kind_MemberPtr,
|
||||
TG_Kind_Struct,
|
||||
TG_Kind_Class,
|
||||
TG_Kind_Union,
|
||||
TG_Kind_Enum,
|
||||
TG_Kind_Alias,
|
||||
TG_Kind_IncompleteStruct,
|
||||
TG_Kind_IncompleteUnion,
|
||||
TG_Kind_IncompleteClass,
|
||||
TG_Kind_IncompleteEnum,
|
||||
TG_Kind_Bitfield,
|
||||
TG_Kind_Variadic,
|
||||
TG_Kind_COUNT,
|
||||
TG_Kind_FirstBasic = TG_Kind_Void,
|
||||
TG_Kind_LastBasic = TG_Kind_ComplexF128,
|
||||
TG_Kind_FirstInteger = TG_Kind_Char8,
|
||||
TG_Kind_LastInteger = TG_Kind_S512,
|
||||
TG_Kind_FirstSigned1 = TG_Kind_Char8,
|
||||
TG_Kind_LastSigned1 = TG_Kind_Char32,
|
||||
TG_Kind_FirstSigned2 = TG_Kind_S8,
|
||||
TG_Kind_LastSigned2 = TG_Kind_S512,
|
||||
TG_Kind_FirstIncomplete = TG_Kind_IncompleteStruct,
|
||||
TG_Kind_LastIncomplete = TG_Kind_IncompleteEnum,
|
||||
} TG_Kind;
|
||||
|
||||
U8 tg_kind_basic_byte_size_table[] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0xFF,
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16,
|
||||
32,
|
||||
64,
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
8,
|
||||
16,
|
||||
32,
|
||||
64,
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
4,
|
||||
6,
|
||||
8,
|
||||
10,
|
||||
16,
|
||||
8,
|
||||
16,
|
||||
20,
|
||||
32,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
String8 tg_kind_basic_string_table[] =
|
||||
{
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp("void"),
|
||||
str8_lit_comp("HANDLE"),
|
||||
str8_lit_comp("char8"),
|
||||
str8_lit_comp("char16"),
|
||||
str8_lit_comp("char32"),
|
||||
str8_lit_comp("uchar8"),
|
||||
str8_lit_comp("uchar16"),
|
||||
str8_lit_comp("uchar32"),
|
||||
str8_lit_comp("U8"),
|
||||
str8_lit_comp("U16"),
|
||||
str8_lit_comp("U32"),
|
||||
str8_lit_comp("U64"),
|
||||
str8_lit_comp("U128"),
|
||||
str8_lit_comp("U256"),
|
||||
str8_lit_comp("U512"),
|
||||
str8_lit_comp("S8"),
|
||||
str8_lit_comp("S16"),
|
||||
str8_lit_comp("S32"),
|
||||
str8_lit_comp("S64"),
|
||||
str8_lit_comp("S128"),
|
||||
str8_lit_comp("S256"),
|
||||
str8_lit_comp("S512"),
|
||||
str8_lit_comp("bool"),
|
||||
str8_lit_comp("F16"),
|
||||
str8_lit_comp("F32"),
|
||||
str8_lit_comp("F32PP"),
|
||||
str8_lit_comp("F48"),
|
||||
str8_lit_comp("F64"),
|
||||
str8_lit_comp("F80"),
|
||||
str8_lit_comp("F128"),
|
||||
str8_lit_comp("ComplexF32"),
|
||||
str8_lit_comp("ComplexF64"),
|
||||
str8_lit_comp("ComplexF80"),
|
||||
str8_lit_comp("ComplexF128"),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp(""),
|
||||
};
|
||||
|
||||
|
||||
#endif // TYPE_GRAPH_META_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,221 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef TYPE_GRAPH_NEW_H
|
||||
#define TYPE_GRAPH_NEW_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/type_graph.meta.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Key Types
|
||||
|
||||
typedef enum TG_KeyKind
|
||||
{
|
||||
TG_KeyKind_Null,
|
||||
TG_KeyKind_Basic,
|
||||
TG_KeyKind_Ext,
|
||||
TG_KeyKind_Cons,
|
||||
TG_KeyKind_Reg,
|
||||
TG_KeyKind_RegAlias,
|
||||
}
|
||||
TG_KeyKind;
|
||||
|
||||
typedef struct TG_Key TG_Key;
|
||||
struct TG_Key
|
||||
{
|
||||
TG_KeyKind kind;
|
||||
U32 u32[1]; // basic -> type_kind; cons -> type_kind; ext -> type_kind; reg -> arch
|
||||
U64 u64[1]; // ext -> unique id; cons -> idx; reg -> code
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Graph Types
|
||||
|
||||
typedef struct TG_ConsType TG_ConsType;
|
||||
struct TG_ConsType
|
||||
{
|
||||
TG_Kind kind;
|
||||
TG_Key direct_type_key;
|
||||
U64 u64;
|
||||
};
|
||||
|
||||
typedef struct TG_Node TG_Node;
|
||||
struct TG_Node
|
||||
{
|
||||
TG_Node *key_hash_next;
|
||||
TG_Node *content_hash_next;
|
||||
TG_Key key;
|
||||
TG_ConsType cons_type;
|
||||
};
|
||||
|
||||
typedef struct TG_Slot TG_Slot;
|
||||
struct TG_Slot
|
||||
{
|
||||
TG_Node *first;
|
||||
TG_Node *last;
|
||||
};
|
||||
|
||||
typedef struct TG_Graph TG_Graph;
|
||||
struct TG_Graph
|
||||
{
|
||||
U64 address_size;
|
||||
U64 cons_id_gen;
|
||||
U64 content_hash_slots_count;
|
||||
TG_Slot *content_hash_slots;
|
||||
U64 key_hash_slots_count;
|
||||
TG_Slot *key_hash_slots;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Extracted Info Types
|
||||
|
||||
typedef enum TG_MemberKind
|
||||
{
|
||||
TG_MemberKind_Null,
|
||||
TG_MemberKind_DataField,
|
||||
TG_MemberKind_StaticData,
|
||||
TG_MemberKind_Method,
|
||||
TG_MemberKind_StaticMethod,
|
||||
TG_MemberKind_VirtualMethod,
|
||||
TG_MemberKind_VTablePtr,
|
||||
TG_MemberKind_Base,
|
||||
TG_MemberKind_VirtualBase,
|
||||
TG_MemberKind_NestedType,
|
||||
TG_MemberKind_COUNT
|
||||
}
|
||||
TG_MemberKind;
|
||||
|
||||
typedef U32 TG_Flags;
|
||||
enum
|
||||
{
|
||||
TG_Flag_Const = (1<<0),
|
||||
TG_Flag_Volatile = (1<<1),
|
||||
};
|
||||
|
||||
typedef struct TG_Member TG_Member;
|
||||
struct TG_Member
|
||||
{
|
||||
TG_MemberKind kind;
|
||||
TG_Key type_key;
|
||||
String8 name;
|
||||
U64 off;
|
||||
};
|
||||
|
||||
typedef struct TG_MemberNode TG_MemberNode;
|
||||
struct TG_MemberNode
|
||||
{
|
||||
TG_MemberNode *next;
|
||||
TG_Member v;
|
||||
};
|
||||
|
||||
typedef struct TG_MemberList TG_MemberList;
|
||||
struct TG_MemberList
|
||||
{
|
||||
TG_MemberNode *first;
|
||||
TG_MemberNode *last;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct TG_MemberArray TG_MemberArray;
|
||||
struct TG_MemberArray
|
||||
{
|
||||
TG_Member *v;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct TG_EnumVal TG_EnumVal;
|
||||
struct TG_EnumVal
|
||||
{
|
||||
String8 name;
|
||||
U64 val;
|
||||
};
|
||||
|
||||
typedef struct TG_EnumValArray TG_EnumValArray;
|
||||
struct TG_EnumValArray
|
||||
{
|
||||
TG_EnumVal *v;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct TG_Type TG_Type;
|
||||
struct TG_Type
|
||||
{
|
||||
TG_Kind kind;
|
||||
TG_Flags flags;
|
||||
String8 name;
|
||||
U64 byte_size;
|
||||
U64 count;
|
||||
U32 off;
|
||||
TG_Key direct_type_key;
|
||||
TG_Key owner_type_key;
|
||||
TG_Key *param_type_keys;
|
||||
TG_Member *members;
|
||||
TG_EnumVal *enum_vals;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals
|
||||
|
||||
global read_only TG_Type tg_type_nil =
|
||||
{
|
||||
/* kind */ TG_Kind_Null,
|
||||
/* flags */ 0,
|
||||
/* name */ {(U8*)"<nil>",5},
|
||||
};
|
||||
|
||||
global read_only TG_Type tg_type_variadic =
|
||||
{
|
||||
/* kind */ TG_Kind_Variadic,
|
||||
/* flags */ 0,
|
||||
/* name */ {(U8*)"...",3},
|
||||
};
|
||||
|
||||
thread_static Arena *tg_build_arena = 0;
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helpers
|
||||
|
||||
internal U64 tg_hash_from_string(U64 seed, String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: RADDBG <-> TG Enum Conversions
|
||||
|
||||
internal TG_Kind tg_kind_from_raddbg_type_kind(RADDBG_TypeKind kind);
|
||||
internal TG_MemberKind tg_member_kind_from_raddbg_member_kind(RADDBG_MemberKind kind);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Key Type Functions
|
||||
|
||||
internal TG_Key tg_key_zero(void);
|
||||
internal TG_Key tg_key_basic(TG_Kind kind);
|
||||
internal TG_Key tg_key_ext(TG_Kind kind, U64 id);
|
||||
internal TG_Key tg_key_reg(Architecture arch, REGS_RegCode code);
|
||||
internal TG_Key tg_key_reg_alias(Architecture arch, REGS_AliasCode code);
|
||||
internal B32 tg_key_match(TG_Key a, TG_Key b);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Graph Construction API
|
||||
|
||||
internal TG_Graph *tg_graph_begin(U64 address_size, U64 slot_count);
|
||||
internal TG_Key tg_cons_type_make(TG_Graph *graph, TG_Kind kind, TG_Key direct_type_key, U64 u64);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Graph Introspection API
|
||||
|
||||
internal TG_Type *tg_type_from_graph_raddbg_key(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key tg_direct_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key tg_owner_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key tg_ptee_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key tg_unwrapped_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal U64 tg_byte_size_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Kind tg_kind_from_key(TG_Key key);
|
||||
internal TG_MemberArray tg_members_from_graph_raddbg_key(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_MemberArray tg_data_members_from_graph_raddbg_key(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal void tg_lhs_string_from_key(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key, String8List *out, U32 prec, B32 skip_return);
|
||||
internal void tg_rhs_string_from_key(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key, String8List *out, U32 prec);
|
||||
internal String8 tg_string_from_key(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
|
||||
#endif // TYPE_GRAPH_NEW_H
|
||||
@@ -0,0 +1,97 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tables
|
||||
|
||||
@table(name basic_string basic_byte_size)
|
||||
// NOTE(rjf): basic_byte_size == 0xFF? => address sized
|
||||
TG_KindTable:
|
||||
{
|
||||
{Null "" 0 }
|
||||
{Void "void" 0 }
|
||||
{Handle "HANDLE" 0xFF }
|
||||
{Char8 "char8" 1 }
|
||||
{Char16 "char16" 2 }
|
||||
{Char32 "char32" 4 }
|
||||
{UChar8 "uchar8" 1 }
|
||||
{UChar16 "uchar16" 2 }
|
||||
{UChar32 "uchar32" 4 }
|
||||
{U8 "U8" 1 }
|
||||
{U16 "U16" 2 }
|
||||
{U32 "U32" 4 }
|
||||
{U64 "U64" 8 }
|
||||
{U128 "U128" 16 }
|
||||
{U256 "U256" 32 }
|
||||
{U512 "U512" 64 }
|
||||
{S8 "S8" 1 }
|
||||
{S16 "S16" 2 }
|
||||
{S32 "S32" 4 }
|
||||
{S64 "S64" 8 }
|
||||
{S128 "S128" 16 }
|
||||
{S256 "S256" 32 }
|
||||
{S512 "S512" 64 }
|
||||
{Bool "bool" 1 }
|
||||
{F16 "F16" 2 }
|
||||
{F32 "F32" 4 }
|
||||
{F32PP "F32PP" 4 }
|
||||
{F48 "F48" 6 }
|
||||
{F64 "F64" 8 }
|
||||
{F80 "F80" 10 }
|
||||
{F128 "F128" 16 }
|
||||
{ComplexF32 "ComplexF32" 8 }
|
||||
{ComplexF64 "ComplexF64" 16 }
|
||||
{ComplexF80 "ComplexF80" 20 }
|
||||
{ComplexF128 "ComplexF128" 32 }
|
||||
{Modifier "" 0 }
|
||||
{Ptr "" 0 }
|
||||
{LRef "" 0 }
|
||||
{RRef "" 0 }
|
||||
{Array "" 0 }
|
||||
{Function "" 0 }
|
||||
{Method "" 0 }
|
||||
{MemberPtr "" 0 }
|
||||
{Struct "" 0 }
|
||||
{Class "" 0 }
|
||||
{Union "" 0 }
|
||||
{Enum "" 0 }
|
||||
{Alias "" 0 }
|
||||
{IncompleteStruct "" 0 }
|
||||
{IncompleteUnion "" 0 }
|
||||
{IncompleteClass "" 0 }
|
||||
{IncompleteEnum "" 0 }
|
||||
{Bitfield "" 0 }
|
||||
{Variadic "" 0 }
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generators
|
||||
|
||||
@table_gen_enum
|
||||
TG_Kind:
|
||||
{
|
||||
@expand(TG_KindTable a) `TG_Kind_$(a.name),`;
|
||||
`TG_Kind_COUNT,`;
|
||||
`TG_Kind_FirstBasic = TG_Kind_Void,`;
|
||||
`TG_Kind_LastBasic = TG_Kind_ComplexF128,`;
|
||||
`TG_Kind_FirstInteger = TG_Kind_Char8,`;
|
||||
`TG_Kind_LastInteger = TG_Kind_S512,`;
|
||||
`TG_Kind_FirstSigned1 = TG_Kind_Char8,`;
|
||||
`TG_Kind_LastSigned1 = TG_Kind_Char32,`;
|
||||
`TG_Kind_FirstSigned2 = TG_Kind_S8,`;
|
||||
`TG_Kind_LastSigned2 = TG_Kind_S512,`;
|
||||
`TG_Kind_FirstIncomplete = TG_Kind_IncompleteStruct,`;
|
||||
`TG_Kind_LastIncomplete = TG_Kind_IncompleteEnum,`;
|
||||
}
|
||||
|
||||
@table_gen_data(type:U8, fallback:0)
|
||||
tg_kind_basic_byte_size_table:
|
||||
{
|
||||
@expand(TG_KindTable a) `$(a.basic_byte_size),`;
|
||||
}
|
||||
|
||||
@table_gen_data(type:String8, fallback:`{0}`)
|
||||
tg_kind_basic_string_table:
|
||||
{
|
||||
@expand(TG_KindTable a) `str8_lit_comp("$(a.basic_string)"),`;
|
||||
}
|
||||
Reference in New Issue
Block a user