From: Julian Seward Date: Mon, 21 Mar 2005 11:53:38 +0000 (+0000) Subject: handleOneStatement: Derive a value for *instrAddr from the IMark in a X-Git-Tag: svn/VALGRIND_3_0_0~919 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eaae711c64fbb6ba33bb7f84b0f1e4923523b70e;p=thirdparty%2Fvalgrind.git handleOneStatement: Derive a value for *instrAddr from the IMark in a way which is 64-bit clean. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3399 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index b4ec110eb7..159051b3de 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -395,8 +395,17 @@ void handleOneStatement(IRTypeEnv* tyenv, IRBB* bbOut, IRStmt* st, break; case Ist_IMark: - *instrAddr = (Addr)st->Ist.IMark.addr; - tl_assert(*instrAddr == st->Ist.IMark.addr); // XXX: check no overflow + /* st->Ist.IMark.addr is a 64-bit int. ULong_to_Ptr casts this + to the host's native pointer type; if that is 32 bits then it + discards the upper 32 bits. If we are cachegrinding on a + 32-bit host then we are also ensured that the guest word size + is 32 bits, due to the assertion in TL_(instrument) that the + host and guest word sizes must be the same. Hence + st->Ist.IMark.addr will have been derived from a 32-bit guest + code address and truncation of it is safe. I believe this + assignment should be correct for both 32- and 64-bit + machines. */ + *instrAddr = (Addr)ULong_to_Ptr(st->Ist.IMark.addr); *instrLen = st->Ist.IMark.len; addStmtToIRBB( bbOut, st ); break;