forked from M-Labs/nac3
nac3core: add location debug info
This commit is contained in:
parent
4850df7874
commit
7c5e617e90
@ -557,6 +557,7 @@ pub fn gen_func_impl<
|
||||
context.create_type_attribute(Attribute::get_named_enum_kind_id("sret"),
|
||||
ret_type.unwrap().as_any_type_enum()));
|
||||
}
|
||||
|
||||
{
|
||||
let ditype = debug_info_builder.dibuilder.create_basic_type(
|
||||
"_",
|
||||
@ -572,7 +573,7 @@ pub fn gen_func_impl<
|
||||
);
|
||||
let func_scope: DISubprogram<'_> = debug_info_builder.dibuilder.create_function(
|
||||
/* scope */ debug_info_builder.compile_unit.as_debug_info_scope(),
|
||||
/* func name */ "main",
|
||||
/* func name */ symbol,
|
||||
/* linkage_name */ None,
|
||||
/* file */ debug_info_builder.compile_unit.get_file(),
|
||||
/* line_no */ 0,
|
||||
|
@ -12,6 +12,7 @@ use crate::{
|
||||
use inkwell::{
|
||||
attributes::{Attribute, AttributeLoc},
|
||||
basic_block::BasicBlock,
|
||||
debug_info::AsDIScope,
|
||||
types::BasicTypeEnum,
|
||||
values::{BasicValue, BasicValueEnum, FunctionValue, PointerValue},
|
||||
IntPredicate::EQ,
|
||||
@ -989,6 +990,24 @@ pub fn gen_stmt<'ctx, 'a, G: CodeGenerator>(
|
||||
stmt: &Stmt<Option<Type>>,
|
||||
) -> Result<(), String> {
|
||||
ctx.current_loc = stmt.location;
|
||||
|
||||
let current_fn = ctx.builder.get_insert_block().unwrap().get_parent().unwrap();
|
||||
let lexical_block = ctx.debug_info_builder.dibuilder.create_lexical_block(
|
||||
/* scope */ current_fn.get_subprogram().unwrap().as_debug_info_scope(),
|
||||
/* file */ ctx.debug_info_builder.compile_unit.get_file(),
|
||||
/* line_no */ ctx.current_loc.row as u32,
|
||||
/* column_no */ ctx.current_loc.column as u32,
|
||||
);
|
||||
|
||||
let loc = ctx.debug_info_builder.dibuilder.create_debug_location(
|
||||
ctx.ctx,
|
||||
/* line */ ctx.current_loc.row as u32,
|
||||
/* column_no */ ctx.current_loc.column as u32,
|
||||
/* current_scope */ lexical_block.as_debug_info_scope(),
|
||||
/* inlined_at */ None
|
||||
);
|
||||
ctx.builder.set_current_debug_location(ctx.ctx, loc);
|
||||
|
||||
match &stmt.node {
|
||||
StmtKind::Pass { .. } => {}
|
||||
StmtKind::Expr { value, .. } => {
|
||||
|
Loading…
Reference in New Issue
Block a user