1
0
Fork 0

tcc -g1 : small debug info (lines/functions only)

This commit is contained in:
grischka 2023-09-06 22:17:03 +02:00
parent 452045422b
commit 8c5fe87665
4 changed files with 24 additions and 15 deletions

View File

@ -84,7 +84,7 @@ $(X)%.o : %.S
$(TOP)/%.o : %.c
$S$(XCC) -c $< -o $@ $(XFLAGS)
$(TOP)/bcheck.o : XFLAGS += -g $(if $(CONFIG_musl),-DTCC_MUSL)
$(TOP)/bcheck.o : XFLAGS += -bt $(if $(CONFIG_musl),-DTCC_MUSL)
$(TOP)/bt-exe.o : $(TOP)/tccrun.c
$(X)crt1w.o : crt1.c

View File

@ -1959,29 +1959,33 @@ dorun:
break;
#ifdef CONFIG_TCC_BACKTRACE
case TCC_OPTION_bt:
s->rt_num_callers = atoi(optarg);
s->rt_num_callers = atoi(optarg); /* zero = default (6) */
enable_backtrace:
s->do_backtrace = 1;
s->do_debug = 1;
s->dwarf = DWARF_VERSION;
break;
#endif
#ifdef CONFIG_TCC_BCHECK
case TCC_OPTION_b:
s->do_bounds_check = 1;
s->do_backtrace = 1;
s->do_debug = 1;
s->dwarf = DWARF_VERSION;
break;
goto enable_backtrace;
#endif
#endif
case TCC_OPTION_g:
s->do_debug = 1;
s->do_debug = 2;
s->dwarf = DWARF_VERSION;
if (strstart("dwarf", &optarg))
if (strstart("dwarf", &optarg)) {
s->dwarf = (*optarg) ? (0 - atoi(optarg)) : DEFAULT_DWARF_VERSION;
} else if (isnum(*optarg)) {
x = *optarg - '0';
/* -g0 = no info, -g1 = lines/functions only, -g2 = full info */
if (x <= 2)
s->do_debug = x;
#ifdef TCC_TARGET_PE
else if (0 == strcmp(".pdb", optarg))
} else if (0 == strcmp(".pdb", optarg)) {
s->dwarf = 5, s->do_debug |= 16;
#endif
}
break;
case TCC_OPTION_c:
x = TCC_OUTPUT_OBJ;

View File

@ -1245,8 +1245,9 @@ ST_FUNC void tcc_debug_fix_anon(TCCState *s1, CType *t)
{
int i, j, debug_type;
if (!s1->do_debug || !s1->dwarf || debug_info)
if (!(s1->do_debug & 2) || !s1->dwarf || debug_info)
return;
if ((t->t & VT_BTYPE) == VT_STRUCT && t->ref->c != -1)
for (i = 0; i < n_debug_anon_hash; i++)
if (t->ref == debug_anon_hash[i].type) {
@ -1789,8 +1790,10 @@ static void tcc_debug_finish (TCCState *s1, struct _debug_info *cur)
ST_FUNC void tcc_add_debug_info(TCCState *s1, int param, Sym *s, Sym *e)
{
CString debug_str;
if (!s1->do_debug)
if (!(s1->do_debug & 2))
return;
cstr_new (&debug_str);
for (; s != e; s = s->prev) {
if (!s->v || (s->r & VT_VALMASK) != VT_LOCAL)
@ -1931,8 +1934,9 @@ ST_FUNC void tcc_debug_funcend(TCCState *s1, int size)
ST_FUNC void tcc_debug_extern_sym(TCCState *s1, Sym *sym, int sh_num, int sym_bind, int sym_type)
{
if (!s1->do_debug)
if (!(s1->do_debug & 2))
return;
if (sym_type == STT_FUNC || sym->v >= SYM_FIRST_ANOM)
return;
if (s1->dwarf) {
@ -1984,8 +1988,9 @@ ST_FUNC void tcc_debug_extern_sym(TCCState *s1, Sym *sym, int sh_num, int sym_bi
ST_FUNC void tcc_debug_typedef(TCCState *s1, Sym *sym)
{
if (!s1->do_debug)
if (!(s1->do_debug & 2))
return;
if (s1->dwarf) {
int debug_type;

View File

@ -156,7 +156,7 @@ call :makelib %T%
@if errorlevel 1 goto :the_end
@if exist %PX%-tcc.exe call :makelib %TX%
@if errorlevel 1 goto :the_end
.\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -g
.\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -bt
.\tcc -m%T% -c ../lib/bt-exe.c -o lib/bt-exe.o
.\tcc -m%T% -c ../lib/bt-log.c -o lib/bt-log.o
.\tcc -m%T% -c ../lib/bt-dll.c -o lib/bt-dll.o