aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrischka <grischka>2010-09-15 13:43:25 +0200
committergrischka <grischka>2011-07-14 19:11:11 +0200
commit08083ddb2141725baff51787b1a00d1eb7037269 (patch)
tree5f92c95cf606266dc107a07c25f39efada54a888
parentd59bd8be8e1365b428167bbbf8a7f217f64795a5 (diff)
downloadtinycc-08083ddb2141725baff51787b1a00d1eb7037269.tar.gz
tinycc-08083ddb2141725baff51787b1a00d1eb7037269.tar.bz2
tccrun: win32: improve rt_get_caller_pc
-rw-r--r--tccrun.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/tccrun.c b/tccrun.c
index 224d063..16e8acb 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;i<level;i++) {
+#ifdef _WIN64
+ pc = uc->Rip;
+ fp = uc->Rbp;
+#else
+ pc = uc->Eip;
+ fp = uc->Ebp;
+#endif
+ if (level > 0) {
+ for(i=1;i<level;i++) {
/* XXX: check address validity with program info */
if (fp <= 0x1000 || fp >= 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 */
/* ------------------------------------------------------------- */