fix 64-bit address output

This commit is contained in:
Glenn Maynard
2004-10-22 22:42:28 +00:00
parent 267a3a9abd
commit f9bcb3c78b
3 changed files with 9 additions and 9 deletions
@@ -83,7 +83,7 @@ CString BacktraceNames::Format() const
ShortenedPath = CString("(") + ShortenedPath + ")"; ShortenedPath = CString("(") + ShortenedPath + ")";
} }
CString ret = ssprintf( "%08x: ", Address ); CString ret = ssprintf( "%0*lx: ", int(sizeof(void*)*2), Address );
if( Symbol != "" ) if( Symbol != "" )
ret += Symbol + " "; ret += Symbol + " ";
ret += ShortenedPath; ret += ShortenedPath;
@@ -97,7 +97,7 @@ CString BacktraceNames::Format() const
#include <dlfcn.h> #include <dlfcn.h>
void BacktraceNames::FromAddr( const void *p ) void BacktraceNames::FromAddr( const void *p )
{ {
Address = (int) p; Address = (intptr_t) p;
/* /*
* When calling a function that doesn't return, gcc will truncate a function. * When calling a function that doesn't return, gcc will truncate a function.
@@ -222,7 +222,7 @@ const char *osx_find_link_edit( const struct mach_header *header )
void BacktraceNames::FromAddr( const void *p ) void BacktraceNames::FromAddr( const void *p )
{ {
Address = (int) p; Address = (intptr_t) p;
/* Find the image with the given pointer. */ /* Find the image with the given pointer. */
int index = osx_find_image( p ); int index = osx_find_image( p );
@@ -287,7 +287,7 @@ void BacktraceNames::FromAddr( const void *p )
#include <execinfo.h> #include <execinfo.h>
void BacktraceNames::FromAddr( const void *p ) void BacktraceNames::FromAddr( const void *p )
{ {
Address = (int) p; Address = (intptr_t) p;
char **foo = backtrace_symbols(&p, 1); char **foo = backtrace_symbols(&p, 1);
if( foo == NULL ) if( foo == NULL )
@@ -340,7 +340,7 @@ void BacktraceNames::FromAddr( const void *p )
pid_t ppid = getpid(); /* Do this before fork()ing! */ pid_t ppid = getpid(); /* Do this before fork()ing! */
Offset = 0; Offset = 0;
Address = long(p); Address = intptr_t(p);
if (pipe(fds) != 0) if (pipe(fds) != 0)
{ {
@@ -447,7 +447,7 @@ void BacktraceNames::FromAddr( const void *p )
#warning Undefined BACKTRACE_LOOKUP_METHOD_* #warning Undefined BACKTRACE_LOOKUP_METHOD_*
void BacktraceNames::FromAddr( const void *p ) void BacktraceNames::FromAddr( const void *p )
{ {
Address = long(p); Address = intptr_t(p);
Offset = 0; Offset = 0;
Symbol = ""; Symbol = "";
File = ""; File = "";
@@ -4,7 +4,7 @@
struct BacktraceNames struct BacktraceNames
{ {
CString Symbol, File; CString Symbol, File;
int Address; intptr_t Address;
int Offset; int Offset;
void FromAddr( const void *p ); void FromAddr( const void *p );
void FromString( CString str ); void FromString( CString str );
@@ -301,9 +301,9 @@ static void child_process()
case SIGSEGV: case SIGSEGV:
case SIGBUS: case SIGBUS:
if( crash.si.si_code == SI_USER ) if( crash.si.si_code == SI_USER )
reason += ssprintf( " from pid %i", (int) crash.si.si_addr ); reason += ssprintf( " from pid %li", (long) crash.si.si_addr );
else else
reason += ssprintf( " at 0x%08x", (unsigned int) crash.si.si_addr ); reason += ssprintf( " at 0x%0*lx", int(sizeof(void*)*2), (unsigned long) crash.si.si_addr );
} }
break; break;
} }