From 7cc1cc388170a0e7bf62025463c4fcd134c1906c Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Sun, 4 Dec 2022 07:19:48 +0100 Subject: [PATCH] Fix for lldb usage lldb does not like function end and next function start at same pc --- tccdbg.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tccdbg.c b/tccdbg.c index 85d70865..3f74d70a 100644 --- a/tccdbg.c +++ b/tccdbg.c @@ -971,7 +971,6 @@ ST_FUNC void tcc_debug_end(TCCState *s1) tcc_free(dwarf_line.filename_table[i].name); tcc_free(dwarf_line.filename_table); - dwarf_line_op(s1, DW_LNS_negate_stmt); dwarf_line_op(s1, 0); // extended dwarf_uleb128_op(s1, 1); // extended size dwarf_line_op(s1, DW_LNE_end_sequence); @@ -1828,9 +1827,6 @@ ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym) if (s1->dwarf) { tcc_debug_line(s1); - dwarf_line_op(s1, DW_LNS_negate_stmt); - dwarf_line_op(s1, DW_LNS_copy); - dwarf_line_op(s1, DW_LNS_negate_stmt); dwarf_info.func = sym; dwarf_info.line = file->line_num; if (s1->do_backtrace) { @@ -1868,9 +1864,15 @@ ST_FUNC void tcc_debug_prolog_epilog(TCCState *s1, int value) /* put function size */ ST_FUNC void tcc_debug_funcend(TCCState *s1, int size) { + /* lldb does not like function end and next function start at same pc */ + int min_instr_len; + if (!s1->do_debug) return; + min_instr_len = dwarf_line.last_pc == ind ? 0 : DWARF_MIN_INSTR_LEN; + ind -= min_instr_len; tcc_debug_line(s1); + ind += min_instr_len; tcc_debug_stabn(s1, N_RBRAC, size); if (s1->dwarf) { int func_sib = 0;