enable backtrace only when it's supported
This commit is contained in:
parent
859da934e0
commit
e9e89ad699
1 changed files with 15 additions and 8 deletions
23
tcc.c
23
tcc.c
|
@ -112,6 +112,10 @@
|
||||||
#define TCC_TARGET_COFF
|
#define TCC_TARGET_COFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && !defined(CONFIG_TCCBOOT)
|
||||||
|
#define CONFIG_TCC_BACKTRACE
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define false 0
|
#define false 0
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
|
@ -431,8 +435,10 @@ static int gnu_ext = 1;
|
||||||
static int tcc_ext = 1;
|
static int tcc_ext = 1;
|
||||||
|
|
||||||
/* max number of callers shown if error */
|
/* max number of callers shown if error */
|
||||||
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
static int num_callers = 6;
|
static int num_callers = 6;
|
||||||
static const char **rt_bound_error_msg;
|
static const char **rt_bound_error_msg;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* XXX: get rid of this ASAP */
|
/* XXX: get rid of this ASAP */
|
||||||
static struct TCCState *tcc_state;
|
static struct TCCState *tcc_state;
|
||||||
|
@ -10043,6 +10049,7 @@ static void asm_global_instr(void)
|
||||||
#include "tccpe.c"
|
#include "tccpe.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
/* print the position in the source file of PC value 'pc' by reading
|
/* print the position in the source file of PC value 'pc' by reading
|
||||||
the stabs debug information */
|
the stabs debug information */
|
||||||
static void rt_printline(unsigned long wanted_pc)
|
static void rt_printline(unsigned long wanted_pc)
|
||||||
|
@ -10165,10 +10172,7 @@ static void rt_printline(unsigned long wanted_pc)
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(CONFIG_TCCBOOT)
|
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
|
|
||||||
/* fix for glibc 2.1 */
|
/* fix for glibc 2.1 */
|
||||||
#ifndef REG_EIP
|
#ifndef REG_EIP
|
||||||
#define REG_EIP EIP
|
#define REG_EIP EIP
|
||||||
|
@ -10234,9 +10238,7 @@ static int rt_get_caller_pc(unsigned long *paddr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#warning add arch specific rt_get_caller_pc()
|
#warning add arch specific rt_get_caller_pc()
|
||||||
|
|
||||||
static int rt_get_caller_pc(unsigned long *paddr,
|
static int rt_get_caller_pc(unsigned long *paddr,
|
||||||
ucontext_t *uc, int level)
|
ucontext_t *uc, int level)
|
||||||
{
|
{
|
||||||
|
@ -10304,6 +10306,7 @@ static void sig_error(int signum, siginfo_t *siginf, void *puc)
|
||||||
}
|
}
|
||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* copy code into memory passed in by the caller and do all relocations
|
/* copy code into memory passed in by the caller and do all relocations
|
||||||
|
@ -10401,9 +10404,7 @@ int tcc_run(TCCState *s1, int argc, char **argv)
|
||||||
prog_main = tcc_get_symbol_err(s1, "main");
|
prog_main = tcc_get_symbol_err(s1, "main");
|
||||||
|
|
||||||
if (do_debug) {
|
if (do_debug) {
|
||||||
#if defined(_WIN32) || defined(CONFIG_TCCBOOT)
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
error("debug mode currently not available for Windows");
|
|
||||||
#else
|
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
/* install TCC signal handlers to print debug info on fatal
|
/* install TCC signal handlers to print debug info on fatal
|
||||||
runtime errors */
|
runtime errors */
|
||||||
|
@ -10415,6 +10416,8 @@ int tcc_run(TCCState *s1, int argc, char **argv)
|
||||||
sigaction(SIGSEGV, &sigact, NULL);
|
sigaction(SIGSEGV, &sigact, NULL);
|
||||||
sigaction(SIGBUS, &sigact, NULL);
|
sigaction(SIGBUS, &sigact, NULL);
|
||||||
sigaction(SIGABRT, &sigact, NULL);
|
sigaction(SIGABRT, &sigact, NULL);
|
||||||
|
#else
|
||||||
|
error("debug mode not available");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11023,7 +11026,9 @@ void help(void)
|
||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
" -b compile with built-in memory and bounds checker (implies -g)\n"
|
" -b compile with built-in memory and bounds checker (implies -g)\n"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
" -bt N show N callers in stack traces\n"
|
" -bt N show N callers in stack traces\n"
|
||||||
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11232,9 +11237,11 @@ int parse_args(TCCState *s, int argc, char **argv)
|
||||||
case TCC_OPTION_bench:
|
case TCC_OPTION_bench:
|
||||||
do_bench = 1;
|
do_bench = 1;
|
||||||
break;
|
break;
|
||||||
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
case TCC_OPTION_bt:
|
case TCC_OPTION_bt:
|
||||||
num_callers = atoi(optarg);
|
num_callers = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
case TCC_OPTION_b:
|
case TCC_OPTION_b:
|
||||||
do_bounds_check = 1;
|
do_bounds_check = 1;
|
||||||
|
|
Loading…
Reference in a new issue