libtcc: Activate DWARF debug infos with tcc -gdwarf ...

This fixes the bug that "tcc -gdwarf ..."
still creates the stab debug infos,
when tcc was build without using DWARF debug infos by default
(configure option: --dwarf=x)

--
Regards ... Detlef
This commit is contained in:
Detlef Riekenberg 2022-09-01 15:55:56 +02:00
parent 2acf65f7e6
commit c51236eee7
2 changed files with 12 additions and 3 deletions

View File

@ -1868,8 +1868,9 @@ reparse:
case TCC_OPTION_g:
s->do_debug = 1;
s->dwarf = DWARF_VERSION;
if (strstart("dwarf-", &optarg))
s->dwarf = atoi(optarg);
if (strstart("dwarf", &optarg))
s->dwarf = (*optarg) ? (0 - atoi(optarg)) : DEFAULT_DWARF_VERSION;
break;
case TCC_OPTION_c:
x = TCC_OUTPUT_OBJ;

8
tcc.h
View File

@ -1815,10 +1815,18 @@ ST_FUNC void tcc_tcov_reset_ind(TCCState *s1);
#define dwarf_str_section s1->dwarf_str_section
#define dwarf_line_str_section s1->dwarf_line_str_section
/* default dwarf version for "-g". use 0 to emit stab debug infos */
#ifndef DWARF_VERSION
# define DWARF_VERSION 0
#endif
/* default dwarf version for "-gdwarf" */
#ifdef TCC_TARGET_MACHO
# define DEFAULT_DWARF_VERSION 2
#else
# define DEFAULT_DWARF_VERSION 5
#endif
#if defined TCC_TARGET_PE
# define R_DATA_32DW 'Z' /* fake code to avoid DLL relocs */
#elif defined TCC_TARGET_X86_64