From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2041) id 53F653857359; Fri, 27 May 2022 06:33:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53F653857359 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Vladimir Mezentsev To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] gprofng: fix build with -mx32 X-Act-Checkin: binutils-gdb X-Git-Author: Vladimir Mezentsev X-Git-Refname: refs/heads/master X-Git-Oldrev: 62b5b11b1b57036c37f68ee108913eb36d3693cc X-Git-Newrev: 2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508 Message-Id: <20220527063308.53F653857359@sourceware.org> Date: Fri, 27 May 2022 06:33:08 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2022 06:33:08 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2a2cb7cf2c7f= 0d380ee9cb9ef361223b8770c508 commit 2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508 Author: Vladimir Mezentsev Date: Thu May 26 12:59:19 2022 -0700 gprofng: fix build with -mx32 =20 gprofng/ChangeLog 2022-05-26 Vladimir Mezentsev =20 PR gprofng/28983 * libcollector/libcol_util.h (__collector_getsp, __collector_ge= tfp, __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. Diff: --- gprofng/libcollector/heaptrace.c | 22 +++++++--------------- gprofng/libcollector/hwprofile.h | 2 +- gprofng/libcollector/libcol_util.h | 31 ++++++++++++++++--------------- gprofng/libcollector/mmaptrace.c | 2 +- gprofng/libcollector/synctrace.c | 22 +++++++++++----------- gprofng/libcollector/unwind.c | 6 +++--- 6 files changed, 39 insertions(+), 46 deletions(-) diff --git a/gprofng/libcollector/heaptrace.c b/gprofng/libcollector/heaptr= ace.c index 470a269064f..24e6d2642ec 100644 --- a/gprofng/libcollector/heaptrace.c +++ b/gprofng/libcollector/heaptrace.c @@ -298,8 +298,7 @@ malloc (size_t size) hpacket.comm.tstamp =3D gethrtime (); hpacket.mtype =3D MALLOC_TRACE; hpacket.size =3D (Size_type) size; - hpacket.vaddr =3D (Vaddr_type) ret; - hpacket.ovaddr =3D (Vaddr_type) 0; + hpacket.vaddr =3D (intptr_t) ret; hpacket.comm.frinfo =3D collector_interface->getFrameInfo (heap_hndl, hp= acket.comm.tstamp, FRINFO_FROM_STACK, &hpacket); collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpac= ket); POP_REENTRANCE (guard); @@ -338,9 +337,7 @@ free (void *ptr) hpacket.comm.tsize =3D sizeof ( Heap_packet); hpacket.comm.tstamp =3D ts; hpacket.mtype =3D FREE_TRACE; - hpacket.size =3D (Size_type) 0; - hpacket.vaddr =3D (Vaddr_type) ptr; - hpacket.ovaddr =3D (Vaddr_type) 0; + hpacket.vaddr =3D (intptr_t) ptr; hpacket.comm.frinfo =3D collector_interface->getFrameInfo (heap_hndl, hp= acket.comm.tstamp, FRINFO_FROM_STACK, &hpacket); collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpac= ket); POP_REENTRANCE (guard); @@ -378,8 +375,7 @@ realloc (void *ptr, size_t size) hpacket.comm.tstamp =3D ts; hpacket.mtype =3D REALLOC_TRACE; hpacket.size =3D (Size_type) size; - hpacket.vaddr =3D (Vaddr_type) ret; - hpacket.ovaddr =3D (Vaddr_type) ptr; + hpacket.vaddr =3D (intptr_t) ret; hpacket.comm.frinfo =3D collector_interface->getFrameInfo (heap_hndl, hp= acket.comm.tstamp, FRINFO_FROM_STACK, &hpacket); collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpac= ket); POP_REENTRANCE (guard); @@ -407,8 +403,7 @@ memalign (size_t align, size_t size) hpacket.comm.tstamp =3D gethrtime (); hpacket.mtype =3D MALLOC_TRACE; hpacket.size =3D (Size_type) size; - hpacket.vaddr =3D (Vaddr_type) ret; - hpacket.ovaddr =3D (Vaddr_type) 0; + hpacket.vaddr =3D (intptr_t) ret; hpacket.comm.frinfo =3D collector_interface->getFrameInfo (heap_hndl, hp= acket.comm.tstamp, FRINFO_FROM_STACK, &hpacket); collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpac= ket); POP_REENTRANCE (guard); @@ -437,8 +432,7 @@ valloc (size_t size) hpacket.comm.tstamp =3D gethrtime (); hpacket.mtype =3D MALLOC_TRACE; hpacket.size =3D (Size_type) size; - hpacket.vaddr =3D (Vaddr_type) ret; - hpacket.ovaddr =3D (Vaddr_type) 0; + hpacket.vaddr =3D (intptr_t) ret; hpacket.comm.frinfo =3D collector_interface->getFrameInfo (heap_hndl, hp= acket.comm.tstamp, FRINFO_FROM_STACK, &hpacket); collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpac= ket); POP_REENTRANCE (guard); @@ -470,8 +464,7 @@ calloc (size_t size, size_t esize) hpacket.comm.tstamp =3D gethrtime (); hpacket.mtype =3D MALLOC_TRACE; hpacket.size =3D (Size_type) (size * esize); - hpacket.vaddr =3D (Vaddr_type) ret; - hpacket.ovaddr =3D (Vaddr_type) 0; + hpacket.vaddr =3D (intptr_t) ret; hpacket.comm.frinfo =3D collector_interface->getFrameInfo (heap_hndl, hp= acket.comm.tstamp, FRINFO_FROM_STACK, &hpacket); collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpac= ket); POP_REENTRANCE (guard); @@ -494,8 +487,7 @@ __collector_heap_record (int mtype, size_t size, void *= vaddr) hpacket.comm.tstamp =3D gethrtime (); hpacket.mtype =3D mtype; hpacket.size =3D (Size_type) size; - hpacket.vaddr =3D (Vaddr_type) vaddr; - hpacket.ovaddr =3D (Vaddr_type) 0; + hpacket.vaddr =3D (intptr_t) vaddr; hpacket.comm.frinfo =3D collector_interface->getFrameInfo (heap_hndl, hp= acket.comm.tstamp, FRINFO_FROM_STACK, &hpacket); collector_interface->writeDataRecord (heap_hndl, (Common_packet*) & hpac= ket); POP_REENTRANCE (guard); diff --git a/gprofng/libcollector/hwprofile.h b/gprofng/libcollector/hwprof= ile.h index 4d01bf17694..a234b78be56 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] =3D (greg_t)(funcp); \ + (ucp)->uc_mcontext.gregs[CONTEXT_PC] =3D (intptr_t)(funcp); \ (ucp)->uc_mcontext.gregs[CONTEXT_SP] =3D 0; \ (ucp)->uc_mcontext.gregs[CONTEXT_FP] =3D 0; =20 diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libc= ol_util.h index 4384d47df5c..e13a02ea6d7 100644 --- a/gprofng/libcollector/libcol_util.h +++ b/gprofng/libcollector/libcol_util.h @@ -133,6 +133,7 @@ __collector_dec_32 (volatile uint32_t *ptr) : // "=3Dm" (*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=20 : "=3Dr" (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 : "=3Dr" (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" : "=3Dr" (r)); #else - " call 1f \n" - "1: popq %0 \n" + __asm__ __volatile__("call 1f \n" + "1: popl %0" : "=3Dr" (r)); #endif - : "=3Dr" (r)); // output return r; } =20 @@ -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 =3D (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/mmaptr= ace.c index bf3294d4843..ba5c9129f4c 100644 --- a/gprofng/libcollector/mmaptrace.c +++ b/gprofng/libcollector/mmaptrace.c @@ -982,7 +982,7 @@ process_vsyscall_page () if (ap->a_type =3D=3D AT_SYSINFO_EHDR) { // newer Linuxes do not have a_ptr field, they just have a_val - ehdr =3D (ELF_EHDR*) ap->a_un.a_val; + ehdr =3D (ELF_EHDR*)(intptr_t) ap->a_un.a_val; if (ehdr !=3D NULL) break; } diff --git a/gprofng/libcollector/synctrace.c b/gprofng/libcollector/synctr= ace.c index 969c681d842..492ef9993f7 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 >=3D sync_threshold) { Sync_packet spacket; - collector_memset (&spacket, 0, sizeof ( Sync_packet)); - spacket.comm.tsize =3D sizeof ( Sync_packet); + collector_memset (&spacket, 0, sizeof (Sync_packet)); + spacket.comm.tsize =3D sizeof (Sync_packet); spacket.comm.tstamp =3D grnt; spacket.requested =3D reqt; - spacket.objp =3D (Vaddr_type) object; + spacket.objp =3D (intptr_t) object; spacket.comm.frinfo =3D 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 >=3D sync_threshold) { Sync_packet spacket; - collector_memset (&spacket, 0, sizeof ( Sync_packet)); - spacket.comm.tsize =3D sizeof ( Sync_packet); + collector_memset (&spacket, 0, sizeof (Sync_packet)); + spacket.comm.tsize =3D sizeof (Sync_packet); spacket.comm.tstamp =3D grnt; spacket.requested =3D reqt; - spacket.objp =3D (Vaddr_type) mp; + spacket.objp =3D (intptr_t) mp; spacket.comm.frinfo =3D 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_pthrea= d_cond_wait) (), pthread_co if (grnt - reqt >=3D sync_threshold) { Sync_packet spacket; - collector_memset (&spacket, 0, sizeof ( Sync_packet)); - spacket.comm.tsize =3D sizeof ( Sync_packet); + collector_memset (&spacket, 0, sizeof (Sync_packet)); + spacket.comm.tsize =3D sizeof (Sync_packet); spacket.comm.tstamp =3D grnt; spacket.requested =3D reqt; - spacket.objp =3D (Vaddr_type) mutex; + spacket.objp =3D (intptr_t) mutex; spacket.comm.frinfo =3D 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_pth= read_cond_timedwait) (), spacket.comm.tsize =3D sizeof ( Sync_packet); spacket.comm.tstamp =3D grnt; spacket.requested =3D reqt; - spacket.objp =3D (Vaddr_type) mutex; + spacket.objp =3D (intptr_t) mutex; spacket.comm.frinfo =3D 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 =3D sizeof ( Sync_packet); spacket.comm.tstamp =3D grnt; spacket.requested =3D reqt; - spacket.objp =3D (Vaddr_type) sp; + spacket.objp =3D (intptr_t) sp; =20 #if ARCH(Intel) && WSIZE(32) spacket.comm.frinfo =3D 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 f309c54bd33..11924378802 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 =3D NULL; \ void *sp =3D __collector_getsp(); \ - GET_SP(context) =3D (greg_t)sp; \ - GET_FP(context) =3D (greg_t)__collector_getfp(); \ - GET_PC(context) =3D (greg_t)__collector_getpc(); \ + GET_SP(context) =3D (intptr_t)sp; \ + GET_FP(context) =3D (intptr_t)__collector_getfp(); \ + GET_PC(context) =3D (intptr_t)__collector_getpc(); \ context->uc_stack.ss_sp =3D sp; \ context->uc_stack.ss_size =3D 0x100000; \ }