mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
rename CodeView leaf/symbol/debug_s helpers for consistent naming
This commit is contained in:
+191
-228
@@ -16,27 +16,125 @@ hash_from_cv_symbol(CV_Symbol *symbol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
//~ Leaf Helpers
|
||||||
|
|
||||||
internal CV_ObjInfo
|
internal U64
|
||||||
cv_obj_info_from_symbol(CV_Symbol symbol)
|
cv_size_from_leaf(String8 data, U64 align)
|
||||||
{
|
{
|
||||||
CV_ObjInfo result; MemoryZeroStruct(&result);
|
U64 size = 0;
|
||||||
switch (symbol.kind) {
|
size += sizeof(CV_LeafSize);
|
||||||
case CV_SymKind_OBJNAME: {
|
size += sizeof(CV_LeafKind);
|
||||||
CV_SymObjName *obj_name = (CV_SymObjName *) symbol.data.str;
|
size += data.size;
|
||||||
result.sig = obj_name->sig;
|
size = AlignPow2(size, align);
|
||||||
str8_deserial_read_cstr(symbol.data, sizeof(CV_SymObjName), &result.name);
|
return size;
|
||||||
} break;
|
|
||||||
case CV_SymKind_OBJNAME_ST: {
|
|
||||||
NotImplemented;
|
|
||||||
} break;
|
|
||||||
default: {
|
|
||||||
InvalidPath;
|
|
||||||
} break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal U64
|
||||||
|
cv_write_leaf(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_LeafKind kind, String8 data, U64 align)
|
||||||
|
{
|
||||||
|
U64 buffer_cursor_start = buffer_cursor;
|
||||||
|
|
||||||
|
// compute record size
|
||||||
|
U64 record_size = sizeof(kind) + data.size;
|
||||||
|
Assert(record_size <= CV_LeafSize_Max);
|
||||||
|
CV_LeafSize record_size16 = (CV_LeafSize)record_size;
|
||||||
|
|
||||||
|
// compute pad
|
||||||
|
static U8 LEAF_PAD_ARR[] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff };
|
||||||
|
U64 pad_size = AlignPadPow2(data.size, align);
|
||||||
|
Assert(pad_size <= ArrayCount(LEAF_PAD_ARR));
|
||||||
|
|
||||||
|
// write header
|
||||||
|
CV_LeafHeader *header_ptr = (CV_LeafHeader *)(buffer + buffer_cursor);
|
||||||
|
header_ptr->size = record_size16;
|
||||||
|
header_ptr->kind = kind;
|
||||||
|
buffer_cursor += sizeof(*header_ptr);
|
||||||
|
|
||||||
|
// write body
|
||||||
|
U8 *leaf_data_ptr = buffer + buffer_cursor;
|
||||||
|
MemoryCopy(leaf_data_ptr, data.str, data.size);
|
||||||
|
buffer_cursor += data.size;
|
||||||
|
|
||||||
|
// write pad
|
||||||
|
U8 *pad_data_ptr = buffer + buffer_cursor;
|
||||||
|
MemoryCopy(pad_data_ptr, &LEAF_PAD_ARR[0], pad_size);
|
||||||
|
buffer_cursor += pad_size;
|
||||||
|
|
||||||
|
U64 write_size = buffer_cursor - buffer_cursor_start;
|
||||||
|
return write_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8
|
||||||
|
cv_make_leaf(Arena *arena, CV_LeafKind kind, String8 data, U64 align)
|
||||||
|
{
|
||||||
|
U64 buffer_size = cv_size_from_leaf(data, align);
|
||||||
|
U8 *buffer = push_array_no_zero(arena, U8, buffer_size);
|
||||||
|
U64 size = cv_write_leaf(buffer, 0, buffer_size, kind, data, align);
|
||||||
|
String8 raw_leaf = str8(buffer, size);
|
||||||
|
return raw_leaf;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8
|
||||||
|
cv_data_from_leaf(Arena *arena, CV_Leaf *leaf, U64 align)
|
||||||
|
{
|
||||||
|
return cv_make_leaf(arena, leaf->kind, leaf->data, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal U64
|
||||||
|
cv_read_leaf(String8 raw_data, U64 off, U64 align, CV_Leaf *leaf_out)
|
||||||
|
{
|
||||||
|
// do we have enough bytes to read header?
|
||||||
|
Assert(raw_data.size >= sizeof(CV_LeafHeader));
|
||||||
|
|
||||||
|
U8 *leaf_ptr = raw_data.str + off;
|
||||||
|
|
||||||
|
StaticAssert(sizeof(CV_LeafHeader) == 4, g_leaf_header_size_check);
|
||||||
|
CV_LeafHeader header = { .v = memory_read32(leaf_ptr) };
|
||||||
|
|
||||||
|
// leaf size must have enough bytes for the kind enum
|
||||||
|
Assert(header.size >= sizeof(CV_LeafKind));
|
||||||
|
|
||||||
|
// do we have enough bytes to read leaf data?
|
||||||
|
Assert(sizeof(CV_LeafSize) + header.size <= raw_data.size);
|
||||||
|
|
||||||
|
// fill out leaf
|
||||||
|
leaf_out->kind = header.kind;
|
||||||
|
leaf_out->data = str8(leaf_ptr + sizeof(CV_LeafHeader), header.size - sizeof(CV_LeafKind));
|
||||||
|
|
||||||
|
U64 leaf_size = AlignPow2(sizeof(CV_LeafHeader) + leaf_out->data.size, align);
|
||||||
|
Assert(leaf_size <= raw_data.size);
|
||||||
|
return leaf_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal CV_Leaf
|
||||||
|
cv_leaf_from_string(String8 raw_data)
|
||||||
|
{
|
||||||
|
CV_Leaf result;
|
||||||
|
cv_read_leaf(raw_data, 0, 1, &result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal CV_Leaf
|
||||||
|
cv_leaf_from_ptr(U8 *ptr)
|
||||||
|
{
|
||||||
|
CV_Leaf leaf = {0};
|
||||||
|
cv_read_leaf(str8(ptr, max_U64), 0, 1, &leaf);
|
||||||
|
return leaf;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal U16
|
||||||
|
cv_leaf_size_from_ptr(U8 *ptr)
|
||||||
|
{
|
||||||
|
CV_LeafSize size = memory_read16(ptr);
|
||||||
|
return size + sizeof(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8
|
||||||
|
cv_raw_leaf_from_ptr(U8 *ptr)
|
||||||
|
{
|
||||||
|
return str8(ptr, cv_leaf_size_from_ptr(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
internal CV_TypeServerInfo
|
internal CV_TypeServerInfo
|
||||||
cv_type_server_info_from_leaf(CV_Leaf leaf)
|
cv_type_server_info_from_leaf(CV_Leaf leaf)
|
||||||
{
|
{
|
||||||
@@ -90,119 +188,11 @@ cv_precomp_info_from_leaf(CV_Leaf leaf)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ Leaf Helpers
|
|
||||||
|
|
||||||
internal U64
|
|
||||||
cv_compute_leaf_record_size(String8 data, U64 align)
|
|
||||||
{
|
|
||||||
U64 size = 0;
|
|
||||||
size += sizeof(CV_LeafSize);
|
|
||||||
size += sizeof(CV_LeafKind);
|
|
||||||
size += data.size;
|
|
||||||
size = AlignPow2(size, align);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal U64
|
|
||||||
cv_serialize_leaf_to_buffer(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_LeafKind kind, String8 data, U64 align)
|
|
||||||
{
|
|
||||||
U64 buffer_cursor_start = buffer_cursor;
|
|
||||||
|
|
||||||
// compute record size
|
|
||||||
U64 record_size = sizeof(kind) + data.size;
|
|
||||||
Assert(record_size <= CV_LeafSize_Max);
|
|
||||||
CV_LeafSize record_size16 = (CV_LeafSize)record_size;
|
|
||||||
|
|
||||||
// compute pad
|
|
||||||
static U8 LEAF_PAD_ARR[] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff };
|
|
||||||
U64 pad_size = AlignPadPow2(data.size, align);
|
|
||||||
Assert(pad_size <= ArrayCount(LEAF_PAD_ARR));
|
|
||||||
|
|
||||||
// write header
|
|
||||||
CV_LeafHeader *header_ptr = (CV_LeafHeader *)(buffer + buffer_cursor);
|
|
||||||
header_ptr->size = record_size16;
|
|
||||||
header_ptr->kind = kind;
|
|
||||||
buffer_cursor += sizeof(*header_ptr);
|
|
||||||
|
|
||||||
// write body
|
|
||||||
U8 *leaf_data_ptr = buffer + buffer_cursor;
|
|
||||||
MemoryCopy(leaf_data_ptr, data.str, data.size);
|
|
||||||
buffer_cursor += data.size;
|
|
||||||
|
|
||||||
// write pad
|
|
||||||
U8 *pad_data_ptr = buffer + buffer_cursor;
|
|
||||||
MemoryCopy(pad_data_ptr, &LEAF_PAD_ARR[0], pad_size);
|
|
||||||
buffer_cursor += pad_size;
|
|
||||||
|
|
||||||
U64 write_size = buffer_cursor - buffer_cursor_start;
|
|
||||||
return write_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8
|
|
||||||
cv_serialize_raw_leaf(Arena *arena, CV_LeafKind kind, String8 data, U64 align)
|
|
||||||
{
|
|
||||||
U64 buffer_size = cv_compute_leaf_record_size(data, align);
|
|
||||||
U8 *buffer = push_array_no_zero(arena, U8, buffer_size);
|
|
||||||
U64 size = cv_serialize_leaf_to_buffer(buffer, 0, buffer_size, kind, data, align);
|
|
||||||
String8 raw_leaf = str8(buffer, size);
|
|
||||||
return raw_leaf;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8
|
|
||||||
cv_serialize_leaf(Arena *arena, CV_Leaf *leaf, U64 align)
|
|
||||||
{
|
|
||||||
return cv_serialize_raw_leaf(arena, leaf->kind, leaf->data, align);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal CV_Leaf
|
|
||||||
cv_make_leaf(Arena *arena, CV_LeafKind kind, String8 data)
|
|
||||||
{
|
|
||||||
CV_Leaf result = {0};
|
|
||||||
String8 raw_leaf = cv_serialize_raw_leaf(arena, kind, data, 1);
|
|
||||||
cv_deserial_leaf(raw_leaf, 0, 1, &result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal U64
|
|
||||||
cv_deserial_leaf(String8 raw_data, U64 off, U64 align, CV_Leaf *leaf_out)
|
|
||||||
{
|
|
||||||
// do we have enough bytes to read header?
|
|
||||||
Assert(raw_data.size >= sizeof(CV_LeafHeader));
|
|
||||||
|
|
||||||
U8 *leaf_ptr = raw_data.str + off;
|
|
||||||
|
|
||||||
StaticAssert(sizeof(CV_LeafHeader) == 4, g_leaf_header_size_check);
|
|
||||||
CV_LeafHeader header = { .v = memory_read32(leaf_ptr) };
|
|
||||||
|
|
||||||
// leaf size must have enough bytes for the kind enum
|
|
||||||
Assert(header.size >= sizeof(CV_LeafKind));
|
|
||||||
|
|
||||||
// do we have enough bytes to read leaf data?
|
|
||||||
Assert(sizeof(CV_LeafSize) + header.size <= raw_data.size);
|
|
||||||
|
|
||||||
// fill out leaf
|
|
||||||
leaf_out->kind = header.kind;
|
|
||||||
leaf_out->data = str8(leaf_ptr + sizeof(CV_LeafHeader), header.size - sizeof(CV_LeafKind));
|
|
||||||
|
|
||||||
U64 leaf_size = AlignPow2(sizeof(CV_LeafHeader) + leaf_out->data.size, align);
|
|
||||||
Assert(leaf_size <= raw_data.size);
|
|
||||||
return leaf_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal CV_Leaf
|
|
||||||
cv_leaf_from_string(String8 raw_data)
|
|
||||||
{
|
|
||||||
CV_Leaf result;
|
|
||||||
cv_deserial_leaf(raw_data, 0, 1, &result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Symbol Helpers
|
//~ Symbol Helpers
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
cv_compute_symbol_record_size(CV_Symbol *symbol, U64 align)
|
cv_size_from_symbol(CV_Symbol *symbol, U64 align)
|
||||||
{
|
{
|
||||||
U64 size = 0;
|
U64 size = 0;
|
||||||
size += sizeof(CV_SymSize);
|
size += sizeof(CV_SymSize);
|
||||||
@@ -212,9 +202,9 @@ cv_compute_symbol_record_size(CV_Symbol *symbol, U64 align)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
cv_serialize_symbol_to_buffer(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_Symbol *symbol, U64 align)
|
cv_write_symbol(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_Symbol *symbol, U64 align)
|
||||||
{
|
{
|
||||||
U64 write_size = cv_compute_symbol_record_size(symbol, align);
|
U64 write_size = cv_size_from_symbol(symbol, align);
|
||||||
Assert(buffer_cursor + write_size <= buffer_size);
|
Assert(buffer_cursor + write_size <= buffer_size);
|
||||||
|
|
||||||
U64 record_size = 0;
|
U64 record_size = 0;
|
||||||
@@ -242,11 +232,11 @@ cv_serialize_symbol_to_buffer(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
cv_serialize_symbol(Arena *arena, CV_Symbol *symbol, U64 align)
|
cv_data_from_symbol(Arena *arena, CV_Symbol *symbol, U64 align)
|
||||||
{
|
{
|
||||||
U64 buffer_size = cv_compute_symbol_record_size(symbol, align);
|
U64 buffer_size = cv_size_from_symbol(symbol, align);
|
||||||
U8 *buffer = push_array(arena, U8, buffer_size);
|
U8 *buffer = push_array(arena, U8, buffer_size);
|
||||||
cv_serialize_symbol_to_buffer(buffer, 0, buffer_size, symbol, align);
|
cv_write_symbol(buffer, 0, buffer_size, symbol, align);
|
||||||
String8 result = str8(buffer, buffer_size);
|
String8 result = str8(buffer, buffer_size);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -406,11 +396,31 @@ cv_make_proc_refs(Arena *arena, CV_ModIndex imod, CV_SymbolList symbol_list)
|
|||||||
return proc_ref_list;
|
return proc_ref_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal CV_ObjInfo
|
||||||
|
cv_obj_info_from_symbol(CV_Symbol symbol)
|
||||||
|
{
|
||||||
|
CV_ObjInfo result; MemoryZeroStruct(&result);
|
||||||
|
switch (symbol.kind) {
|
||||||
|
case CV_SymKind_OBJNAME: {
|
||||||
|
CV_SymObjName *obj_name = (CV_SymObjName *) symbol.data.str;
|
||||||
|
result.sig = obj_name->sig;
|
||||||
|
str8_deserial_read_cstr(symbol.data, sizeof(CV_SymObjName), &result.name);
|
||||||
|
} break;
|
||||||
|
case CV_SymKind_OBJNAME_ST: {
|
||||||
|
NotImplemented;
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
InvalidPath;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ .debug$S helpers
|
//~ .debug$S helpers
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
cv_parse_debug_s_c13_(Arena *arena, CV_DebugS *debug_s, String8 raw_debug_s)
|
cv_debug_s_from_data_c13_(Arena *arena, CV_DebugS *debug_s, String8 raw_debug_s)
|
||||||
{
|
{
|
||||||
for (U64 cursor = 0; cursor + sizeof(CV_C13SubSectionHeader) <= raw_debug_s.size; ) {
|
for (U64 cursor = 0; cursor + sizeof(CV_C13SubSectionHeader) <= raw_debug_s.size; ) {
|
||||||
// read header
|
// read header
|
||||||
@@ -434,24 +444,6 @@ cv_parse_debug_s_c13_(Arena *arena, CV_DebugS *debug_s, String8 raw_debug_s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal CV_DebugS
|
|
||||||
cv_parse_debug_s_c13(Arena *arena, String8 raw_debug_s)
|
|
||||||
{
|
|
||||||
CV_DebugS debug_s = {0};
|
|
||||||
cv_parse_debug_s_c13_(arena, &debug_s, raw_debug_s);
|
|
||||||
return debug_s;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal CV_DebugS
|
|
||||||
cv_parse_debug_s_c13_list(Arena *arena, String8List raw_debug_s)
|
|
||||||
{
|
|
||||||
CV_DebugS debug_s = {0};
|
|
||||||
for (String8Node *node = raw_debug_s.first; node != 0; node = node->next) {
|
|
||||||
cv_parse_debug_s_c13_(arena, &debug_s, node->string);
|
|
||||||
}
|
|
||||||
return debug_s;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal force_inline UBSAN_NO_ALIGN CV_Signature
|
internal force_inline UBSAN_NO_ALIGN CV_Signature
|
||||||
cv_signature_from_debug_s(String8 raw_debug_s)
|
cv_signature_from_debug_s(String8 raw_debug_s)
|
||||||
{
|
{
|
||||||
@@ -461,7 +453,15 @@ cv_signature_from_debug_s(String8 raw_debug_s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal CV_DebugS
|
internal CV_DebugS
|
||||||
cv_parse_debug_s(Arena *arena, String8 raw_debug_s)
|
cv_debug_s_from_data_c13(Arena *arena, String8 raw_debug_s)
|
||||||
|
{
|
||||||
|
CV_DebugS debug_s = {0};
|
||||||
|
cv_debug_s_from_data_c13_(arena, &debug_s, raw_debug_s);
|
||||||
|
return debug_s;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal CV_DebugS
|
||||||
|
cv_debug_s_from_data(Arena *arena, String8 raw_debug_s)
|
||||||
{
|
{
|
||||||
CV_DebugS result; MemoryZeroStruct(&result);
|
CV_DebugS result; MemoryZeroStruct(&result);
|
||||||
if (raw_debug_s.size >= sizeof(CV_Signature)) {
|
if (raw_debug_s.size >= sizeof(CV_Signature)) {
|
||||||
@@ -469,7 +469,7 @@ cv_parse_debug_s(Arena *arena, String8 raw_debug_s)
|
|||||||
switch (sig) {
|
switch (sig) {
|
||||||
case CV_Signature_C13: {
|
case CV_Signature_C13: {
|
||||||
String8 raw_debug_s_past_sig = str8_substr(raw_debug_s, r1u64(sizeof(sig), raw_debug_s.size));
|
String8 raw_debug_s_past_sig = str8_substr(raw_debug_s, r1u64(sizeof(sig), raw_debug_s.size));
|
||||||
result = cv_parse_debug_s_c13(arena, raw_debug_s_past_sig);
|
result = cv_debug_s_from_data_c13(arena, raw_debug_s_past_sig);
|
||||||
} break;
|
} break;
|
||||||
case CV_Signature_C6: {
|
case CV_Signature_C6: {
|
||||||
Assert(!"TODO: handle C6");
|
Assert(!"TODO: handle C6");
|
||||||
@@ -494,57 +494,6 @@ cv_debug_s_concat_in_place(CV_DebugS *dst, CV_DebugS *src)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8List
|
|
||||||
cv_data_c13_from_debug_s(Arena *arena, CV_DebugS *debug_s, B32 write_sig)
|
|
||||||
{
|
|
||||||
String8List srl = {0};
|
|
||||||
str8_serial_begin(arena, &srl);
|
|
||||||
|
|
||||||
if (write_sig) {
|
|
||||||
CV_Signature sig = CV_Signature_C13;
|
|
||||||
str8_serial_push_struct(arena, &srl, &sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
static CV_C13SubSectionKind layout_arr[] = {
|
|
||||||
CV_C13SubSectionKind_Symbols,
|
|
||||||
//CV_C13SubSectionKind_Lines,
|
|
||||||
CV_C13SubSectionKind_FileChksms,
|
|
||||||
CV_C13SubSectionKind_FrameData,
|
|
||||||
CV_C13SubSectionKind_InlineeLines,
|
|
||||||
CV_C13SubSectionKind_IlLines,
|
|
||||||
CV_C13SubSectionKind_CrossScopeImports,
|
|
||||||
CV_C13SubSectionKind_CrossScopeExports,
|
|
||||||
CV_C13SubSectionKind_FuncMDTokenMap,
|
|
||||||
CV_C13SubSectionKind_TypeMDTokenMap,
|
|
||||||
CV_C13SubSectionKind_MergedAssemblyInput,
|
|
||||||
CV_C13SubSectionKind_CoffSymbolRVA,
|
|
||||||
CV_C13SubSectionKind_XfgHashType,
|
|
||||||
CV_C13SubSectionKind_XfgHashVirtual,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (U64 layout_idx = 0; layout_idx < ArrayCount(layout_arr); layout_idx += 1) {
|
|
||||||
CV_C13SubSectionKind kind = layout_arr[layout_idx];
|
|
||||||
String8List *data = cv_sub_section_ptr_from_debug_s(debug_s, kind);
|
|
||||||
if (data->total_size > 0) {
|
|
||||||
U32 size32 = safe_cast_u32(data->total_size);
|
|
||||||
str8_serial_push_u32(arena, &srl, kind);
|
|
||||||
str8_serial_push_u32(arena, &srl, size32);
|
|
||||||
str8_serial_push_data_list(arena, &srl, data->first);
|
|
||||||
str8_serial_push_align(arena, &srl, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String8List *line_data = cv_sub_section_ptr_from_debug_s(debug_s, CV_C13SubSectionKind_Lines);
|
|
||||||
for (String8Node *line_node = line_data->first; line_node != 0; line_node = line_node->next) {
|
|
||||||
str8_serial_push_u32(arena, &srl, CV_C13SubSectionKind_Lines);
|
|
||||||
str8_serial_push_u32(arena, &srl, safe_cast_u32(line_node->string.size));
|
|
||||||
str8_serial_push_string(arena, &srl, line_node->string);
|
|
||||||
str8_serial_push_align(arena, &srl, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
return srl;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
cv_size_from_debug_s(CV_DebugS *debug_s, U64 align)
|
cv_size_from_debug_s(CV_DebugS *debug_s, U64 align)
|
||||||
{
|
{
|
||||||
@@ -568,6 +517,41 @@ cv_size_from_debug_s(CV_DebugS *debug_s, U64 align)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal String8List
|
||||||
|
cv_data_from_debug_s_c13(Arena *arena, CV_DebugS *debug_s, B32 write_sig)
|
||||||
|
{
|
||||||
|
String8List srl = {0};
|
||||||
|
str8_serial_begin(arena, &srl);
|
||||||
|
|
||||||
|
if (write_sig) {
|
||||||
|
CV_Signature sig = CV_Signature_C13;
|
||||||
|
str8_serial_push_struct(arena, &srl, &sig);
|
||||||
|
}
|
||||||
|
|
||||||
|
for EachIndex(i, CV_C13SubSectionIdxKind_COUNT) {
|
||||||
|
if (i == CV_C13SubSectionIdxKind_Lines) { continue; }
|
||||||
|
CV_C13SubSectionKind kind = cv_c13_sub_section_kind_from_idx(i);
|
||||||
|
String8List *data = cv_sub_section_ptr_from_debug_s(debug_s, kind);
|
||||||
|
if (data->total_size > 0) {
|
||||||
|
U32 size32 = safe_cast_u32(data->total_size);
|
||||||
|
str8_serial_push_u32(arena, &srl, kind);
|
||||||
|
str8_serial_push_u32(arena, &srl, size32);
|
||||||
|
str8_serial_push_data_list(arena, &srl, data->first);
|
||||||
|
str8_serial_push_align(arena, &srl, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String8List *line_data = cv_sub_section_ptr_from_debug_s(debug_s, CV_C13SubSectionKind_Lines);
|
||||||
|
for EachNode(line_n, String8Node, line_data->first) {
|
||||||
|
str8_serial_push_u32(arena, &srl, CV_C13SubSectionKind_Lines);
|
||||||
|
str8_serial_push_u32(arena, &srl, safe_cast_u32(line_n->string.size));
|
||||||
|
str8_serial_push_string(arena, &srl, line_n->string);
|
||||||
|
str8_serial_push_align(arena, &srl, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return srl;
|
||||||
|
}
|
||||||
|
|
||||||
internal CV_C13SubSectionKind
|
internal CV_C13SubSectionKind
|
||||||
cv_c13_sub_section_kind_from_idx(CV_C13SubSectionIdxKind idx)
|
cv_c13_sub_section_kind_from_idx(CV_C13SubSectionIdxKind idx)
|
||||||
{
|
{
|
||||||
@@ -1112,7 +1096,7 @@ cv_debug_t_from_data(Arena *arena, String8 data, U64 align)
|
|||||||
U64 count = 0;
|
U64 count = 0;
|
||||||
for (U64 cursor = 0; cursor < data.size; count += 1) {
|
for (U64 cursor = 0; cursor < data.size; count += 1) {
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cursor += cv_deserial_leaf(data, cursor, align, &leaf);
|
cursor += cv_read_leaf(data, cursor, align, &leaf);
|
||||||
}
|
}
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
|
|
||||||
@@ -1121,7 +1105,7 @@ cv_debug_t_from_data(Arena *arena, String8 data, U64 align)
|
|||||||
offsets[idx++] = cursor;
|
offsets[idx++] = cursor;
|
||||||
|
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cursor += cv_deserial_leaf(data, cursor, align, &leaf);
|
cursor += cv_read_leaf(data, cursor, align, &leaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CV_DebugT){ .count = count, .data = data, .offsets = offsets };
|
return (CV_DebugT){ .count = count, .data = data, .offsets = offsets };
|
||||||
@@ -1133,7 +1117,7 @@ cv_debug_t_get_leaf(CV_DebugT debug_t, U64 leaf_idx)
|
|||||||
CV_Leaf leaf = {0};
|
CV_Leaf leaf = {0};
|
||||||
if (debug_t.count > 0) {
|
if (debug_t.count > 0) {
|
||||||
Assert(leaf_idx < debug_t.count);
|
Assert(leaf_idx < debug_t.count);
|
||||||
cv_deserial_leaf(debug_t.data, debug_t.offsets[leaf_idx], 1, &leaf);
|
cv_read_leaf(debug_t.data, debug_t.offsets[leaf_idx], 1, &leaf);
|
||||||
Assert(cv_header_struct_size_from_leaf_kind(leaf.kind) <= leaf.data.size);
|
Assert(cv_header_struct_size_from_leaf_kind(leaf.kind) <= leaf.data.size);
|
||||||
}
|
}
|
||||||
return leaf;
|
return leaf;
|
||||||
@@ -1178,27 +1162,6 @@ cv_debug_t_array_count_leaves(U64 count, CV_DebugT *debug_t)
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal CV_Leaf
|
|
||||||
cv_leaf_from_ptr(U8 *ptr)
|
|
||||||
{
|
|
||||||
CV_Leaf leaf = {0};
|
|
||||||
cv_deserial_leaf(str8(ptr, max_U64), 0, 1, &leaf);
|
|
||||||
return leaf;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal U16
|
|
||||||
cv_leaf_size_from_ptr(U8 *ptr)
|
|
||||||
{
|
|
||||||
CV_LeafSize size = memory_read16(ptr);
|
|
||||||
return size + sizeof(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8
|
|
||||||
cv_raw_leaf_from_ptr(U8 *ptr)
|
|
||||||
{
|
|
||||||
return str8(ptr, cv_leaf_size_from_ptr(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
// $$Symbols
|
// $$Symbols
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
@@ -1323,11 +1286,11 @@ cv_symbol_list_arr_get_count(U64 count, CV_SymbolList *list_arr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal String8List
|
internal String8List
|
||||||
cv_data_from_symbol_list(Arena *arena, CV_SymbolList symbol_list, U64 align)
|
cv_write_symbol_list(Arena *arena, CV_SymbolList symbol_list, U64 align)
|
||||||
{
|
{
|
||||||
String8List data_list = {0};
|
String8List data_list = {0};
|
||||||
for (CV_SymbolNode *node = symbol_list.first; node != 0; node = node->next) {
|
for (CV_SymbolNode *node = symbol_list.first; node != 0; node = node->next) {
|
||||||
String8 data = cv_serialize_symbol(arena, &node->data, align);
|
String8 data = cv_data_from_symbol(arena, &node->data, align);
|
||||||
str8_list_push(arena, &data_list, data);
|
str8_list_push(arena, &data_list, data);
|
||||||
}
|
}
|
||||||
return data_list;
|
return data_list;
|
||||||
@@ -1509,7 +1472,7 @@ cv_patch_symbol_tree_offsets(CV_SymbolList list, U64 base_offset, U64 align)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// advance cursor
|
// advance cursor
|
||||||
cursor += cv_compute_symbol_record_size(&symbol, align);
|
cursor += cv_size_from_symbol(&symbol, align);
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
|
|||||||
@@ -359,51 +359,51 @@ typedef struct
|
|||||||
} CV_PackStringHashTableTask;
|
} CV_PackStringHashTableTask;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
//~ Leaf helpers
|
||||||
|
|
||||||
|
internal U64 cv_size_from_leaf(String8 data, U64 align);
|
||||||
|
internal U64 cv_write_leaf(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_LeafKind kind, String8 data, U64 align);
|
||||||
|
internal String8 cv_make_leaf(Arena *arena, CV_LeafKind kind, String8 data, U64 align);
|
||||||
|
internal String8 cv_data_from_leaf(Arena *arena, CV_Leaf *leaf, U64 align);
|
||||||
|
|
||||||
|
internal U64 cv_read_leaf(String8 raw_data, U64 off, U64 align, CV_Leaf *leaf_out);
|
||||||
|
internal CV_Leaf cv_leaf_from_string(String8 raw_data);
|
||||||
|
internal CV_Leaf cv_leaf_from_ptr(U8 *ptr);
|
||||||
|
internal U16 cv_leaf_size_from_ptr(U8 *ptr);
|
||||||
|
internal String8 cv_raw_leaf_from_ptr(U8 *ptr);
|
||||||
|
|
||||||
internal CV_ObjInfo cv_obj_info_from_symbol(CV_Symbol symbol);
|
|
||||||
internal CV_TypeServerInfo cv_type_server_info_from_leaf(CV_Leaf leaf);
|
internal CV_TypeServerInfo cv_type_server_info_from_leaf(CV_Leaf leaf);
|
||||||
internal CV_PrecompInfo cv_precomp_info_from_leaf(CV_Leaf leaf);
|
internal CV_PrecompInfo cv_precomp_info_from_leaf(CV_Leaf leaf);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Leaf Helpers
|
//~ Symbol helpers
|
||||||
|
|
||||||
internal U64 cv_compute_leaf_record_size(String8 data, U64 align);
|
internal U64 cv_size_from_symbol(CV_Symbol *symbol, U64 align);
|
||||||
internal U64 cv_serialize_leaf_to_buffer(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_LeafKind kind, String8 data, U64 align);
|
internal U64 cv_write_symbol(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_Symbol *symbol, U64 align);
|
||||||
internal String8 cv_serialize_raw_leaf(Arena *arena, CV_LeafKind kind, String8 data, U64 align);
|
internal String8 cv_data_from_symbol(Arena *arena, CV_Symbol *symbol, U64 align);
|
||||||
internal String8 cv_serialize_leaf(Arena *arena, CV_Leaf *leaf, U64 align);
|
|
||||||
internal CV_Leaf cv_make_leaf(Arena *arena, CV_LeafKind kind, String8 data);
|
|
||||||
internal U64 cv_deserial_leaf(String8 raw_data, U64 off, U64 align, CV_Leaf *leaf_out);
|
|
||||||
internal CV_Leaf cv_leaf_from_string(String8 raw_data);
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ Symbol Helpers
|
|
||||||
|
|
||||||
internal U64 cv_compute_symbol_record_size(CV_Symbol *symbol, U64 align);
|
|
||||||
internal U64 cv_serialize_symbol_to_buffer(U8 *buffer, U64 buffer_cursor, U64 buffer_size, CV_Symbol *symbol, U64 align);
|
|
||||||
internal String8 cv_serialize_symbol(Arena *arena, CV_Symbol *symbol, U64 align);
|
|
||||||
|
|
||||||
internal String8 cv_make_symbol(Arena *arena, CV_SymKind kind, String8 data);
|
internal String8 cv_make_symbol(Arena *arena, CV_SymKind kind, String8 data);
|
||||||
internal String8 cv_make_obj_name(Arena *arena, String8 obj_path, U32 sig);
|
internal String8 cv_make_obj_name(Arena *arena, String8 obj_path, U32 sig);
|
||||||
internal String8 cv_make_comp3(Arena *arena,
|
internal String8 cv_make_comp3(Arena *arena, CV_Compile3Flags flags, CV_Language lang, CV_Arch arch, U16 ver_fe_major, U16 ver_fe_minor, U16 ver_fe_build, U16 ver_feqfe, U16 ver_major, U16 ver_minor, U16 ver_build, U16 ver_qfe, String8 version_string);
|
||||||
CV_Compile3Flags flags, CV_Language lang, CV_Arch arch,
|
|
||||||
U16 ver_fe_major, U16 ver_fe_minor, U16 ver_fe_build, U16 ver_feqfe,
|
|
||||||
U16 ver_major, U16 ver_minor, U16 ver_build, U16 ver_qfe,
|
|
||||||
String8 version_string);
|
|
||||||
internal String8 cv_make_envblock(Arena *arena, String8List string_list);
|
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_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_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 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);
|
||||||
|
|
||||||
|
internal CV_ObjInfo cv_obj_info_from_symbol(CV_Symbol symbol);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// .debug$S Helpers
|
// .debug$S helpers
|
||||||
|
|
||||||
internal CV_DebugS cv_parse_debug_s_c13(Arena *arena, String8 raw_debug_s);
|
|
||||||
internal CV_DebugS cv_parse_debug_s_c13_list(Arena *arena, String8List raw_debug_s);
|
|
||||||
internal CV_Signature cv_signature_from_debug_s(String8 raw_debug_s);
|
internal CV_Signature cv_signature_from_debug_s(String8 raw_debug_s);
|
||||||
internal CV_DebugS cv_parse_debug_s(Arena *arena, String8 raw_debug_s);
|
internal CV_DebugS cv_debug_s_from_data_c13(Arena *arena, String8 raw_debug_s);
|
||||||
|
internal CV_DebugS cv_debug_s_from_data(Arena *arena, String8 raw_debug_s);
|
||||||
internal void cv_debug_s_concat_in_place(CV_DebugS *dst, CV_DebugS *src);
|
internal void cv_debug_s_concat_in_place(CV_DebugS *dst, CV_DebugS *src);
|
||||||
internal String8List cv_data_c13_from_debug_s(Arena *arena, CV_DebugS *debug_s, B32 write_sig);
|
|
||||||
internal U64 cv_size_from_debug_s(CV_DebugS *debug_s, U64 align);
|
internal U64 cv_size_from_debug_s(CV_DebugS *debug_s, U64 align);
|
||||||
|
internal String8List cv_data_from_debug_s_c13(Arena *arena, CV_DebugS *debug_s, B32 write_sig);
|
||||||
|
|
||||||
internal CV_C13SubSectionKind cv_c13_sub_section_kind_from_idx(CV_C13SubSectionIdxKind idx);
|
internal CV_C13SubSectionKind cv_c13_sub_section_kind_from_idx(CV_C13SubSectionIdxKind idx);
|
||||||
internal CV_C13SubSectionIdxKind cv_c13_sub_section_idx_from_kind(CV_C13SubSectionKind kind);
|
internal CV_C13SubSectionIdxKind cv_c13_sub_section_idx_from_kind(CV_C13SubSectionKind kind);
|
||||||
@@ -430,6 +430,7 @@ internal U64 cv_debug_t_array_count_leaves(U64 count, CV_DebugT *arr
|
|||||||
// $$Symbols
|
// $$Symbols
|
||||||
internal void cv_parse_symbol_sub_section_capped(Arena *arena, CV_SymbolList *list, U64 offset_base, String8 data, U64 align, U64 cap);
|
internal void cv_parse_symbol_sub_section_capped(Arena *arena, CV_SymbolList *list, U64 offset_base, String8 data, U64 align, U64 cap);
|
||||||
internal void cv_parse_symbol_sub_section(Arena *arena, CV_SymbolList *list, U64 offset_base, String8 data, U64 align);
|
internal void cv_parse_symbol_sub_section(Arena *arena, CV_SymbolList *list, U64 offset_base, String8 data, U64 align);
|
||||||
|
|
||||||
internal void cv_symbol_list_push_node(CV_SymbolList *list, CV_SymbolNode *node);
|
internal void cv_symbol_list_push_node(CV_SymbolList *list, CV_SymbolNode *node);
|
||||||
internal CV_SymbolNode * cv_symbol_list_push(Arena *arena, CV_SymbolList *list);
|
internal CV_SymbolNode * cv_symbol_list_push(Arena *arena, CV_SymbolList *list);
|
||||||
internal CV_SymbolNode * cv_symbol_list_push_data(Arena *arena, CV_SymbolList *list, CV_SymKind kind, String8 data);
|
internal CV_SymbolNode * cv_symbol_list_push_data(Arena *arena, CV_SymbolList *list, CV_SymKind kind, String8 data);
|
||||||
@@ -438,7 +439,8 @@ internal void cv_symbol_list_remove_node(CV_SymbolList *list, CV_Sy
|
|||||||
internal void cv_symbol_list_concat_in_place(CV_SymbolList *list, CV_SymbolList *to_concat);
|
internal void cv_symbol_list_concat_in_place(CV_SymbolList *list, CV_SymbolList *to_concat);
|
||||||
internal void cv_symbol_list_concat_in_place_arr(CV_SymbolList *list, U64 count, CV_SymbolList *to_concat);
|
internal void cv_symbol_list_concat_in_place_arr(CV_SymbolList *list, U64 count, CV_SymbolList *to_concat);
|
||||||
internal U64 cv_symbol_list_arr_get_count(U64 count, CV_SymbolList *list_arr);
|
internal U64 cv_symbol_list_arr_get_count(U64 count, CV_SymbolList *list_arr);
|
||||||
internal String8List cv_data_from_symbol_list(Arena *arena, CV_SymbolList symbol_list, U64 align);
|
|
||||||
|
internal String8List cv_write_symbol_list(Arena *arena, CV_SymbolList symbol_list, U64 align);
|
||||||
internal CV_SymbolList cv_global_scope_symbols_from_list(Arena *arena, CV_SymbolList list);
|
internal CV_SymbolList cv_global_scope_symbols_from_list(Arena *arena, CV_SymbolList list);
|
||||||
internal CV_SymbolPtrArray cv_symbol_ptr_array_from_list(Arena *arena, TP_Context *tp, U64 count, CV_SymbolList *symbol_list_arr);
|
internal CV_SymbolPtrArray cv_symbol_ptr_array_from_list(Arena *arena, TP_Context *tp, U64 count, CV_SymbolList *symbol_list_arr);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -470,7 +470,7 @@ lnk_make_null_obj(Arena *arena)
|
|||||||
// push .debug$T sections with null leaf
|
// push .debug$T sections with null leaf
|
||||||
String8 null_debug_data;
|
String8 null_debug_data;
|
||||||
{
|
{
|
||||||
String8 raw_null_leaf = cv_serialize_raw_leaf(obj_writer->arena, CV_LeafKind_NOTYPE, str8(0,0), 1);
|
String8 raw_null_leaf = cv_make_leaf(obj_writer->arena, CV_LeafKind_NOTYPE, str8(0,0), 1);
|
||||||
|
|
||||||
String8List srl = {0};
|
String8List srl = {0};
|
||||||
str8_serial_begin(obj_writer->arena, &srl);
|
str8_serial_begin(obj_writer->arena, &srl);
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ lnk_make_debug_s(Arena *arena, CV_SymbolList symbol_list)
|
|||||||
|
|
||||||
CV_DebugS debug_s = {0};
|
CV_DebugS debug_s = {0};
|
||||||
String8List *symbol_list_ptr = cv_sub_section_ptr_from_debug_s(&debug_s, CV_C13SubSectionKind_Symbols);
|
String8List *symbol_list_ptr = cv_sub_section_ptr_from_debug_s(&debug_s, CV_C13SubSectionKind_Symbols);
|
||||||
*symbol_list_ptr = cv_data_from_symbol_list(scratch.arena, symbol_list, CV_SymbolAlign);
|
*symbol_list_ptr = cv_write_symbol_list(scratch.arena, symbol_list, CV_SymbolAlign);
|
||||||
|
|
||||||
String8List debug_s_data_list = cv_data_c13_from_debug_s(scratch.arena, &debug_s, 1);
|
String8List debug_s_data_list = cv_data_from_debug_s_c13(scratch.arena, &debug_s, 1);
|
||||||
String8 debug_s_data = str8_list_join(arena, &debug_s_data_list, 0);
|
String8 debug_s_data = str8_list_join(arena, &debug_s_data_list, 0);
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ THREAD_POOL_TASK_FUNC(lnk_parse_debug_s_task)
|
|||||||
|
|
||||||
for (String8Node *node = sect_list.first; node != 0; node = node->next) {
|
for (String8Node *node = sect_list.first; node != 0; node = node->next) {
|
||||||
// parse & merge sub sections
|
// parse & merge sub sections
|
||||||
CV_DebugS ds = cv_parse_debug_s(arena, node->string);
|
CV_DebugS ds = cv_debug_s_from_data(arena, node->string);
|
||||||
cv_debug_s_concat_in_place(debug_s, &ds);
|
cv_debug_s_concat_in_place(debug_s, &ds);
|
||||||
|
|
||||||
// make sure there is one string table
|
// make sure there is one string table
|
||||||
@@ -1032,10 +1032,10 @@ lnk_match_leaf_ref(LNK_CodeViewInput *input, LNK_LeafHashes *hashes, LNK_LeafRef
|
|||||||
|
|
||||||
if (a_hash == b_hash) {
|
if (a_hash == b_hash) {
|
||||||
CV_Leaf a_leaf;
|
CV_Leaf a_leaf;
|
||||||
cv_deserial_leaf(lnk_data_from_leaf_ref(input, a), 0, 1, &a_leaf);
|
cv_read_leaf(lnk_data_from_leaf_ref(input, a), 0, 1, &a_leaf);
|
||||||
|
|
||||||
CV_Leaf b_leaf;
|
CV_Leaf b_leaf;
|
||||||
cv_deserial_leaf(lnk_data_from_leaf_ref(input, b), 0, 1, &b_leaf);
|
cv_read_leaf(lnk_data_from_leaf_ref(input, b), 0, 1, &b_leaf);
|
||||||
|
|
||||||
Assert(a_leaf.kind == b_leaf.kind);
|
Assert(a_leaf.kind == b_leaf.kind);
|
||||||
|
|
||||||
@@ -2155,7 +2155,7 @@ THREAD_POOL_TASK_FUNC(lnk_fixup_symbols_task)
|
|||||||
String8 leaf_data = str8(leaf_arr_ipi[leaf_idx], max_U64);
|
String8 leaf_data = str8(leaf_arr_ipi[leaf_idx], max_U64);
|
||||||
|
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cv_deserial_leaf(leaf_data, 0, 1, &leaf);
|
cv_read_leaf(leaf_data, 0, 1, &leaf);
|
||||||
|
|
||||||
U64 min_leaf_size = cv_header_struct_size_from_leaf_kind(leaf.kind);
|
U64 min_leaf_size = cv_header_struct_size_from_leaf_kind(leaf.kind);
|
||||||
if (min_leaf_size > leaf.data.size) {
|
if (min_leaf_size > leaf.data.size) {
|
||||||
@@ -2739,7 +2739,7 @@ THREAD_POOL_TASK_FUNC(lnk_write_module_data_task)
|
|||||||
|
|
||||||
for EachIndex(i, parsed_symbols.count) {
|
for EachIndex(i, parsed_symbols.count) {
|
||||||
for EachNode(symbol_n, CV_SymbolNode, parsed_symbols.v[i].first) {
|
for EachNode(symbol_n, CV_SymbolNode, parsed_symbols.v[i].first) {
|
||||||
U64 symbol_size = cv_compute_symbol_record_size(&symbol_n->data, PDB_SYMBOL_ALIGN);
|
U64 symbol_size = cv_size_from_symbol(&symbol_n->data, PDB_SYMBOL_ALIGN);
|
||||||
|
|
||||||
// flush temp
|
// flush temp
|
||||||
if (temp_size + symbol_size > temp_max) {
|
if (temp_size + symbol_size > temp_max) {
|
||||||
@@ -2748,7 +2748,7 @@ THREAD_POOL_TASK_FUNC(lnk_write_module_data_task)
|
|||||||
temp_size = 0;
|
temp_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
U64 serial_size = cv_serialize_symbol_to_buffer(temp, temp_size, temp_max, &symbol_n->data, PDB_SYMBOL_ALIGN);
|
U64 serial_size = cv_write_symbol(temp, temp_size, temp_max, &symbol_n->data, PDB_SYMBOL_ALIGN);
|
||||||
Assert(serial_size == symbol_size);
|
Assert(serial_size == symbol_size);
|
||||||
temp_size += serial_size;
|
temp_size += serial_size;
|
||||||
}
|
}
|
||||||
@@ -3262,7 +3262,7 @@ THREAD_POOL_TASK_FUNC(lnk_build_udt_name_hash_table_task)
|
|||||||
String8 leaf_data = str8(task->leaf_arr[leaf_idx], max_U64);
|
String8 leaf_data = str8(task->leaf_arr[leaf_idx], max_U64);
|
||||||
|
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cv_deserial_leaf(leaf_data, 0, 1, &leaf);
|
cv_read_leaf(leaf_data, 0, 1, &leaf);
|
||||||
|
|
||||||
// is this UDT?
|
// is this UDT?
|
||||||
if ( ! cv_is_udt(leaf.kind)) { continue; }
|
if ( ! cv_is_udt(leaf.kind)) { continue; }
|
||||||
@@ -3531,7 +3531,7 @@ lnk_rdib_type_from_itype(LNK_ConvertTypesToRDI *task, CV_TypeIndex itype)
|
|||||||
// try to resovle forward reference (defn might be missing)
|
// try to resovle forward reference (defn might be missing)
|
||||||
if (itype >= tpi_range.min) {
|
if (itype >= tpi_range.min) {
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cv_deserial_leaf(str8(task->leaf_arr[CV_TypeIndexSource_TPI][itype - tpi_range.min], max_U64), 0, 1, &leaf);
|
cv_read_leaf(str8(task->leaf_arr[CV_TypeIndexSource_TPI][itype - tpi_range.min], max_U64), 0, 1, &leaf);
|
||||||
if (cv_is_udt(leaf.kind)) {
|
if (cv_is_udt(leaf.kind)) {
|
||||||
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
||||||
if (udt_info.props & CV_TypeProp_FwdRef) {
|
if (udt_info.props & CV_TypeProp_FwdRef) {
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ THREAD_POOL_TASK_FUNC(lnk_obj_initer)
|
|||||||
if (str8_match(name, str8_lit(".debug$S"), 0)) {
|
if (str8_match(name, str8_lit(".debug$S"), 0)) {
|
||||||
Temp temp = temp_begin(scratch.arena);
|
Temp temp = temp_begin(scratch.arena);
|
||||||
String8 debug_s_data = str8_substr(input->data, rng_1u64(sect_header->foff, sect_header->foff+sect_header->fsize));
|
String8 debug_s_data = str8_substr(input->data, rng_1u64(sect_header->foff, sect_header->foff+sect_header->fsize));
|
||||||
CV_DebugS debug_s = cv_parse_debug_s(temp.arena, debug_s_data);
|
CV_DebugS debug_s = cv_debug_s_from_data(temp.arena, debug_s_data);
|
||||||
for EachNode(symbols_n, String8Node, debug_s.data_list[CV_C13SubSectionIdxKind_Symbols].first) {
|
for EachNode(symbols_n, String8Node, debug_s.data_list[CV_C13SubSectionIdxKind_Symbols].first) {
|
||||||
CV_SymbolList symbol_list = {0};
|
CV_SymbolList symbol_list = {0};
|
||||||
cv_parse_symbol_sub_section_capped(scratch.arena, &symbol_list, 0, symbols_n->string, CV_SymbolAlign, 2);
|
cv_parse_symbol_sub_section_capped(scratch.arena, &symbol_list, 0, symbols_n->string, CV_SymbolAlign, 2);
|
||||||
@@ -750,7 +750,7 @@ lnk_debug_s_from_obj(Arena *arena, LNK_Obj *obj)
|
|||||||
{
|
{
|
||||||
for (String8Node *node = raw_debug_s.first; node != 0; node = node->next) {
|
for (String8Node *node = raw_debug_s.first; node != 0; node = node->next) {
|
||||||
// parse & merge sub sections
|
// parse & merge sub sections
|
||||||
CV_DebugS ds = cv_parse_debug_s(arena, node->string);
|
CV_DebugS ds = cv_debug_s_from_data(arena, node->string);
|
||||||
cv_debug_s_concat_in_place(&debug_s, &ds);
|
cv_debug_s_concat_in_place(&debug_s, &ds);
|
||||||
|
|
||||||
// make sure there is one string table
|
// make sure there is one string table
|
||||||
|
|||||||
@@ -1336,7 +1336,7 @@ pdb_type_server_make_leaf(PDB_TypeServer *ts, CV_LeafKind kind, String8 data)
|
|||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
|
|
||||||
String8 leaf = cv_serialize_raw_leaf(ts->arena, kind, data, PDB_LEAF_ALIGN);
|
String8 leaf = cv_make_leaf(ts->arena, kind, data, PDB_LEAF_ALIGN);
|
||||||
String8Node *node = str8_list_push(ts->arena, &ts->leaf_list, leaf);
|
String8Node *node = str8_list_push(ts->arena, &ts->leaf_list, leaf);
|
||||||
|
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
@@ -1427,7 +1427,7 @@ pdb_type_server_push(PDB_TypeServer *ts, String8 raw_leaf)
|
|||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
|
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cv_deserial_leaf(raw_leaf, 0, 1, &leaf);
|
cv_read_leaf(raw_leaf, 0, 1, &leaf);
|
||||||
|
|
||||||
if (cv_is_udt(leaf.kind)) {
|
if (cv_is_udt(leaf.kind)) {
|
||||||
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
||||||
@@ -1447,7 +1447,7 @@ THREAD_POOL_TASK_FUNC(pdb_count_udt_task)
|
|||||||
PDB_PushLeafTask *task = raw_task;
|
PDB_PushLeafTask *task = raw_task;
|
||||||
for EachInRange(leaf_idx, task->ranges[task_id]) {
|
for EachInRange(leaf_idx, task->ranges[task_id]) {
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cv_deserial_leaf(str8(task->leaf_arr[leaf_idx], max_U64), 0, 1, &leaf);
|
cv_read_leaf(str8(task->leaf_arr[leaf_idx], max_U64), 0, 1, &leaf);
|
||||||
|
|
||||||
if (cv_is_udt(leaf.kind)) {
|
if (cv_is_udt(leaf.kind)) {
|
||||||
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
||||||
@@ -1472,7 +1472,7 @@ THREAD_POOL_TASK_FUNC(pdb_push_udt_leaf_task)
|
|||||||
|
|
||||||
for EachInRange(leaf_idx, task->ranges[task_id]) {
|
for EachInRange(leaf_idx, task->ranges[task_id]) {
|
||||||
CV_Leaf leaf;
|
CV_Leaf leaf;
|
||||||
cv_deserial_leaf(str8(task->leaf_arr[leaf_idx], max_U64), 0, 1, &leaf);
|
cv_read_leaf(str8(task->leaf_arr[leaf_idx], max_U64), 0, 1, &leaf);
|
||||||
|
|
||||||
if (cv_is_udt(leaf.kind)) {
|
if (cv_is_udt(leaf.kind)) {
|
||||||
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data);
|
||||||
@@ -2273,7 +2273,7 @@ THREAD_POOL_TASK_FUNC(gsi_size_buckets_task)
|
|||||||
PDB_GsiSerializeSymbolsTask *task = raw_task;
|
PDB_GsiSerializeSymbolsTask *task = raw_task;
|
||||||
CV_SymbolList *bucket_list = &task->bucket_arr[bucket_idx];
|
CV_SymbolList *bucket_list = &task->bucket_arr[bucket_idx];
|
||||||
for (CV_SymbolNode *node = bucket_list->first; node != 0; node = node->next) {
|
for (CV_SymbolNode *node = bucket_list->first; node != 0; node = node->next) {
|
||||||
task->bucket_size_arr[bucket_idx] += cv_compute_symbol_record_size(&node->data, task->symbol_align);
|
task->bucket_size_arr[bucket_idx] += cv_size_from_symbol(&node->data, task->symbol_align);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2308,7 +2308,7 @@ THREAD_POOL_TASK_FUNC(gsi_serialize_pub32)
|
|||||||
sr->offset = buffer_cursor;
|
sr->offset = buffer_cursor;
|
||||||
|
|
||||||
// serialize symbol
|
// serialize symbol
|
||||||
U64 serial_size = cv_serialize_symbol_to_buffer(buffer, buffer_cursor, buffer_size, symbol, task->symbol_align);
|
U64 serial_size = cv_write_symbol(buffer, buffer_cursor, buffer_size, symbol, task->symbol_align);
|
||||||
|
|
||||||
// advance
|
// advance
|
||||||
sort_idx += 1;
|
sort_idx += 1;
|
||||||
@@ -2347,7 +2347,7 @@ THREAD_POOL_TASK_FUNC(gsi_serialize_symbols_task)
|
|||||||
sr->offset = buffer_cursor;
|
sr->offset = buffer_cursor;
|
||||||
|
|
||||||
// serialize symbol
|
// serialize symbol
|
||||||
U64 serial_size = cv_serialize_symbol_to_buffer(buffer, buffer_cursor, buffer_size, symbol, task->symbol_align);
|
U64 serial_size = cv_write_symbol(buffer, buffer_cursor, buffer_size, symbol, task->symbol_align);
|
||||||
|
|
||||||
// advance
|
// advance
|
||||||
sort_idx += 1;
|
sort_idx += 1;
|
||||||
|
|||||||
@@ -2468,7 +2468,7 @@ cv_format_debug_sections(Arena *arena, String8List *out, String8 indent, String8
|
|||||||
String8 raw_sect = str8_substr(raw_image, sect_frange);
|
String8 raw_sect = str8_substr(raw_image, sect_frange);
|
||||||
if (str8_match_lit(".debug$S", sect_name, 0)) {
|
if (str8_match_lit(".debug$S", sect_name, 0)) {
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
CV_DebugS debug_s = cv_parse_debug_s(scratch.arena, raw_sect);
|
CV_DebugS debug_s = cv_debug_s_from_data(scratch.arena, raw_sect);
|
||||||
for (String8Node *string_n = debug_s.data_list[CV_C13SubSectionIdxKind_Symbols].first;
|
for (String8Node *string_n = debug_s.data_list[CV_C13SubSectionIdxKind_Symbols].first;
|
||||||
string_n != 0 && keep_parsing; string_n = string_n->next) {
|
string_n != 0 && keep_parsing; string_n = string_n->next) {
|
||||||
Temp temp = temp_begin(scratch.arena);
|
Temp temp = temp_begin(scratch.arena);
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ entry_point(CmdLine *cmdl)
|
|||||||
String8 c13_data = pdb_data_from_unit_range(msf, comp_unit, PDB_DbiCompUnitRange_C13);
|
String8 c13_data = pdb_data_from_unit_range(msf, comp_unit, PDB_DbiCompUnitRange_C13);
|
||||||
|
|
||||||
// parse $$
|
// parse $$
|
||||||
CV_DebugS debug_s = cv_parse_debug_s_c13(arena, c13_data);
|
CV_DebugS debug_s = cv_debug_s_from_data_c13(arena, c13_data);
|
||||||
|
|
||||||
// find $$FILE_CKSMS
|
// find $$FILE_CKSMS
|
||||||
String8 file_chksms = cv_file_chksms_from_debug_s(debug_s);
|
String8 file_chksms = cv_file_chksms_from_debug_s(debug_s);
|
||||||
|
|||||||
Reference in New Issue
Block a user