Skip to content

Commit 9dae796

Browse files
committed
translate-c: set up debug scope for translated functions
1 parent 79c2ceb commit 9dae796

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/codegen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,10 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
590590
bool is_optimized = g->build_mode != BuildModeDebug;
591591
bool is_internal_linkage = (fn_table_entry->body_node != nullptr &&
592592
fn_table_entry->export_list.length == 0);
593+
ZigLLVMDIScope *fn_di_scope = get_di_scope(g, scope->parent);
594+
assert(fn_di_scope != nullptr);
593595
ZigLLVMDISubprogram *subprogram = ZigLLVMCreateFunction(g->dbuilder,
594-
get_di_scope(g, scope->parent), buf_ptr(&fn_table_entry->symbol_name), "",
596+
fn_di_scope, buf_ptr(&fn_table_entry->symbol_name), "",
595597
import->di_file, line_number,
596598
fn_table_entry->type_entry->di_type, is_internal_linkage,
597599
is_definition, scope_line, flags, is_optimized, nullptr);

src/ir.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14051,6 +14051,8 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc
1405114051
child_import->package = new_anonymous_package();
1405214052
child_import->package->package_table.put(buf_create_from_str("builtin"), ira->codegen->compile_var_package);
1405314053
child_import->package->package_table.put(buf_create_from_str("std"), ira->codegen->std_package);
14054+
child_import->di_file = ZigLLVMCreateFile(ira->codegen->dbuilder,
14055+
buf_ptr(buf_create_from_str("cimport.h")), buf_ptr(buf_create_from_str(".")));
1405414056

1405514057
ZigList<ErrorMsg *> errors = {0};
1405614058

0 commit comments

Comments
 (0)