forked from Mirrors/tinycc
tccrun: win32: improve rt_get_caller_pc
parent
d59bd8be8e
commit
08083ddb21
31
tccrun.c
31
tccrun.c
|
@ -612,36 +612,31 @@ static void win64_add_function_table(TCCState *s1)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define Eip Rip
|
|
||||||
#define Ebp Rbp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* return the PC at frame level 'level'. Return non zero if not found */
|
/* return the PC at frame level 'level'. Return non zero if not found */
|
||||||
static int rt_get_caller_pc(uplong *paddr, CONTEXT *uc, int level)
|
static int rt_get_caller_pc(uplong *paddr, CONTEXT *uc, int level)
|
||||||
{
|
{
|
||||||
uplong fp;
|
uplong fp, pc;
|
||||||
int i;
|
int i;
|
||||||
|
#ifdef _WIN64
|
||||||
if (level == 0) {
|
pc = uc->Rip;
|
||||||
*paddr = uc->Eip;
|
fp = uc->Rbp;
|
||||||
return 0;
|
#else
|
||||||
} else {
|
pc = uc->Eip;
|
||||||
fp = uc->Ebp;
|
fp = uc->Ebp;
|
||||||
for(i=1;i<level;i++) {
|
#endif
|
||||||
|
if (level > 0) {
|
||||||
|
for(i=1;i<level;i++) {
|
||||||
/* XXX: check address validity with program info */
|
/* XXX: check address validity with program info */
|
||||||
if (fp <= 0x1000 || fp >= 0xc0000000)
|
if (fp <= 0x1000 || fp >= 0xc0000000)
|
||||||
return -1;
|
return -1;
|
||||||
fp = ((uplong*)fp)[0];
|
fp = ((uplong*)fp)[0];
|
||||||
}
|
}
|
||||||
*paddr = ((uplong*)fp)[1];
|
pc = ((uplong*)fp)[1];
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
*paddr = pc;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef Eip
|
|
||||||
#undef Ebp
|
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
#endif /* CONFIG_TCC_BACKTRACE */
|
#endif /* CONFIG_TCC_BACKTRACE */
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in New Issue