From 08083ddb2141725baff51787b1a00d1eb7037269 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 15 Sep 2010 13:43:25 +0200 Subject: [PATCH] tccrun: win32: improve rt_get_caller_pc --- tccrun.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/tccrun.c b/tccrun.c index 224d0637..16e8acb8 100644 --- a/tccrun.c +++ b/tccrun.c @@ -612,36 +612,31 @@ static void win64_add_function_table(TCCState *s1) } #endif -#ifdef _WIN64 -#define Eip Rip -#define Ebp Rbp -#endif - /* 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) { - uplong fp; + uplong fp, pc; int i; - - if (level == 0) { - *paddr = uc->Eip; - return 0; - } else { - fp = uc->Ebp; - for(i=1;iRip; + fp = uc->Rbp; +#else + pc = uc->Eip; + fp = uc->Ebp; +#endif + if (level > 0) { + for(i=1;i= 0xc0000000) return -1; fp = ((uplong*)fp)[0]; } - *paddr = ((uplong*)fp)[1]; - return 0; + pc = ((uplong*)fp)[1]; } + *paddr = pc; + return 0; } -#undef Eip -#undef Ebp - #endif /* _WIN32 */ #endif /* CONFIG_TCC_BACKTRACE */ /* ------------------------------------------------------------- */ -- 2.11.4.GIT