aboutsummaryrefslogtreecommitdiff
path: root/gprofng
diff options
context:
space:
mode:
authorVladimir Mezentsev <vladimir.mezentsev@oracle.com>2023-10-23 19:55:01 -0700
committerVladimir Mezentsev <vladimir.mezentsev@oracle.com>2023-10-24 23:27:30 -0700
commit53beac2e23bcffe632bb837c97003998e6986ce9 (patch)
tree5376681dc206ebe3764915e873daf7cb89905a6c /gprofng
parent7ac6d0c38c365a6778a91fd37203c21561c61c4c (diff)
downloadgdb-53beac2e23bcffe632bb837c97003998e6986ce9.zip
gdb-53beac2e23bcffe632bb837c97003998e6986ce9.tar.gz
gdb-53beac2e23bcffe632bb837c97003998e6986ce9.tar.bz2
gprofng: Fix -Wformat= warnings
Added format attribute to several gprofng functions. Fixed -Wformat= warnings. gprofng/ChangeLog 2023-10-23 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> * libcollector/heaptrace.c: Fixed -Wformat= warnings. * libcollector/hwprofile.c: Likewise. * libcollector/iolib.c: Likewise. * libcollector/iotrace.c: Likewise. * libcollector/jprofile.c: Likewise. * libcollector/profile.c: Likewise. * libcollector/synctrace.c: Likewise. * src/ClassFile.cc: Likewise. * src/SourceFile.cc: Likewise. * libcollector/libcol_util.h: Added format attribute. * src/Emsg.h: Likewise. * src/collector_module.h: Likewise. * src/data_pckts.h: Define fld_sizeof.
Diffstat (limited to 'gprofng')
-rw-r--r--gprofng/libcollector/heaptrace.c29
-rw-r--r--gprofng/libcollector/hwprofile.c81
-rw-r--r--gprofng/libcollector/iolib.c2
-rw-r--r--gprofng/libcollector/iotrace.c37
-rw-r--r--gprofng/libcollector/jprofile.c10
-rw-r--r--gprofng/libcollector/libcol_util.h3
-rw-r--r--gprofng/libcollector/profile.c23
-rw-r--r--gprofng/libcollector/synctrace.c23
-rw-r--r--gprofng/src/ClassFile.cc2
-rw-r--r--gprofng/src/Emsg.h3
-rw-r--r--gprofng/src/SourceFile.cc6
-rw-r--r--gprofng/src/collector_module.h11
-rw-r--r--gprofng/src/data_pckts.h1
13 files changed, 149 insertions, 82 deletions
diff --git a/gprofng/libcollector/heaptrace.c b/gprofng/libcollector/heaptrace.c
index b51ab33..4c1b6b3 100644
--- a/gprofng/libcollector/heaptrace.c
+++ b/gprofng/libcollector/heaptrace.c
@@ -24,6 +24,7 @@
#include "config.h"
#include <dlfcn.h>
+#include <stddef.h>
#include "gp-defs.h"
#include "collector.h"
@@ -151,26 +152,34 @@ open_experiment (const char *exp)
module_interface.description);
/* Record Heap_packet description */
- Heap_packet *pp = NULL;
collector_interface->writeLog (" <profpckt kind=\"%d\" uname=\"Heap tracing data\">\n", HEAP_PCKT);
collector_interface->writeLog (" <field name=\"LWPID\" uname=\"Lightweight process id\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Heap_packet, comm.lwp_id),
+ fld_sizeof (Heap_packet, comm.lwp_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"THRID\" uname=\"Thread number\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Heap_packet, comm.thr_id),
+ fld_sizeof (Heap_packet, comm.thr_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"CPUID\" uname=\"CPU id\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Heap_packet, comm.cpu_id),
+ fld_sizeof (Heap_packet, comm.cpu_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"TSTAMP\" uname=\"High resolution timestamp\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Heap_packet, comm.tstamp),
+ fld_sizeof (Heap_packet, comm.tstamp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Heap_packet, comm.frinfo),
+ fld_sizeof (Heap_packet, comm.frinfo) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"HTYPE\" uname=\"Heap trace function type\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->mtype, sizeof (pp->mtype) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Heap_packet, mtype),
+ fld_sizeof (Heap_packet, mtype) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"HSIZE\" uname=\"Memory size\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->size, sizeof (pp->size) == 4 ? "UINT32" : "UINT64");
+ (int) offsetof (Heap_packet, size),
+ fld_sizeof (Heap_packet, size) == 4 ? "UINT32" : "UINT64");
collector_interface->writeLog (" <field name=\"HVADDR\" uname=\"Memory address\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->vaddr, sizeof (pp->vaddr) == 4 ? "UINT32" : "UINT64");
+ (int) offsetof (Heap_packet, vaddr),
+ fld_sizeof (Heap_packet, vaddr) == 4 ? "UINT32" : "UINT64");
collector_interface->writeLog (" <field name=\"HOVADDR\" uname=\"Previous memory address\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->ovaddr, sizeof (pp->ovaddr) == 4 ? "UINT32" : "UINT64");
+ (int) offsetof (Heap_packet, ovaddr),
+ fld_sizeof (Heap_packet, ovaddr) == 4 ? "UINT32" : "UINT64");
collector_interface->writeLog (" </profpckt>\n");
collector_interface->writeLog ("</profile>\n");
return COL_ERROR_NONE;
diff --git a/gprofng/libcollector/hwprofile.c b/gprofng/libcollector/hwprofile.c
index 3ca89d1..092d665 100644
--- a/gprofng/libcollector/hwprofile.c
+++ b/gprofng/libcollector/hwprofile.c
@@ -25,6 +25,7 @@
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
+#include <stddef.h>
#include <unistd.h>
#include <errno.h>
#include <sys/syscall.h>
@@ -823,66 +824,90 @@ hwclogwrite0 ()
collector_interface->writeLog ("<profdata fname=\"%s\"/>\n",
module_interface.description);
/* Record Hwcntr_packet description */
- Hwcntr_packet *pp = NULL;
collector_interface->writeLog ("<profpckt kind=\"%d\" uname=\"" STXT ("Hardware counter profiling data") "\">\n", HW_PCKT);
collector_interface->writeLog (" <field name=\"LWPID\" uname=\"" STXT ("Lightweight process id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Hwcntr_packet, comm.lwp_id),
+ fld_sizeof (Hwcntr_packet, comm.lwp_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"THRID\" uname=\"" STXT ("Thread number") "\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Hwcntr_packet, comm.thr_id),
+ fld_sizeof (Hwcntr_packet, comm.thr_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"CPUID\" uname=\"" STXT ("CPU id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Hwcntr_packet, comm.cpu_id),
+ fld_sizeof (Hwcntr_packet, comm.cpu_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"TSTAMP\" uname=\"" STXT ("High resolution timestamp") "\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Hwcntr_packet, comm.tstamp),
+ fld_sizeof (Hwcntr_packet, comm.tstamp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Hwcntr_packet, comm.frinfo),
+ fld_sizeof (Hwcntr_packet, comm.frinfo) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"HWCTAG\" uname=\"" STXT ("Hardware counter index") "\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->tag, sizeof (pp->tag) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Hwcntr_packet, tag),
+ fld_sizeof (Hwcntr_packet, tag) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"HWCINT\" uname=\"" STXT ("Hardware counter interval") "\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->interval, sizeof (pp->interval) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Hwcntr_packet, interval),
+ fld_sizeof (Hwcntr_packet, interval) == 4 ? "INT32" : "INT64");
collector_interface->writeLog ("</profpckt>\n");
if (hwcdef_has_memspace)
{
/* Record MHwcntr_packet description */
- MHwcntr_packet *xpp = NULL;
collector_interface->writeLog ("<profpckt kind=\"%d\" uname=\"" STXT ("Hardware counter profiling data") "\">\n", MHWC_PCKT);
collector_interface->writeLog (" <field name=\"LWPID\" uname=\"" STXT ("Lightweight process id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->comm.lwp_id, sizeof (xpp->comm.lwp_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, comm.lwp_id),
+ fld_sizeof (MHwcntr_packet, comm.lwp_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"THRID\" uname=\"" STXT ("Thread number") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->comm.thr_id, sizeof (xpp->comm.thr_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, comm.thr_id),
+ fld_sizeof (MHwcntr_packet, comm.thr_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"CPUID\" uname=\"" STXT ("CPU id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->comm.cpu_id, sizeof (xpp->comm.cpu_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, comm.cpu_id),
+ fld_sizeof (MHwcntr_packet, comm.cpu_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"TSTAMP\" uname=\"" STXT ("High resolution timestamp") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->comm.tstamp, sizeof (xpp->comm.tstamp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, comm.tstamp),
+ fld_sizeof (MHwcntr_packet, comm.tstamp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->comm.frinfo, sizeof (xpp->comm.frinfo) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, comm.frinfo),
+ fld_sizeof (MHwcntr_packet, comm.frinfo) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"HWCTAG\" uname=\"" STXT ("Hardware counter index") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->tag, sizeof (xpp->tag) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, tag),
+ fld_sizeof (MHwcntr_packet, tag) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"HWCINT\" uname=\"" STXT ("Hardware counter interval") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->interval, sizeof (xpp->interval) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, interval),
+ fld_sizeof (MHwcntr_packet, interval) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"VADDR\" uname=\"" STXT ("Virtual address (data)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->ea_vaddr, sizeof (xpp->ea_vaddr) == 4 ? "UINT32" : "UINT64");
+ (int) offsetof (MHwcntr_packet, ea_vaddr),
+ fld_sizeof (MHwcntr_packet, ea_vaddr) == 4 ? "UINT32" : "UINT64");
collector_interface->writeLog (" <field name=\"PADDR\" uname=\"" STXT ("Physical address (data)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->ea_paddr, sizeof (xpp->ea_paddr) == 4 ? "UINT32" : "UINT64");
+ (int) offsetof (MHwcntr_packet, ea_paddr),
+ fld_sizeof (MHwcntr_packet, ea_paddr) == 4 ? "UINT32" : "UINT64");
collector_interface->writeLog (" <field name=\"VIRTPC\" uname=\"" STXT ("Virtual address (instruction)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->pc_vaddr, sizeof (xpp->pc_vaddr) == 4 ? "UINT32" : "UINT64");
+ (int) offsetof (MHwcntr_packet, pc_vaddr),
+ fld_sizeof (MHwcntr_packet, pc_vaddr) == 4 ? "UINT32" : "UINT64");
collector_interface->writeLog (" <field name=\"PHYSPC\" uname=\"" STXT ("Physical address (instruction)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->pc_paddr, sizeof (xpp->pc_paddr) == 4 ? "UINT32" : "UINT64");
+ (int) offsetof (MHwcntr_packet, pc_paddr),
+ fld_sizeof (MHwcntr_packet, pc_paddr) == 4 ? "UINT32" : "UINT64");
collector_interface->writeLog (" <field name=\"EA_PAGESIZE\" uname=\"" STXT ("Page size (data)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->ea_pagesz, sizeof (xpp->ea_pagesz) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, ea_pagesz),
+ fld_sizeof (MHwcntr_packet, ea_pagesz) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"PC_PAGESIZE\" uname=\"" STXT ("Page size (instruction)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->pc_pagesz, sizeof (xpp->pc_pagesz) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, pc_pagesz),
+ fld_sizeof (MHwcntr_packet, pc_pagesz) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"EA_LGRP\" uname=\"" STXT ("Page locality group (data)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->ea_lgrp, sizeof (xpp->ea_lgrp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, ea_lgrp),
+ fld_sizeof (MHwcntr_packet, ea_lgrp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"PC_LGRP\" uname=\"" STXT ("Page locality group (instruction)") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->pc_lgrp, sizeof (xpp->pc_lgrp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, pc_lgrp),
+ fld_sizeof (MHwcntr_packet, pc_lgrp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"LWP_LGRP_HOME\" uname=\"" STXT ("LWP home lgroup id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->lgrp_lwp, sizeof (xpp->lgrp_lwp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, lgrp_lwp),
+ fld_sizeof (MHwcntr_packet, lgrp_lwp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"PS_LGRP_HOME\" uname=\"" STXT ("Process home lgroup id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->lgrp_ps, sizeof (xpp->lgrp_ps) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, lgrp_ps),
+ fld_sizeof (MHwcntr_packet, lgrp_ps) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"MEM_LAT\" uname=\"" STXT ("Memory Latency Cycles") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->latency, sizeof (xpp->latency) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, latency),
+ fld_sizeof (MHwcntr_packet, latency) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"MEM_SRC\" uname=\"" STXT ("Memory Data Source") "\" offset=\"%d\" type=\"%s\"/>\n",
- &xpp->data_source, sizeof (xpp->data_source) == 4 ? "INT32" : "INT64");
+ (int) offsetof (MHwcntr_packet, data_source),
+ fld_sizeof (MHwcntr_packet, data_source) == 4 ? "INT32" : "INT64");
collector_interface->writeLog ("</profpckt>\n");
}
}
diff --git a/gprofng/libcollector/iolib.c b/gprofng/libcollector/iolib.c
index 9de4814..96fdd25 100644
--- a/gprofng/libcollector/iolib.c
+++ b/gprofng/libcollector/iolib.c
@@ -640,7 +640,7 @@ remapBlock (DataHandle *hndl, unsigned iflow, unsigned ichunk)
hrtime_t teo = __collector_gethrtime ();
double deltato = (double) (teo - tso) / 1000000.;
(void) CALL_UTIL (snprintf) (errmsg, sizeof (errmsg),
- " t=%d, %s: open-retries=%lu, %3.6f ms.; remap\n",
+ " t=%ld, %s: open-retries=%d, %3.6f ms.; remap\n",
(unsigned long) __collector_thr_self (), hndl->fname,
iter, deltato);
__collector_log_write ("<event kind=\"%s\" id=\"%d\">%s</event>\n",
diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c
index 81c8440..7ed9c99 100644
--- a/gprofng/libcollector/iotrace.c
+++ b/gprofng/libcollector/iotrace.c
@@ -25,6 +25,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <stdarg.h>
+#include <stddef.h>
#include <stdlib.h>
// create() and others are defined in fcntl.h.
@@ -305,32 +306,42 @@ open_experiment (const char *exp)
collector_interface->writeLog (" <profdata fname=\"%s\"/>\n",
module_interface.description);
/* Record IOTrace_packet description */
- IOTrace_packet *pp = NULL;
collector_interface->writeLog (" <profpckt kind=\"%d\" uname=\"IO tracing data\">\n", IOTRACE_PCKT);
collector_interface->writeLog (" <field name=\"LWPID\" uname=\"Lightweight process id\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, comm.lwp_id),
+ fld_sizeof (IOTrace_packet, comm.lwp_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"THRID\" uname=\"Thread number\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, comm.thr_id),
+ fld_sizeof (IOTrace_packet, comm.thr_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"CPUID\" uname=\"CPU id\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, comm.cpu_id),
+ fld_sizeof (IOTrace_packet, comm.cpu_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"TSTAMP\" uname=\"High resolution timestamp\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, comm.tstamp),
+ fld_sizeof (IOTrace_packet, comm.tstamp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, comm.frinfo),
+ fld_sizeof (IOTrace_packet, comm.frinfo) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"IOTYPE\" uname=\"IO trace function type\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->iotype, sizeof (pp->iotype) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, iotype),
+ fld_sizeof (IOTrace_packet, iotype) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"IOFD\" uname=\"File descriptor\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->fd, sizeof (pp->fd) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, fd),
+ fld_sizeof (IOTrace_packet, fd) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"IONBYTE\" uname=\"Number of bytes\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->nbyte, sizeof (pp->nbyte) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, nbyte),
+ fld_sizeof (IOTrace_packet, nbyte) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"IORQST\" uname=\"Time of IO requested\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->requested, sizeof (pp->requested) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, requested),
+ fld_sizeof (IOTrace_packet, requested) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"IOOFD\" uname=\"Original file descriptor\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->ofd, sizeof (pp->ofd) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, ofd),
+ fld_sizeof (IOTrace_packet, ofd) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"IOFSTYPE\" uname=\"File system type\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->fstype, sizeof (pp->fstype) == 4 ? "INT32" : "INT64");
+ (int) offsetof (IOTrace_packet, fstype),
+ fld_sizeof (IOTrace_packet, fstype) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"IOFNAME\" uname=\"File name\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->fname, "STRING");
+ (int) offsetof (IOTrace_packet, fname), "STRING");
collector_interface->writeLog (" </profpckt>\n");
collector_interface->writeLog ("</profile>\n");
return COL_ERROR_NONE;
diff --git a/gprofng/libcollector/jprofile.c b/gprofng/libcollector/jprofile.c
index 4bec999..130da19 100644
--- a/gprofng/libcollector/jprofile.c
+++ b/gprofng/libcollector/jprofile.c
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <errno.h>
#include <sys/param.h> /* MAXPATHLEN */
-
+#include <stddef.h>
#include <jni.h>
#include <jvmti.h>
@@ -628,8 +628,8 @@ jvmti_ThreadStart (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread)
group_name,
parent_name,
(unsigned long) tid,
- thread,
- jni_env
+ (unsigned long) thread,
+ (unsigned long) jni_env
);
TSD_Entry *tsd = collector_interface->getKey (tsd_key);
if (tsd)
@@ -648,8 +648,8 @@ jvmti_ThreadEnd (jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread)
SP_JCMD_JTHREND,
(unsigned) (hrt / NANOSEC), (unsigned) (hrt % NANOSEC),
(unsigned long) tid,
- thread,
- jni_env
+ (unsigned long) thread,
+ (unsigned long) jni_env
);
TSD_Entry *tsd = collector_interface->getKey (tsd_key);
if (tsd)
diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libcol_util.h
index bb94114..c21b4a4 100644
--- a/gprofng/libcollector/libcol_util.h
+++ b/gprofng/libcollector/libcol_util.h
@@ -38,7 +38,8 @@ extern void __collector_libscf_funcs_init();
/* ------- functions from libcol_util.c ----------------- */
extern void * __collector_memcpy (void *s1, const void *s2, size_t n);
-extern int (*__collector_sscanfp)(const char *restrict s, const char *restrict fmt, ...);
+extern int (*__collector_sscanfp)(const char *restrict s, const char *restrict fmt, ...)
+ __attribute__ ((format (scanf, 2, 3)));
extern char * __collector_strcat (char *s1, const char *s2);
extern char * __collector_strchr (const char *s1, int chr);
extern size_t __collector_strlcpy (char *dst, const char *src, size_t dstsize);
diff --git a/gprofng/libcollector/profile.c b/gprofng/libcollector/profile.c
index 4819d83..02c3e66 100644
--- a/gprofng/libcollector/profile.c
+++ b/gprofng/libcollector/profile.c
@@ -27,6 +27,7 @@
#include "config.h"
#include <dlfcn.h>
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ucontext.h>
@@ -181,22 +182,28 @@ open_experiment (const char *exp)
module_interface.description);
/* Record Profile packet description */
- ClockPacket *cp = NULL;
collector_interface->writeLog (" <profpckt kind=\"%d\" uname=\"" STXT ("Clock profiling data") "\">\n", CLOCK_TYPE);
collector_interface->writeLog (" <field name=\"LWPID\" uname=\"" STXT ("Lightweight process id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &cp->lwp_id, sizeof (cp->lwp_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (ClockPacket, lwp_id),
+ fld_sizeof (ClockPacket, lwp_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"THRID\" uname=\"" STXT ("Thread number") "\" offset=\"%d\" type=\"%s\"/>\n",
- &cp->thr_id, sizeof (cp->thr_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (ClockPacket, thr_id),
+ fld_sizeof (ClockPacket, thr_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"CPUID\" uname=\"" STXT ("CPU id") "\" offset=\"%d\" type=\"%s\"/>\n",
- &cp->cpu_id, sizeof (cp->cpu_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (ClockPacket, cpu_id),
+ fld_sizeof (ClockPacket, cpu_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"TSTAMP\" uname=\"" STXT ("High resolution timestamp") "\" offset=\"%d\" type=\"%s\"/>\n",
- &cp->tstamp, sizeof (cp->tstamp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (ClockPacket, tstamp),
+ fld_sizeof (ClockPacket, tstamp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
- &cp->frinfo, sizeof (cp->frinfo) == 4 ? "INT32" : "INT64");
+ (int) offsetof (ClockPacket, frinfo),
+ fld_sizeof (ClockPacket, frinfo) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"MSTATE\" uname=\"" STXT ("Thread state") "\" offset=\"%d\" type=\"%s\"/>\n",
- &cp->mstate, sizeof (cp->mstate) == 4 ? "INT32" : "INT64");
+ (int) offsetof (ClockPacket, mstate),
+ fld_sizeof (ClockPacket, mstate) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"NTICK\" uname=\"" STXT ("Duration") "\" offset=\"%d\" type=\"%s\"/>\n",
- &cp->nticks, sizeof (cp->nticks) == 4 ? "INT32" : "INT64");
+ (int) offsetof (ClockPacket, nticks),
+ fld_sizeof (ClockPacket, nticks) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" </profpckt>\n");
collector_interface->writeLog ("</profile>\n");
return COL_ERROR_NONE;
diff --git a/gprofng/libcollector/synctrace.c b/gprofng/libcollector/synctrace.c
index 565afbe..4c4d80d 100644
--- a/gprofng/libcollector/synctrace.c
+++ b/gprofng/libcollector/synctrace.c
@@ -26,6 +26,7 @@
#include <dlfcn.h>
#include <unistd.h>
#include <semaphore.h> /* sem_wait() */
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
@@ -252,22 +253,28 @@ open_experiment (const char *exp)
collector_interface->writeLog (" <profdata fname=\"%s\"/>\n",
module_interface.description);
/* Record Sync_packet description */
- Sync_packet *pp = NULL;
collector_interface->writeLog (" <profpckt kind=\"%d\" uname=\"Synchronization tracing data\">\n", SYNC_PCKT);
collector_interface->writeLog (" <field name=\"LWPID\" uname=\"Lightweight process id\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.lwp_id, sizeof (pp->comm.lwp_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Sync_packet, comm.lwp_id),
+ fld_sizeof (Sync_packet, comm.lwp_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"THRID\" uname=\"Thread number\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.thr_id, sizeof (pp->comm.thr_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Sync_packet, comm.thr_id),
+ fld_sizeof (Sync_packet, comm.thr_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"CPUID\" uname=\"CPU id\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.cpu_id, sizeof (pp->comm.cpu_id) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Sync_packet, comm.cpu_id),
+ fld_sizeof (Sync_packet, comm.cpu_id) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"TSTAMP\" uname=\"High resolution timestamp\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.tstamp, sizeof (pp->comm.tstamp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Sync_packet, comm.tstamp),
+ fld_sizeof (Sync_packet, comm.tstamp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"FRINFO\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->comm.frinfo, sizeof (pp->comm.frinfo) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Sync_packet, comm.frinfo),
+ fld_sizeof (Sync_packet, comm.frinfo) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"SRQST\" uname=\"Synchronization start time\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->requested, sizeof (pp->requested) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Sync_packet, requested),
+ fld_sizeof (Sync_packet, requested) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" <field name=\"SOBJ\" uname=\"Synchronization object address\" offset=\"%d\" type=\"%s\"/>\n",
- &pp->objp, sizeof (pp->objp) == 4 ? "INT32" : "INT64");
+ (int) offsetof (Sync_packet, objp),
+ fld_sizeof (Sync_packet, objp) == 4 ? "INT32" : "INT64");
collector_interface->writeLog (" </profpckt>\n");
collector_interface->writeLog ("</profile>\n");
diff --git a/gprofng/src/ClassFile.cc b/gprofng/src/ClassFile.cc
index 0f1d468..d59c963 100644
--- a/gprofng/src/ClassFile.cc
+++ b/gprofng/src/ClassFile.cc
@@ -1594,7 +1594,7 @@ ClassFile::get_disasm (uint64_t inst_address, uint64_t end_address,
{
append_msg (CMSG_ERROR, GTXT ("Cannot disassemble class file %s (%s), implausible size = %lld"),
get_name (), dbeFile->get_location (),
- (end_address - start_address));
+ (long long) (end_address - start_address));
inst_size = 0;
return NULL;
}
diff --git a/gprofng/src/Emsg.h b/gprofng/src/Emsg.h
index bed664b..9dbacea 100644
--- a/gprofng/src/Emsg.h
+++ b/gprofng/src/Emsg.h
@@ -105,7 +105,8 @@ public:
Vector<Emsg*> *msgs;
void remove_msg (Emsg *msg);
Emsg *get_error ();
- Emsg *append_msg (Cmsg_warn w, const char *fmt, ...);
+ Emsg *append_msg (Cmsg_warn w, const char *fmt, ...)
+ __attribute__ ((format (printf, 3, 4)));
void append_msgs (Vector<Emsg*> *lst);
};
diff --git a/gprofng/src/SourceFile.cc b/gprofng/src/SourceFile.cc
index 35629cc..f3809c8 100644
--- a/gprofng/src/SourceFile.cc
+++ b/gprofng/src/SourceFile.cc
@@ -135,7 +135,8 @@ SourceFile::readSource ()
DbeLine *p = v->get (i);
if (p->lineno >= srcLines->size ())
append_msg (CMSG_ERROR, GTXT ("Wrong line number %d. '%s' has only %d lines"),
- p->lineno, dbeFile->get_location (), srcLines->size ());
+ (int) p->lineno, dbeFile->get_location (),
+ (int) srcLines->size ());
}
delete v;
}
@@ -167,7 +168,8 @@ SourceFile::find_dbeline (Function *func, int lineno)
if (dbeLine == NULL)
append_msg (CMSG_ERROR,
GTXT ("Wrong line number %d. '%s' has only %d lines"),
- lineno, dbeFile->get_location (), lines->size ());
+ (int) lineno, dbeFile->get_location (),
+ (int) lines->size ());
}
else
{
diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h
index 07bf362..67dcad6 100644
--- a/gprofng/src/collector_module.h
+++ b/gprofng/src/collector_module.h
@@ -53,7 +53,8 @@ typedef struct CollectorUtilFuncs
char *(*fgets)(char *s, int n, FILE *stream);
FILE *(*fopen)(const char *filename, const char *mode);
pid_t (*vfork)();
- int (*fprintf)(FILE *stream, const char *format, ...);
+ int (*fprintf)(FILE *stream, const char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
void (*free)(void *ptr);
int (*fstat)(int fd, struct stat *buf);
int (*getcontext)(ucontext_t *ucp);
@@ -82,7 +83,8 @@ typedef struct CollectorUtilFuncs
int (*setenv)(const char *name, const char *value, int overwrite);
int (*sigfillset)(sigset_t *set);
int (*sigprocmask)(int how, const sigset_t *set, sigset_t *oldset);
- int (*snprintf)(char *str, size_t size, const char *format, ...);
+ int (*snprintf)(char *str, size_t size, const char *format, ...)
+ __attribute__ ((format (printf, 3, 4)));
int (*stack_getbounds)();
char *(*strchr)(const char *name, int c);
int (*strcmp)(const char *s1, const char *s2);
@@ -168,12 +170,13 @@ typedef struct CollectorInterface
CollectorModule (*registerModule)(struct ModuleInterface*);
const char *(*getParams)();
const char *(*getExpDir)();
- int (*writeLog)(char *format, ...);
+ int (*writeLog)(char *format, ...) __attribute__ ((format (printf, 1, 2)));
FrameInfo (*getFrameInfo)(CollectorModule modl, HiResTime ts, int mode, void *arg);
FrameInfo (*getUID)(CM_Array *arg);
FrameInfo (*getUID2)(CM_Array *arg, FrameInfo uid);
int (*getStackTrace)(void *buf, int size, void *bptr, void *eptr, void *arg);
- int (*writeMetaData)(CollectorModule modl, char *format, ...);
+ int (*writeMetaData)(CollectorModule modl, char *format, ...)
+ __attribute__ ((format (printf, 2, 3)));
/* writeDataRecord ensures that the header is filled in, and then calls writeDataPacket */
int (*writeDataRecord)(CollectorModule modl, struct Common_packet *pckt);
diff --git a/gprofng/src/data_pckts.h b/gprofng/src/data_pckts.h
index 484edae..eecd4e9 100644
--- a/gprofng/src/data_pckts.h
+++ b/gprofng/src/data_pckts.h
@@ -51,6 +51,7 @@ typedef uint32_t Size_type; /* size_t for 32 bit apps */
#define SP_FAILED_UNWIND_MARKER ((uint64_t)(-3))
#define PROFILE_BUFFER_CHUNK 16384
+#define fld_sizeof(t, f) (sizeof (((t *)0)->f))
typedef enum
{