public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gprofng: fix build with -mx32
@ 2022-05-27 6:33 Vladimir Mezentsev
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Mezentsev @ 2022-05-27 6:33 UTC (permalink / raw)
To: bfd-cvs, gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508
commit 2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date: Thu May 26 12:59:19 2022 -0700
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.
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/heaptrace.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 = 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 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] = (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 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)
: // "=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 bf3294d4843..ba5c9129f4c 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 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 >= 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 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 = 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; \
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [binutils-gdb] gprofng: fix build with -mx32
@ 2022-05-28 3:09 Vladimir Mezentsev
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Mezentsev @ 2022-05-28 3:09 UTC (permalink / raw)
To: bfd-cvs, gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6094a48ec821a52731172f3471dce4923a482cd1
commit 6094a48ec821a52731172f3471dce4923a482cd1
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date: Fri May 27 19:54:26 2022 -0700
gprofng: fix build with -mx32
gprofng/ChangeLog
2022-05-27 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/28983
PR gprofng/29143
* src/Experiment.cc (write_header): Fix argument for ctime.
Fix -Wformat= warnings.
* src/Dbe.cc: Likewise.
* src/DwarfLib.h: Fix [-Wsign-compare] warnings.
* src/Experiment.h: Likewise.
* src/ipc.cc: Fix -Wformat= warnings.
Diff:
---
gprofng/src/Dbe.cc | 14 ++++++--------
gprofng/src/DwarfLib.h | 6 +++---
gprofng/src/Experiment.cc | 16 ++++++++++------
gprofng/src/Experiment.h | 2 +-
gprofng/src/ipc.cc | 2 +-
5 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/gprofng/src/Dbe.cc b/gprofng/src/Dbe.cc
index 1a6e5214581..d2cd94bfc19 100644
--- a/gprofng/src/Dbe.cc
+++ b/gprofng/src/Dbe.cc
@@ -1944,21 +1944,19 @@ dbeGetOverviewText (int dbevindex)
info->append (dbe_sprintf (GTXT (" Target : '%s'"), field));
field = exp->hostname;
if (field && field[0])
- info->append (dbe_sprintf (NTXT (" %s %s (%s, %s)"),
- GTXT ("Host :"),
+ info->append (dbe_sprintf (GTXT (" Host : %s (%s, %s)"),
field,
exp->architecture ? exp->architecture
: GTXT ("<CPU architecture not recorded>"),
exp->os_version ? exp->os_version
: GTXT ("<OS version not recorded>")));
- long start_sec = exp->start_sec;
- char *p = ctime (&start_sec); // does this need to be freed? YXXX
+ time_t start_sec = (time_t) exp->start_sec;
+ char *p = ctime (&start_sec);
hrtime_t tot_time = dbeCalcGroupDuration (grInd);
double seconds = tot_time * 1.e-9;
- info->append (dbe_sprintf (NTXT (" %s %s %s %0.3f %s"),
- GTXT ("Start Time :"), p,
- GTXT ("Duration :"), seconds,
- GTXT ("Seconds")));
+ info->append (dbe_sprintf (
+ GTXT (" Start Time : %s Duration : %0.3f Seconds"),
+ p, seconds));
// Number of descendants/processes would be nice
info->append (dbe_strdup (NTXT ("")));
}
diff --git a/gprofng/src/DwarfLib.h b/gprofng/src/DwarfLib.h
index 95eff5751ff..07bd60fcb44 100644
--- a/gprofng/src/DwarfLib.h
+++ b/gprofng/src/DwarfLib.h
@@ -152,9 +152,9 @@ private:
uint64_t timestamp;
uint64_t file_size;
uint64_t address;
- uint32_t file;
- uint32_t line;
- uint32_t column;
+ int file;
+ int line;
+ int column;
Dwarf_Half version;
uint64_t op_index_register;
Dwarf_Small maximum_operations_per_instruction;
diff --git a/gprofng/src/Experiment.cc b/gprofng/src/Experiment.cc
index a23c10c30a3..c797724af07 100644
--- a/gprofng/src/Experiment.cc
+++ b/gprofng/src/Experiment.cc
@@ -644,7 +644,7 @@ Experiment::ExperimentHandler::startElement (char*, char*, char *qName, Attribut
exp->exp_start_time = ts;
str = attrs->getValue (NTXT ("time"));
if (str != NULL)
- exp->start_sec = atol (str);
+ exp->start_sec = atoll (str);
str = attrs->getValue (NTXT ("pid"));
if (str != NULL)
exp->pid = atoi (str);
@@ -4136,7 +4136,8 @@ Experiment::write_header ()
if (dbeSession->ipc_mode || dbeSession->rdt_mode)
{
// In GUI: print start time at the beginning
- char *start_time = ctime (&start_sec);
+ time_t t = (time_t) start_sec;
+ char *start_time = ctime (&t);
if (start_time != NULL)
{
sb.setLength (0);
@@ -4258,7 +4259,8 @@ Experiment::write_header ()
}
// add comment for start time
- char *p = ctime (&start_sec);
+ time_t t = (time_t) start_sec;
+ char *p = ctime (&t);
sb.setLength (0);
if (p != NULL)
sb.sprintf (GTXT ("Experiment started %s"), p);
@@ -6444,9 +6446,11 @@ Experiment::dump_map (FILE *outfile)
load.tv_nsec += NANOSEC;
}
fprintf (outfile,
- "0x%08llx %8lld (0x%08llx) %5ld.%09ld %5ld.%09ld \"%s\"\n",
- s->base, s->size, s->size, load.tv_sec, load.tv_nsec,
- unload.tv_sec, unload.tv_nsec, s->obj->get_name ());
+ "0x%08llx %8lld (0x%08llx) %5lld.%09lld %5lld.%09lld \"%s\"\n",
+ (long long) s->base, (long long) s->size, (long long) s->size,
+ (long long) load.tv_sec, (long long) load.tv_nsec,
+ (long long) unload.tv_sec, (long long) unload.tv_nsec,
+ s->obj->get_name ());
}
fprintf (outfile, NTXT ("\n"));
}
diff --git a/gprofng/src/Experiment.h b/gprofng/src/Experiment.h
index 41c44e4a08a..17c91bda23e 100644
--- a/gprofng/src/Experiment.h
+++ b/gprofng/src/Experiment.h
@@ -114,7 +114,7 @@ public:
// Configuration Information
char *hostname; // Hosthame (e.g. mymachine)
- long start_sec; // Starting timeval secs.
+ hrtime_t start_sec; // Starting timeval secs.
char *username; // name of person performing the test
char *architecture; // Architecture name ("sun4")
Platform_t platform; // Sparc,Sparcv9,Intel
diff --git a/gprofng/src/ipc.cc b/gprofng/src/ipc.cc
index 932423cdf0d..edc70256a68 100644
--- a/gprofng/src/ipc.cc
+++ b/gprofng/src/ipc.cc
@@ -1281,7 +1281,7 @@ ipc_doWork (void *arg)
{
int arg1 = readInt (req);
uint64_t arg2 = readLong (req);
- ipc_log (" args = %d, %ld\n", arg1, arg2);
+ ipc_log (" args = %d, %lld\n", arg1, (long long) arg2);
dbeSetSelObjV2 (arg1, arg2);
writeString (NULL, req);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-28 3:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 6:33 [binutils-gdb] gprofng: fix build with -mx32 Vladimir Mezentsev
2022-05-28 3:09 Vladimir Mezentsev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).