aboutsummaryrefslogtreecommitdiff
path: root/gprofng
diff options
context:
space:
mode:
authorVladimir Mezentsev <vladimir.mezentsev@oracle.com>2022-05-26 12:59:19 -0700
committerVladimir Mezentsev <vladimir.mezentsev@oracle.com>2022-05-26 23:27:50 -0700
commit2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508 (patch)
tree157f064b5bf50d1e3aa1b164b3996dcdfbe47ae6 /gprofng
parent62b5b11b1b57036c37f68ee108913eb36d3693cc (diff)
downloadgdb-2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508.zip
gdb-2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508.tar.gz
gdb-2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508.tar.bz2
gprofng: fix build with -mx32
gprofng/ChangeLog 2022-05-26 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR gprofng/28983 * libcollector/libcol_util.h (__collector_getsp, __collector_getfp, __collector_getpc): Adapt for build with -mx32 * libcollector/heaptrace.c: Fix -Wpointer-to-int-cast warnings. * libcollector/hwprofile.h: Likewise. * libcollector/mmaptrace.c: Likewise. * libcollector/synctrace.c: Likewise. * libcollector/unwind.c: Likewise.
Diffstat (limited to 'gprofng')
-rw-r--r--gprofng/libcollector/heaptrace.c22
-rw-r--r--gprofng/libcollector/hwprofile.h2
-rw-r--r--gprofng/libcollector/libcol_util.h31
-rw-r--r--gprofng/libcollector/mmaptrace.c2
-rw-r--r--gprofng/libcollector/synctrace.c22
-rw-r--r--gprofng/libcollector/unwind.c6
6 files changed, 39 insertions, 46 deletions
diff --git a/gprofng/libcollector/heaptrace.c b/gprofng/libcollector/heaptrace.c
index 470a269..24e6d26 100644
--- a/gprofng/libcollector/heaptrace.c
+++ b/gprofng/libcollector/heaptrace.c
@@ -298,8 +298,7 @@ malloc (size_t size)
hpacket.comm.tstamp = gethrtime ();
hpacket.mtype = MALLOC_TRACE;
hpacket.size = (Size_type) size;
- hpacket.vaddr = (Vaddr_type) ret;
- hpacket.ovaddr = (Vaddr_type) 0;
+ hpacket.vaddr = (intptr_t) ret;
hpacket.comm.frinfo = collector_interface->getFrameInfo (heap_hndl, hpacket.comm.tstamp, FRINFO_FROM_STACK, &hpacket);
collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpacket);
POP_REENTRANCE (guard);
@@ -338,9 +337,7 @@ free (void *ptr)
hpacket.comm.tsize = sizeof ( Heap_packet);
hpacket.comm.tstamp = ts;
hpacket.mtype = FREE_TRACE;
- hpacket.size = (Size_type) 0;
- hpacket.vaddr = (Vaddr_type) ptr;
- hpacket.ovaddr = (Vaddr_type) 0;
+ hpacket.vaddr = (intptr_t) ptr;
hpacket.comm.frinfo = collector_interface->getFrameInfo (heap_hndl, hpacket.comm.tstamp, FRINFO_FROM_STACK, &hpacket);
collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpacket);
POP_REENTRANCE (guard);
@@ -378,8 +375,7 @@ realloc (void *ptr, size_t size)
hpacket.comm.tstamp = ts;
hpacket.mtype = REALLOC_TRACE;
hpacket.size = (Size_type) size;
- hpacket.vaddr = (Vaddr_type) ret;
- hpacket.ovaddr = (Vaddr_type) ptr;
+ hpacket.vaddr = (intptr_t) ret;
hpacket.comm.frinfo = collector_interface->getFrameInfo (heap_hndl, hpacket.comm.tstamp, FRINFO_FROM_STACK, &hpacket);
collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpacket);
POP_REENTRANCE (guard);
@@ -407,8 +403,7 @@ memalign (size_t align, size_t size)
hpacket.comm.tstamp = gethrtime ();
hpacket.mtype = MALLOC_TRACE;
hpacket.size = (Size_type) size;
- hpacket.vaddr = (Vaddr_type) ret;
- hpacket.ovaddr = (Vaddr_type) 0;
+ hpacket.vaddr = (intptr_t) ret;
hpacket.comm.frinfo = collector_interface->getFrameInfo (heap_hndl, hpacket.comm.tstamp, FRINFO_FROM_STACK, &hpacket);
collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpacket);
POP_REENTRANCE (guard);
@@ -437,8 +432,7 @@ valloc (size_t size)
hpacket.comm.tstamp = gethrtime ();
hpacket.mtype = MALLOC_TRACE;
hpacket.size = (Size_type) size;
- hpacket.vaddr = (Vaddr_type) ret;
- hpacket.ovaddr = (Vaddr_type) 0;
+ hpacket.vaddr = (intptr_t) ret;
hpacket.comm.frinfo = collector_interface->getFrameInfo (heap_hndl, hpacket.comm.tstamp, FRINFO_FROM_STACK, &hpacket);
collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpacket);
POP_REENTRANCE (guard);
@@ -470,8 +464,7 @@ calloc (size_t size, size_t esize)
hpacket.comm.tstamp = gethrtime ();
hpacket.mtype = MALLOC_TRACE;
hpacket.size = (Size_type) (size * esize);
- hpacket.vaddr = (Vaddr_type) ret;
- hpacket.ovaddr = (Vaddr_type) 0;
+ hpacket.vaddr = (intptr_t) ret;
hpacket.comm.frinfo = collector_interface->getFrameInfo (heap_hndl, hpacket.comm.tstamp, FRINFO_FROM_STACK, &hpacket);
collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpacket);
POP_REENTRANCE (guard);
@@ -494,8 +487,7 @@ __collector_heap_record (int mtype, size_t size, void *vaddr)
hpacket.comm.tstamp = gethrtime ();
hpacket.mtype = mtype;
hpacket.size = (Size_type) size;
- hpacket.vaddr = (Vaddr_type) vaddr;
- hpacket.ovaddr = (Vaddr_type) 0;
+ hpacket.vaddr = (intptr_t) vaddr;
hpacket.comm.frinfo = collector_interface->getFrameInfo (heap_hndl, hpacket.comm.tstamp, FRINFO_FROM_STACK, &hpacket);
collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpacket);
POP_REENTRANCE (guard);
diff --git a/gprofng/libcollector/hwprofile.h b/gprofng/libcollector/hwprofile.h
index 4d01bf1..a234b78 100644
--- a/gprofng/libcollector/hwprofile.h
+++ b/gprofng/libcollector/hwprofile.h
@@ -72,7 +72,7 @@ typedef struct MHwcntr_packet
#define CONTEXT_SP REG_ESP
#endif /* WSIZE() */
#define SETFUNCTIONCONTEXT(ucp,funcp) \
- (ucp)->uc_mcontext.gregs[CONTEXT_PC] = (greg_t)(funcp); \
+ (ucp)->uc_mcontext.gregs[CONTEXT_PC] = (intptr_t)(funcp); \
(ucp)->uc_mcontext.gregs[CONTEXT_SP] = 0; \
(ucp)->uc_mcontext.gregs[CONTEXT_FP] = 0;
diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libcol_util.h
index 4384d47..e13a02e 100644
--- a/gprofng/libcollector/libcol_util.h
+++ b/gprofng/libcollector/libcol_util.h
@@ -133,6 +133,7 @@ __collector_dec_32 (volatile uint32_t *ptr)
: // "=m" (*ptr) // output
: "m" (*ptr)); // input
}
+
/**
* This function subtrackts the value "off" of the value stored in target
* to occur in an atomic manner, and returns new value stored in target.
@@ -148,6 +149,7 @@ __collector_subget_32 (uint32_t *ptr, uint32_t off)
);
return (r - offset);
}
+
/**
* This function returns the value of the stack pointer register
*/
@@ -155,14 +157,15 @@ static __attribute__ ((always_inline)) inline void *
__collector_getsp ()
{
void *r;
-#if WSIZE(64)
- __asm__ __volatile__("movq %%rsp, %0"
-#else
+#if WSIZE(32) || defined(__ILP32__)
__asm__ __volatile__("movl %%esp, %0"
-#endif
+#else
+ __asm__ __volatile__("movq %%rsp, %0"
+#endif
: "=r" (r)); // output
return r;
}
+
/**
* This function returns the value of the frame pointer register
*/
@@ -170,14 +173,15 @@ static __attribute__ ((always_inline)) inline void *
__collector_getfp ()
{
void *r;
-#if WSIZE(64)
- __asm__ __volatile__("movq %%rbp, %0"
-#else
+#if WSIZE(32) || defined(__ILP32__)
__asm__ __volatile__("movl %%ebp, %0"
+#else
+ __asm__ __volatile__("movq %%rbp, %0"
#endif
: "=r" (r)); // output
return r;
}
+
/**
* This function returns the value of the processor counter register
*/
@@ -185,15 +189,12 @@ static __attribute__ ((always_inline)) inline void *
__collector_getpc ()
{
void *r;
- __asm__ __volatile__(
-#if WSIZE(32)
- " call 1f \n"
- "1: popl %0 \n"
+#if defined(__x86_64)
+ __asm__ __volatile__("lea (%%rip), %0" : "=r" (r));
#else
- " call 1f \n"
- "1: popq %0 \n"
+ __asm__ __volatile__("call 1f \n"
+ "1: popl %0" : "=r" (r));
#endif
- : "=r" (r)); // output
return r;
}
@@ -258,7 +259,7 @@ static __attribute__ ((always_inline)) inline void *
__collector_cas_ptr (void *mem, void *cmp, void *new)
{
void *r;
-#if WSIZE(32)
+#if WSIZE(32) || defined(__ILP32__)
r = (void *) __collector_cas_32 ((volatile uint32_t *)mem, (uint32_t) cmp, (uint32_t)new);
#else
__asm__ __volatile__("lock; cmpxchgq %2, (%1)"
diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c
index bf3294d..ba5c912 100644
--- a/gprofng/libcollector/mmaptrace.c
+++ b/gprofng/libcollector/mmaptrace.c
@@ -982,7 +982,7 @@ process_vsyscall_page ()
if (ap->a_type == AT_SYSINFO_EHDR)
{
// newer Linuxes do not have a_ptr field, they just have a_val
- ehdr = (ELF_EHDR*) ap->a_un.a_val;
+ ehdr = (ELF_EHDR*)(intptr_t) ap->a_un.a_val;
if (ehdr != NULL)
break;
}
diff --git a/gprofng/libcollector/synctrace.c b/gprofng/libcollector/synctrace.c
index 969c681..492ef99 100644
--- a/gprofng/libcollector/synctrace.c
+++ b/gprofng/libcollector/synctrace.c
@@ -707,11 +707,11 @@ __collector_jsync_end (hrtime_t reqt, void *object)
if (grnt - reqt >= sync_threshold)
{
Sync_packet spacket;
- collector_memset (&spacket, 0, sizeof ( Sync_packet));
- spacket.comm.tsize = sizeof ( Sync_packet);
+ collector_memset (&spacket, 0, sizeof (Sync_packet));
+ spacket.comm.tsize = sizeof (Sync_packet);
spacket.comm.tstamp = grnt;
spacket.requested = reqt;
- spacket.objp = (Vaddr_type) object;
+ spacket.objp = (intptr_t) object;
spacket.comm.frinfo = collector_interface->getFrameInfo (sync_hndl, spacket.comm.tstamp, FRINFO_FROM_STACK_ARG, &spacket);
collector_interface->writeDataRecord (sync_hndl, (Common_packet*) & spacket);
}
@@ -740,11 +740,11 @@ pthread_mutex_lock (pthread_mutex_t *mp)
if (grnt - reqt >= sync_threshold)
{
Sync_packet spacket;
- collector_memset (&spacket, 0, sizeof ( Sync_packet));
- spacket.comm.tsize = sizeof ( Sync_packet);
+ collector_memset (&spacket, 0, sizeof (Sync_packet));
+ spacket.comm.tsize = sizeof (Sync_packet);
spacket.comm.tstamp = grnt;
spacket.requested = reqt;
- spacket.objp = (Vaddr_type) mp;
+ spacket.objp = (intptr_t) mp;
spacket.comm.frinfo = collector_interface->getFrameInfo (sync_hndl, spacket.comm.tstamp, FRINFO_FROM_STACK, &spacket);
collector_interface->writeDataRecord (sync_hndl, (Common_packet*) & spacket);
}
@@ -831,11 +831,11 @@ __collector_pthread_cond_wait_symver (int(real_pthread_cond_wait) (), pthread_co
if (grnt - reqt >= sync_threshold)
{
Sync_packet spacket;
- collector_memset (&spacket, 0, sizeof ( Sync_packet));
- spacket.comm.tsize = sizeof ( Sync_packet);
+ collector_memset (&spacket, 0, sizeof (Sync_packet));
+ spacket.comm.tsize = sizeof (Sync_packet);
spacket.comm.tstamp = grnt;
spacket.requested = reqt;
- spacket.objp = (Vaddr_type) mutex;
+ spacket.objp = (intptr_t) mutex;
spacket.comm.frinfo = collector_interface->getFrameInfo (sync_hndl, spacket.comm.tstamp, FRINFO_FROM_STACK_ARG, &spacket);
collector_interface->writeDataRecord (sync_hndl, (Common_packet*) & spacket);
}
@@ -938,7 +938,7 @@ __collector_pthread_cond_timedwait_symver (int(real_pthread_cond_timedwait) (),
spacket.comm.tsize = sizeof ( Sync_packet);
spacket.comm.tstamp = grnt;
spacket.requested = reqt;
- spacket.objp = (Vaddr_type) mutex;
+ spacket.objp = (intptr_t) mutex;
spacket.comm.frinfo = collector_interface->getFrameInfo (sync_hndl, spacket.comm.tstamp, FRINFO_FROM_STACK_ARG, &spacket);
collector_interface->writeDataRecord (sync_hndl, (Common_packet*) & spacket);
}
@@ -1047,7 +1047,7 @@ sem_wait (sem_t *sp)
spacket.comm.tsize = sizeof ( Sync_packet);
spacket.comm.tstamp = grnt;
spacket.requested = reqt;
- spacket.objp = (Vaddr_type) sp;
+ spacket.objp = (intptr_t) sp;
#if ARCH(Intel) && WSIZE(32)
spacket.comm.frinfo = collector_interface->getFrameInfo (sync_hndl, spacket.comm.tstamp, FRINFO_FROM_STACK_ARG, &spacket);
diff --git a/gprofng/libcollector/unwind.c b/gprofng/libcollector/unwind.c
index f309c54..1192437 100644
--- a/gprofng/libcollector/unwind.c
+++ b/gprofng/libcollector/unwind.c
@@ -223,9 +223,9 @@ memory_error_func (int status ATTRIBUTE_UNUSED, bfd_vma addr ATTRIBUTE_UNUSED,
{ \
context->uc_link = NULL; \
void *sp = __collector_getsp(); \
- GET_SP(context) = (greg_t)sp; \
- GET_FP(context) = (greg_t)__collector_getfp(); \
- GET_PC(context) = (greg_t)__collector_getpc(); \
+ GET_SP(context) = (intptr_t)sp; \
+ GET_FP(context) = (intptr_t)__collector_getfp(); \
+ GET_PC(context) = (intptr_t)__collector_getpc(); \
context->uc_stack.ss_sp = sp; \
context->uc_stack.ss_size = 0x100000; \
}