mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Fix -debug crash on windows caused by missing debug info for files.
This commit is contained in:
+12
-1
@@ -10028,7 +10028,11 @@ void ir_init_module(irModule *m, Checker *c) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_CompileUnit);
|
irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_CompileUnit);
|
||||||
di->CompileUnit.file = m->info->files.entries[0].value; // Zeroth is the init file
|
|
||||||
|
GB_ASSERT(m->info->files.entries.count > 0);
|
||||||
|
AstFile *file = m->info->files.entries[0].value;
|
||||||
|
|
||||||
|
di->CompileUnit.file = file; // Zeroth is the init file
|
||||||
di->CompileUnit.producer = str_lit("odin");
|
di->CompileUnit.producer = str_lit("odin");
|
||||||
|
|
||||||
map_set(&m->debug_info, hash_pointer(m), di);
|
map_set(&m->debug_info, hash_pointer(m), di);
|
||||||
@@ -10047,6 +10051,13 @@ void ir_init_module(irModule *m, Checker *c) {
|
|||||||
|
|
||||||
array_init(&m->debug_location_stack, heap_allocator()); // TODO(lachsinc): ir_allocator() ??
|
array_init(&m->debug_location_stack, heap_allocator()); // TODO(lachsinc): ir_allocator() ??
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
for_array(i, m->info->files.entries) {
|
||||||
|
AstFile *file = m->info->files.entries[i].value;
|
||||||
|
ir_add_debug_info_file(m, file);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ir_destroy_module(irModule *m) {
|
void ir_destroy_module(irModule *m) {
|
||||||
|
|||||||
+4
-2
@@ -2450,11 +2450,13 @@ void print_llvm_ir(irGen *ir) {
|
|||||||
|
|
||||||
for_array(di_index, m->debug_info.entries) {
|
for_array(di_index, m->debug_info.entries) {
|
||||||
irDebugInfo *di = m->debug_info.entries[di_index].value;
|
irDebugInfo *di = m->debug_info.entries[di_index].value;
|
||||||
|
GB_ASSERT_MSG(di != nullptr, "Invalid irDebugInfo");
|
||||||
ir_fprintf(f, "!%d = ", di->id);
|
ir_fprintf(f, "!%d = ", di->id);
|
||||||
|
|
||||||
switch (di->kind) {
|
switch (di->kind) {
|
||||||
case irDebugInfo_CompileUnit: {
|
case irDebugInfo_CompileUnit: {
|
||||||
irDebugInfo *file = *map_get(&m->debug_info, hash_pointer(di->CompileUnit.file));
|
irDebugInfo **found = map_get(&m->debug_info, hash_pointer(di->CompileUnit.file));
|
||||||
|
GB_ASSERT_MSG(found != nullptr, "Missing debug info for: %.*s\n", LIT(di->CompileUnit.file->fullpath));
|
||||||
|
irDebugInfo *file = *found;
|
||||||
ir_fprintf(f,
|
ir_fprintf(f,
|
||||||
"distinct !DICompileUnit("
|
"distinct !DICompileUnit("
|
||||||
"language: DW_LANG_C_plus_plus" // Is this good enough?
|
"language: DW_LANG_C_plus_plus" // Is this good enough?
|
||||||
|
|||||||
Reference in New Issue
Block a user