mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-15 13:29:41 -07:00
WIP rework GSI and PSI symbol writer
This commit is contained in:
1 parent
883935d44e
commit
d7cfd5f55a
8 files changed
+432
-568
No files matched your search
@@ -192,21 +192,8 @@ cv_precomp_info_from_leaf(CV_Leaf leaf)
|
||||
//~ Symbol Helpers
|
||||
|
||||
internal U64
|
||||
cv_size_from_symbol(CV_Symbol *symbol, U64 align)
|
||||
cv_write_symbol_buf(String8Node *buf, U64 *buf_pos, CV_Symbol *symbol, U64 align)
|
||||
{
|
||||
U64 size = 0;
|
||||
size += sizeof(CV_SymSize);
|
||||
size += sizeof(CV_SymKind);
|
||||
size += AlignPow2(symbol->data.size, align);
|
||||
return size;
|
||||
}
|
||||
|
||||
internal U64
|
||||
cv_write_symbol(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_Symbol *symbol, U64 align)
|
||||
{
|
||||
U64 write_size = cv_size_from_symbol(symbol, align);
|
||||
Assert(buffer_cursor + write_size <= buffer_size);
|
||||
|
||||
U64 record_size = 0;
|
||||
record_size += sizeof(symbol->kind);
|
||||
record_size += AlignPow2(symbol->data.size, align);
|
||||
@@ -214,23 +201,28 @@ cv_write_symbol(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_Symbol *symbo
|
||||
Assert(record_size <= CV_SymSize_Max);
|
||||
CV_SymSize record_size16 = (CV_SymSize)record_size;
|
||||
|
||||
// init header
|
||||
CV_SymbolHeader *header = (CV_SymbolHeader *)(buffer + buffer_cursor);
|
||||
header->size = record_size16;
|
||||
header->kind = symbol->kind;
|
||||
|
||||
// copy symbol data
|
||||
U8 *data_dst = (U8 *)(header + 1);
|
||||
MemoryCopy(data_dst, symbol->data.str, symbol->data.size);
|
||||
|
||||
// set pad bytes
|
||||
U64 pad_size = AlignPadPow2(symbol->data.size, align);
|
||||
U8 *pad_dst = data_dst + symbol->data.size;
|
||||
MemorySet(&pad_dst[0], 0, pad_size);
|
||||
U64 write_size = 0;
|
||||
write_size += str8_buffer_write(buf, buf_pos, str8((U8 *)&(CV_SymbolHeader){ .size = record_size16, .kind = symbol->kind }, sizeof(CV_SymbolHeader)));
|
||||
write_size += str8_buffer_write(buf, buf_pos, symbol->data);
|
||||
write_size += str8_buffer_write_zeroes(buf, buf_pos, AlignPadPow2(symbol->data.size, align));
|
||||
|
||||
return write_size;
|
||||
}
|
||||
|
||||
internal U64
|
||||
cv_write_symbol(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_Symbol *symbol, U64 align)
|
||||
{
|
||||
String8Node dummy_curr = { .string = str8(buffer + buffer_cursor, buffer_size - buffer_cursor) };
|
||||
U64 dummy_pos = 0;
|
||||
return cv_write_symbol_buf(&dummy_curr, &dummy_pos, symbol, align);
|
||||
}
|
||||
|
||||
internal U64
|
||||
cv_size_from_symbol(CV_Symbol *symbol, U64 align)
|
||||
{
|
||||
return cv_write_symbol_buf(0, 0, symbol, align);
|
||||
}
|
||||
|
||||
internal String8
|
||||
cv_data_from_symbol(Arena *arena, CV_Symbol *symbol, U64 align)
|
||||
{
|
||||
@@ -1532,9 +1524,7 @@ cv_patch_symbol_tree_offsets_new(String8List raw_symbols, U64 base_offset, U64 a
|
||||
for EachNode(n, String8Node, raw_symbols.first) {
|
||||
for (U64 cursor = 0, depth = 0; cursor + sizeof(CV_SymbolHeader) <= n->string.size; ) {
|
||||
CV_Symbol symbol = {0};
|
||||
TryReadBreak(cv_read_symbol(n->string, cursor, CV_SymbolAlign, &symbol), cursor);
|
||||
|
||||
if (symbol.kind == CV_SymKind_SKIP) { continue; }
|
||||
TryReadBreak(cv_read_symbol(n->string, cursor, align, &symbol), cursor);
|
||||
|
||||
if (cv_is_scope_symbol(symbol.kind)) {
|
||||
// NOTE: We don't patch 'next' offset in PROC symbols because
|
||||
|
||||
@@ -403,7 +403,6 @@ internal String8 cv_make_comp3(Arena *arena, CV_Compile3Flags flags, CV_La
|
||||
internal String8 cv_make_envblock(Arena *arena, String8List string_list);
|
||||
internal CV_Symbol cv_make_proc_ref(Arena *arena, CV_ModIndex imod, U32 stream_offset, String8 name, B32 is_local);
|
||||
internal CV_Symbol cv_make_pub32(Arena *arena, CV_Pub32Flags flags, U32 off, U16 isect, String8 name);
|
||||
internal CV_SymbolList cv_make_proc_refs(Arena *arena, CV_ModIndex imod, CV_SymbolList symbol_list);
|
||||
|
||||
internal U64 cv_read_symbol(String8 raw_data, U64 off, U64 align, CV_Symbol *symbol_out);
|
||||
internal CV_Symbol cv_symbol_from_string(String8 raw_data);
|
||||
|
||||
Reference in new issue
Block a user