mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Static array debug info. Temporary dynamic array debug info (pointer to data, no len/cap info provided yet).
This commit is contained in:
+41
@@ -585,6 +585,7 @@ struct irDebugInfo {
|
|||||||
Array<irDebugInfo *> param_types;
|
Array<irDebugInfo *> param_types;
|
||||||
} ProcType; // TODO(lachsinc): Unused?
|
} ProcType; // TODO(lachsinc): Unused?
|
||||||
struct {
|
struct {
|
||||||
|
// TODO(lachsinc): Do derived types even need scope/file/line etc. info?
|
||||||
irDebugEncoding tag;
|
irDebugEncoding tag;
|
||||||
String name;
|
String name;
|
||||||
irDebugInfo * scope;
|
irDebugInfo * scope;
|
||||||
@@ -606,6 +607,7 @@ struct irDebugInfo {
|
|||||||
i32 size;
|
i32 size;
|
||||||
i32 align;
|
i32 align;
|
||||||
Array<irDebugInfo *> elements;
|
Array<irDebugInfo *> elements;
|
||||||
|
i32 array_count; // TODO(lach): We could define a new !DISubrange and place ptr to it inside above elements array instead.
|
||||||
} CompositeType;
|
} CompositeType;
|
||||||
struct {
|
struct {
|
||||||
String name;
|
String name;
|
||||||
@@ -1752,6 +1754,45 @@ irDebugInfo *ir_add_debug_info_type(irModule *module, irDebugInfo *scope, Entity
|
|||||||
return di;
|
return di;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(lachsinc): Not sure if correct.. Also cleanup
|
||||||
|
// NOTE(lachsinc): For now dynamic arrays are just a pointer to their data.
|
||||||
|
// We could get fancy and use a composite type along with
|
||||||
|
// DW_TAG_class_type / template debug stuff eventually.
|
||||||
|
if (is_type_dynamic_array(type)) {
|
||||||
|
irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_DerivedType);
|
||||||
|
|
||||||
|
auto elem_type = type->DynamicArray.elem;
|
||||||
|
|
||||||
|
di->DerivedType.name = str_lit("dynamic_array_todo");
|
||||||
|
di->DerivedType.tag = irDebugBasicEncoding_pointer_type;
|
||||||
|
di->DerivedType.scope = scope;
|
||||||
|
di->DerivedType.file = file;
|
||||||
|
di->DerivedType.pos = e->token.pos;
|
||||||
|
di->DerivedType.base_type = ir_add_debug_info_type(module, scope, e, elem_type, file);
|
||||||
|
di->DerivedType.size = 64; // TODO(lachsinc): HACK
|
||||||
|
di->DerivedType.align = 0; // TODO(lachsinc): HACK
|
||||||
|
|
||||||
|
GB_ASSERT(base->kind != Type_Named);
|
||||||
|
map_set(&module->debug_info, hash_type(type), di);
|
||||||
|
|
||||||
|
return di;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_type_array(type)) {
|
||||||
|
|
||||||
|
irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_CompositeType);
|
||||||
|
di->CompositeType.size = 8*cast(i32)type_size_of(type); // TODO(lachsinc): Confirm correct array sizing. llvm expects size in bits!
|
||||||
|
di->CompositeType.align = 8*cast(i32)type_align_of(type);
|
||||||
|
di->CompositeType.base_type = ir_add_debug_info_type(module, scope, e, type->Array.elem, file);
|
||||||
|
di->CompositeType.tag = irDebugBasicEncoding_array_type;
|
||||||
|
di->CompositeType.array_count = (i32)type->Array.count;
|
||||||
|
|
||||||
|
GB_ASSERT(base->kind != Type_Named);
|
||||||
|
map_set(&module->debug_info, hash_type(type), di);
|
||||||
|
|
||||||
|
return di;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// TODO(lachsinc): HACK For now any remaining types interpreted as a rawptr.
|
// TODO(lachsinc): HACK For now any remaining types interpreted as a rawptr.
|
||||||
//
|
//
|
||||||
|
|||||||
+46
-28
@@ -2034,13 +2034,16 @@ void print_llvm_ir(irGen *ir) {
|
|||||||
"name: \"%.*s\""
|
"name: \"%.*s\""
|
||||||
", baseType: !%d"
|
", baseType: !%d"
|
||||||
", size: %d"
|
", size: %d"
|
||||||
", align: %d"
|
|
||||||
", tag: ",
|
", tag: ",
|
||||||
LIT(di->DerivedType.name),
|
LIT(di->DerivedType.name),
|
||||||
di->DerivedType.base_type->id,
|
di->DerivedType.base_type->id,
|
||||||
di->DerivedType.size,
|
di->DerivedType.size,
|
||||||
di->DerivedType.align);
|
di->DerivedType.align);
|
||||||
ir_print_debug_encoding(f, irDebugInfo_DerivedType, di->DerivedType.tag);
|
ir_print_debug_encoding(f, irDebugInfo_DerivedType, di->DerivedType.tag);
|
||||||
|
if (di->DerivedType.align > 0) {
|
||||||
|
ir_fprintf(f, ", align: %d",
|
||||||
|
di->DerivedType.align);
|
||||||
|
}
|
||||||
if (di->DerivedType.offset > 0) {
|
if (di->DerivedType.offset > 0) {
|
||||||
ir_fprintf(f, ", offset: %d",
|
ir_fprintf(f, ", offset: %d",
|
||||||
di->DerivedType.offset);
|
di->DerivedType.offset);
|
||||||
@@ -2048,35 +2051,50 @@ void print_llvm_ir(irGen *ir) {
|
|||||||
ir_write_byte(f, ')');
|
ir_write_byte(f, ')');
|
||||||
break;
|
break;
|
||||||
case irDebugInfo_CompositeType: {
|
case irDebugInfo_CompositeType: {
|
||||||
ir_fprintf(f, "!DICompositeType("
|
if (di->CompositeType.tag == irDebugBasicEncoding_array_type) {
|
||||||
"name: \"%.*s\""
|
GB_ASSERT(di->CompositeType.base_type);
|
||||||
", scope: !%d"
|
ir_fprintf(f, "!DICompositeType("
|
||||||
", file: !%d"
|
"tag: DW_TAG_array_type"
|
||||||
", line: %td"
|
", size: %d"
|
||||||
", size: %d"
|
", align: %d"
|
||||||
", align: %d"
|
", baseType: !%d"
|
||||||
", tag: ",
|
", elements: !{!DISubrange(count: %d)}"
|
||||||
LIT(di->CompositeType.name),
|
")",
|
||||||
di->CompositeType.scope->id,
|
di->CompositeType.size,
|
||||||
di->CompositeType.file->id,
|
di->CompositeType.align,
|
||||||
di->CompositeType.pos.line,
|
di->CompositeType.base_type->id,
|
||||||
di->CompositeType.size,
|
di->CompositeType.array_count);
|
||||||
di->CompositeType.align);
|
} else {
|
||||||
ir_print_debug_encoding(f, irDebugInfo_CompositeType, di->CompositeType.tag);
|
ir_fprintf(f, "!DICompositeType("
|
||||||
if (di->CompositeType.base_type) {
|
"name: \"%.*s\""
|
||||||
GB_ASSERT(di->CompositeType.tag == irDebugBasicEncoding_enumeration_type);
|
", scope: !%d"
|
||||||
ir_fprintf(f, ", baseType: !%d", di->CompositeType.base_type->id);
|
", file: !%d"
|
||||||
}
|
", line: %td"
|
||||||
if (di->CompositeType.elements.count > 0) {
|
", size: %d"
|
||||||
ir_write_str_lit(f, ", elements: !{");
|
", align: %d"
|
||||||
for_array(element_index, di->CompositeType.elements) {
|
", tag: ",
|
||||||
ir_fprintf(f, "%s!%d",
|
LIT(di->CompositeType.name),
|
||||||
element_index > 0 ? ", " : "",
|
di->CompositeType.scope->id,
|
||||||
di->CompositeType.elements[element_index]->id);
|
di->CompositeType.file->id,
|
||||||
|
di->CompositeType.pos.line,
|
||||||
|
di->CompositeType.size,
|
||||||
|
di->CompositeType.align);
|
||||||
|
ir_print_debug_encoding(f, irDebugInfo_CompositeType, di->CompositeType.tag);
|
||||||
|
if (di->CompositeType.base_type) {
|
||||||
|
GB_ASSERT(di->CompositeType.tag == irDebugBasicEncoding_enumeration_type);
|
||||||
|
ir_fprintf(f, ", baseType: !%d", di->CompositeType.base_type->id);
|
||||||
}
|
}
|
||||||
ir_write_byte(f, '}');
|
if (di->CompositeType.elements.count > 0) {
|
||||||
|
ir_write_str_lit(f, ", elements: !{");
|
||||||
|
for_array(element_index, di->CompositeType.elements) {
|
||||||
|
ir_fprintf(f, "%s!%d",
|
||||||
|
element_index > 0 ? ", " : "",
|
||||||
|
di->CompositeType.elements[element_index]->id);
|
||||||
|
}
|
||||||
|
ir_write_byte(f, '}');
|
||||||
|
}
|
||||||
|
ir_write_byte(f, ')');
|
||||||
}
|
}
|
||||||
ir_write_byte(f, ')');
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case irDebugInfo_Enumerator: {
|
case irDebugInfo_Enumerator: {
|
||||||
|
|||||||
Reference in New Issue
Block a user