diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 97354e0f6..b36716971 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -958,11 +958,15 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) { if hash do write_byte(fi.buf, '\n'); - for _, i in b.names { - if !hash && i > 0 do write_string(fi.buf, ", "); + field_count := -1; + for name, i in b.names { + // if len(name) > 0 && name[0] == '_' do continue; + field_count += 1; + + if !hash && field_count > 0 do write_string(fi.buf, ", "); if hash do for in 0..fi.indent-1 do write_byte(fi.buf, '\t'); - write_string(fi.buf, b.names[i]); + write_string(fi.buf, name); write_string(fi.buf, " = "); if t := b.types[i]; types.is_any(t) { diff --git a/src/ir.cpp b/src/ir.cpp index 7cfd8e113..6f1637b7a 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -2116,6 +2116,9 @@ irDebugInfo *ir_add_debug_info_proc_type(irModule *module, Type *type) { // gb_max(result_count, 1) because llvm expects explicit "null" return type di->ProcType.types = ir_add_debug_info_array(module, 0, gb_max(result_count, 1) + param_count); + // TODO(bill): Is this even correct?! + irDebugInfo *scope = di; + // Result/return types if (result_count >= 1) { TypeTuple *results_tuple = &type->Proc.results->Tuple; @@ -2125,7 +2128,7 @@ irDebugInfo *ir_add_debug_info_proc_type(irModule *module, Type *type) { continue; } - irDebugInfo *type_di = ir_add_debug_info_type(module, e->type, e, nullptr, nullptr); + irDebugInfo *type_di = ir_add_debug_info_type(module, e->type, e, scope, nullptr); GB_ASSERT_NOT_NULL(type_di); array_add(&di->ProcType.types->DebugInfoArray.elements, type_di); } @@ -2143,7 +2146,7 @@ irDebugInfo *ir_add_debug_info_proc_type(irModule *module, Type *type) { continue; } - irDebugInfo *type_di = ir_add_debug_info_type(module, e->type, e, nullptr, nullptr); + irDebugInfo *type_di = ir_add_debug_info_type(module, e->type, e, scope, nullptr); GB_ASSERT_NOT_NULL(type_di); array_add(&di->ProcType.types->DebugInfoArray.elements, type_di); } @@ -2490,7 +2493,7 @@ irDebugInfo *ir_add_debug_info_global(irModule *module, irValue *v) { // unique for the DIGlobalVariable's hash. map_set(&module->debug_info, hash_pointer(var_di), var_di); - var_di->GlobalVariable.type = ir_add_debug_info_type(module, e->type, nullptr, nullptr, nullptr); + var_di->GlobalVariable.type = ir_add_debug_info_type(module, e->type, nullptr, scope, nullptr); GB_ASSERT_NOT_NULL(var_di->GlobalVariable.type); di->GlobalVariableExpression.var = var_di; @@ -2657,9 +2660,11 @@ void ir_value_set_debug_location(irProcedure *proc, irValue *v) { irModule *m = proc->module; GB_ASSERT(m->debug_location_stack.count > 0); v->loc = *array_end_ptr(&m->debug_location_stack); - if (v->loc == nullptr) { + + if (v->loc == nullptr && proc->entity != nullptr) { // NOTE(lachsinc): Entry point (main()) and runtime_startup are the only ones where null location is considered valid. - GB_ASSERT(proc->is_entry_point || (string_compare(proc->name, str_lit(IR_STARTUP_RUNTIME_PROC_NAME)) == 0)); + GB_ASSERT_MSG(proc->is_entry_point || (string_compare(proc->name, str_lit(IR_STARTUP_RUNTIME_PROC_NAME)) == 0), + "%.*s %p", LIT(proc->name), proc->entity); } } diff --git a/src/ir_print.cpp b/src/ir_print.cpp index aca2fdeac..c8b255d2f 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -227,7 +227,9 @@ bool ir_print_debug_location(irFileBuffer *f, irModule *m, irValue *v) { } } else { irProcedure *proc = v->Instr.block->proc; - GB_ASSERT(proc->is_entry_point || (string_compare(proc->name, str_lit(IR_STARTUP_RUNTIME_PROC_NAME)) == 0)); + if (proc->entity != nullptr) { + GB_ASSERT(proc->is_entry_point || (string_compare(proc->name, str_lit(IR_STARTUP_RUNTIME_PROC_NAME)) == 0)); + } } return false; }