Skip to content

Commit

Permalink
Merge branch 'gpp-build-time-warnings-20210505'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeenan committed May 9, 2021
2 parents 6b4bbed + 5d852c1 commit 487b044
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions FileHandle.xs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ NYTP_write_attribute_nv(NYTP_file ofile, const char *key,
size_t key_len, NV value)
{
char buffer[NV_DIG+20]; /* see Perl_sv_2pv_flags */
const size_t len = my_snprintf(buffer, sizeof(buffer), "%"NVgf, value);
const size_t len = my_snprintf(buffer, sizeof(buffer), "%" NVgf, value);

return NYTP_write_attribute_string(ofile, key, key_len, buffer, len);
}
Expand All @@ -989,7 +989,7 @@ NYTP_write_option_iv(NYTP_file ofile, const char *key, IV value)
{
/* 3: 1 for rounding errors, 1 for the sign, 1 for the '\0' */
char buffer[(int)(sizeof (IV) * CHAR_BIT * LOG_2_OVER_LOG_10 + 3)];
const size_t len = my_snprintf(buffer, sizeof(buffer), "%"IVdf, value);
const size_t len = my_snprintf(buffer, sizeof(buffer), "%" IVdf, value);

return NYTP_write_option_pv(ofile, key, buffer, len);
}
Expand Down
3 changes: 2 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ $mm_opts{PREREQ_PM} = {
if (my $gccversion = $Config{gccversion}) { # ask gcc to be more pedantic
print "Your perl was compiled with gcc (version $Config{gccversion}), okay.\n";
$gccversion =~ s/[^\d\.]//g; # just a number please
$mm_opts{DEFINE} .= ' -W -Wall -Wpointer-arith -Wbad-function-cast';
$mm_opts{DEFINE} .= ' -W -Wall -Wpointer-arith';
$mm_opts{DEFINE} .= ' -Wbad-function-cast' unless $Config{d_cplusplus};
$mm_opts{DEFINE} .= ' -Wno-comment -Wno-sign-compare -Wno-cast-qual';
$mm_opts{DEFINE} .= ' -Wmissing-noreturn -Wno-unused-parameter' if $gccversion ge "3.0";
if ($is_developer && $opt_g) {
Expand Down
43 changes: 24 additions & 19 deletions NYTProf.xs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static char PROF_output_file[MAXPATHLEN+1] = "nytprof.out";
static unsigned int profile_opts = NYTP_OPTf_OPTIMIZE | NYTP_OPTf_SAVESRC;
static int profile_start = NYTP_START_BEGIN; /* when to start profiling */

static char *nytp_panic_overflow_msg_fmt = "panic: buffer overflow of %s on '%s' (see TROUBLESHOOTING section of the NYTProf documentation)";
static char const *nytp_panic_overflow_msg_fmt = "panic: buffer overflow of %s on '%s' (see TROUBLESHOOTING section of the NYTProf documentation)";

struct NYTP_options_t {
const char *option_name;
Expand Down Expand Up @@ -1352,7 +1352,12 @@ start_cop_of_context(pTHX_ PERL_CONTEXT *cx)
/* find next cop from OP */
o = start_op;
while ( o && (type = (o->op_type) ? o->op_type : (int)o->op_targ) ) {
if (type == OP_NEXTSTATE || type == OP_SETSTATE || type == OP_DBSTATE) {
if (type == OP_NEXTSTATE ||
#if PERL_VERSION < 11
type == OP_SETSTATE ||
#endif
type == OP_DBSTATE)
{
if (trace_level >= trace)
logwarn("\tstart_cop_of_context %s is %s line %d of %s\n",
cx_block_type(cx), OP_NAME(o), (int)CopLINE((COP*)o),
Expand Down Expand Up @@ -1838,7 +1843,7 @@ open_output_file(pTHX_ char *filename)
if ((profile_opts & NYTP_OPTf_ADDPID) || out)
sprintf(&filename_buf[strlen(filename_buf)], ".%d", getpid());
if ( profile_opts & NYTP_OPTf_ADDTIMESTAMP )
sprintf(&filename_buf[strlen(filename_buf)], ".%.0"NVff"", gettimeofday_nv());
sprintf(&filename_buf[strlen(filename_buf)], ".%.0" NVff, gettimeofday_nv());
filename = filename_buf;
/* caller is expected to have purged/closed old out if appropriate */
}
Expand All @@ -1857,7 +1862,7 @@ open_output_file(pTHX_ char *filename)
filename, fopen_errno, strerror(fopen_errno), hint);
}
if (trace_level >= 1)
logwarn("~ opened %s at %.6"NVff"\n", filename, gettimeofday_nv());
logwarn("~ opened %s at %.6" NVff "\n", filename, gettimeofday_nv());

output_header(aTHX);
}
Expand Down Expand Up @@ -1887,7 +1892,7 @@ close_output_file(pTHX) {
out = NULL;

if (trace_level >= 1)
logwarn("~ closed file at %.6"NVff"\n", timeofday);
logwarn("~ closed file at %.6" NVff "\n", timeofday);
}


Expand All @@ -1901,7 +1906,7 @@ reinit_if_forked(pTHX)

/* we're now the child process */
if (trace_level >= 1)
logwarn("~ new pid %d (was %d) forkdepth %"IVdf"\n", getpid(), last_pid, profile_forkdepth);
logwarn("~ new pid %d (was %d) forkdepth %" IVdf "\n", getpid(), last_pid, profile_forkdepth);

/* reset state */
last_pid = getpid();
Expand Down Expand Up @@ -2226,7 +2231,7 @@ incr_sub_inclusive_time(pTHX_ subr_entry_t *subr_entry)
}

if (trace_level >= 5) {
logwarn("%2u <- %s %"NVgf" excl = %"NVgf"t incl - %"NVgf"t (%"NVgf"-%"NVgf"), oh %"NVff"-%"NVff"=%"NVff"t, d%d @%d:%d #%lu %p\n",
logwarn("%2u <- %s %" NVgf " excl = %" NVgf "t incl - %" NVgf "t (%" NVgf "-%" NVgf "), oh %" NVff "-%" NVff "=%" NVff "t, d%d @%d:%d #%lu %p\n",
(unsigned int)subr_entry->subr_prof_depth, called_subname_pv,
excl_subr_ticks, incl_subr_ticks,
called_sub_ticks,
Expand Down Expand Up @@ -2402,7 +2407,7 @@ subr_entry_setup(pTHX_ COP *prev_cop, subr_entry_t *clone_subr_entry, OPCODE op_

if (subr_entry_ix <= prev_subr_entry_ix) {
/* one cause of this is running NYTProf with threads */
logwarn("NYTProf panic: stack is confused, giving up! (Try running with subs=0) ix=%"IVdf" prev_ix=%"IVdf"\n", (IV)subr_entry_ix, (IV)prev_subr_entry_ix);
logwarn("NYTProf panic: stack is confused, giving up! (Try running with subs=0) ix=%" IVdf " prev_ix=%" IVdf "\n", (IV)subr_entry_ix, (IV)prev_subr_entry_ix);
/* limit the damage */
disable_profile(aTHX);
return prev_subr_entry_ix;
Expand Down Expand Up @@ -2892,7 +2897,7 @@ pp_subcall_profiler(pTHX_ int is_slowop)
subr_entry->already_counted++;

if (trace_level >= 4) {
logwarn("%2u ->%4s %s::%s from %s::%s @%u:%u (d%d, oh %"NVff"t, sub %"NVff"s) #%lu\n",
logwarn("%2u ->%4s %s::%s from %s::%s @%u:%u (d%d, oh %" NVff "t, sub %" NVff "s) #%lu\n",
(unsigned int)subr_entry->subr_prof_depth,
(subr_entry->called_is_xs) ? subr_entry->called_is_xs : "sub",
subr_entry->called_subpkg_pv,
Expand Down Expand Up @@ -3028,7 +3033,7 @@ disable_profile(pTHX)
is_profiling = 0;
}
if (trace_level)
logwarn("~ disable_profile (previously %s, pid %d, trace %"IVdf")\n",
logwarn("~ disable_profile (previously %s, pid %d, trace %" IVdf ")\n",
prev_is_profiling ? "enabled" : "disabled", getpid(), trace_level);
return prev_is_profiling;
}
Expand All @@ -3048,7 +3053,7 @@ finish_profile(pTHX)
#endif

if (trace_level >= 1)
logwarn("~ finish_profile (overhead %"NVgf"t, is_profiling %d)\n",
logwarn("~ finish_profile (overhead %" NVgf "t, is_profiling %d)\n",
cumulative_overhead_ticks, is_profiling);

/* write data for final statement, unless DB_leave has already */
Expand Down Expand Up @@ -3676,7 +3681,7 @@ write_sub_callers(pTHX)
if (sc[NYTP_SCi_INCL_RTIME] < 0.0 || sc[NYTP_SCi_EXCL_RTIME] < 0.0) {
++negative_time_calls;
if (trace_level) {
logwarn("%s call has negative time: incl %"NVff"s, excl %"NVff"s:\n",
logwarn("%s call has negative time: incl %" NVff "s, excl %" NVff "s:\n",
called_subname, sc[NYTP_SCi_INCL_RTIME], sc[NYTP_SCi_EXCL_RTIME]);
trace = 1;
}
Expand All @@ -3687,7 +3692,7 @@ write_sub_callers(pTHX)
logwarn("%s is xsub\n", called_subname);
}
else {
logwarn("%s called by %.*s at %u:%u: count %ld (i%"NVff"s e%"NVff"s, d%d ri%"NVff"s)\n",
logwarn("%s called by %.*s at %u:%u: count %ld (i%" NVff "s e%" NVff "s, d%d ri%" NVff "s)\n",
called_subname, (int)caller_subname_len, caller_subname, fid, line,
(long)sc[NYTP_SCi_CALL_COUNT], sc[NYTP_SCi_INCL_RTIME], sc[NYTP_SCi_EXCL_RTIME],
(int)sc[NYTP_SCi_REC_DEPTH], sc[NYTP_SCi_RECI_RTIME]);
Expand Down Expand Up @@ -4276,7 +4281,7 @@ load_sub_callers_callback(Loader_state_base *cb_data, const int tag, ...)
normalize_eval_seqn(aTHX_ called_subname_sv);

if (trace_level >= 6)
logwarn("Sub %s called by %s %u:%u: count %d, incl %"NVff", excl %"NVff"\n",
logwarn("Sub %s called by %s %u:%u: count %d, incl %" NVff ", excl %" NVff "\n",
SvPV_nolen(called_subname_sv), SvPV_nolen(caller_subname_sv),
fid, line, count, incl_time, excl_time);

Expand Down Expand Up @@ -4398,7 +4403,7 @@ load_pid_start_callback(Loader_state_base *cb_data, const int tag, ...)
len = sprintf(text, "%d", pid);
(void)hv_store(state->live_pids_hv, text, len, newSVuv(ppid), 0);
if (trace_level)
logwarn("Start of profile data for pid %s (ppid %d, %"IVdf" pids live) at %"NVff"\n",
logwarn("Start of profile data for pid %s (ppid %d, %" IVdf " pids live) at %" NVff "\n",
text, ppid, (IV)HvKEYS(state->live_pids_hv), start_time);

store_attrib_sv(aTHX_ state->attr_hv, STR_WITH_LEN("profiler_start_time"),
Expand Down Expand Up @@ -4430,7 +4435,7 @@ load_pid_end_callback(Loader_state_base *cb_data, const int tag, ...)
logwarn("Inconsistent pids in profile data (pid %d not introduced)\n",
pid);
if (trace_level)
logwarn("End of profile data for pid %s (%"IVdf" remaining) at %"NVff"\n", text,
logwarn("End of profile data for pid %s (%" IVdf " remaining) at %" NVff "\n", text,
(IV)HvKEYS(state->live_pids_hv), state->profiler_end_time);

store_attrib_sv(aTHX_ state->attr_hv, STR_WITH_LEN("profiler_end_time"),
Expand Down Expand Up @@ -5001,7 +5006,7 @@ load_profile_to_hv(pTHX_ NYTP_file in)


if (HvKEYS(state.live_pids_hv)) {
logwarn("Profile data incomplete, no terminator for %"IVdf" pids %s\n",
logwarn("Profile data incomplete, no terminator for %" IVdf " pids %s\n",
(IV)HvKEYS(state.live_pids_hv),
"(refer to TROUBLESHOOTING in the NYTProf documentation)");
store_attrib_sv(aTHX_ state.attr_hv, STR_WITH_LEN("complete"),
Expand Down Expand Up @@ -5043,15 +5048,15 @@ load_profile_to_hv(pTHX_ NYTP_file in)
&& state.profiler_duration != 0.0
#endif
) {
logwarn("The sum of the statement timings is %.1"NVff"%% of the total time profiling."
logwarn("The sum of the statement timings is %.1" NVff "%% of the total time profiling."
" (Values slightly over 100%% can be due simply to cumulative timing errors,"
" whereas larger values can indicate a problem with the clock used.)\n",
state.total_stmts_duration / state.profiler_duration * 100);
show_summary_stats = 1;
}

if (show_summary_stats)
logwarn("Summary: statements profiled %lu (=%lu-%lu), sum of time %"NVff"s, profile spanned %"NVff"s\n",
logwarn("Summary: statements profiled %lu (=%lu-%lu), sum of time %" NVff "s, profile spanned %" NVff "s\n",
(unsigned long)(state.total_stmts_measured - state.total_stmts_discounted),
(unsigned long)state.total_stmts_measured, (unsigned long)state.total_stmts_discounted,
state.total_stmts_duration,
Expand Down

0 comments on commit 487b044

Please sign in to comment.