diff --git a/tcc.h b/tcc.h index 83d8c7e4..0d29822a 100644 --- a/tcc.h +++ b/tcc.h @@ -548,7 +548,8 @@ struct SymAttr { nodecorate : 1, dllimport : 1, addrtaken : 1, - xxxx : 3; /* not used */ + nodebug : 1, + xxxx : 2; /* not used */ }; /* function attributes or temporary attributes for parsing */ diff --git a/tccdbg.c b/tccdbg.c index 9a4b26a2..f63ab4b7 100644 --- a/tccdbg.c +++ b/tccdbg.c @@ -1285,6 +1285,15 @@ static void tcc_debug_remove(TCCState *s1, Sym *t) } } +#define STRUCT_NODEBUG(s) \ + (s->a.nodebug || \ + ((s->v & ~SYM_FIELD) >= SYM_FIRST_ANOM && \ + ((s->type.t & VT_BTYPE) == VT_BYTE || \ + (s->type.t & VT_BTYPE) == VT_BOOL || \ + (s->type.t & VT_BTYPE) == VT_SHORT || \ + (s->type.t & VT_BTYPE) == VT_INT || \ + (s->type.t & VT_BTYPE) == VT_LLONG))) + static void tcc_get_debug_info(TCCState *s1, Sym *s, CString *result) { int type; @@ -1320,9 +1329,10 @@ static void tcc_get_debug_info(TCCState *s1, Sym *s, CString *result) int pos, size, align; t = t->next; + if (STRUCT_NODEBUG(t)) + continue; cstr_printf (&str, "%s:", - (t->v & ~SYM_FIELD) >= SYM_FIRST_ANOM - ? "" : get_tok_str(t->v & ~SYM_FIELD, NULL)); + get_tok_str(t->v & ~SYM_FIELD, NULL)); tcc_get_debug_info (s1, t, &str); if (t->type.t & VT_BITFIELD) { pos = t->c * 8 + BIT_POS(t->type.t); @@ -1430,6 +1440,8 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) i = 0; while (e->next) { e = e->next; + if (STRUCT_NODEBUG(e)) + continue; i++; } pos_type = (int *) tcc_malloc(i * sizeof(int)); @@ -1453,12 +1465,13 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) i = 0; while (e->next) { e = e->next; + if (STRUCT_NODEBUG(e)) + continue; dwarf_data1(dwarf_info_section, e->type.t & VT_BITFIELD ? DWARF_ABBREV_MEMBER_BF : DWARF_ABBREV_MEMBER); dwarf_strp(dwarf_info_section, - (e->v & ~SYM_FIELD) >= SYM_FIRST_ANOM - ? "" : get_tok_str(e->v & ~SYM_FIELD, NULL)); + get_tok_str(e->v & ~SYM_FIELD, NULL)); dwarf_uleb128(dwarf_info_section, dwarf_line.cur_file); dwarf_uleb128(dwarf_info_section, file->line_num); pos_type[i++] = dwarf_info_section->data_offset; @@ -1482,6 +1495,8 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) i = 0; while (e->next) { e = e->next; + if (STRUCT_NODEBUG(e)) + continue; type = tcc_get_dwarf_info(s1, e); tcc_debug_check_anon(s1, e, pos_type[i]); write32le(dwarf_info_section->data + pos_type[i++], diff --git a/tccgen.c b/tccgen.c index 1e028b3c..86ced00c 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1067,6 +1067,7 @@ static void merge_symattr(struct SymAttr *sa, struct SymAttr *sa1) sa->aligned = sa1->aligned; sa->packed |= sa1->packed; sa->weak |= sa1->weak; + sa->nodebug |= sa1->nodebug; if (sa1->visibility != STV_DEFAULT) { int vis = sa->visibility; if (vis == STV_DEFAULT @@ -3823,6 +3824,10 @@ redo: case TOK_WEAK2: ad->a.weak = 1; break; + case TOK_NODEBUG1: + case TOK_NODEBUG2: + ad->a.nodebug = 1; + break; case TOK_UNUSED1: case TOK_UNUSED2: /* currently, no need to handle it because tcc does not diff --git a/tcctok.h b/tcctok.h index 9936d2ef..cfdc60dc 100644 --- a/tcctok.h +++ b/tcctok.h @@ -124,6 +124,8 @@ DEF(TOK_ALIAS2, "__alias__") DEF(TOK_UNUSED1, "unused") DEF(TOK_UNUSED2, "__unused__") + DEF(TOK_NODEBUG1, "nodebug") + DEF(TOK_NODEBUG2, "__nodebug__") DEF(TOK_CDECL1, "cdecl") DEF(TOK_CDECL2, "__cdecl") DEF(TOK_CDECL3, "__cdecl__")