Add heap profiling tests.
Fix a regression in prof_dump_ctx() due to an uninitized variable. This
was caused by revision 4f37ef693e
, so no
releases are affected.
This commit is contained in:
52
src/prof.c
52
src/prof.c
@@ -646,24 +646,49 @@ prof_lookup(prof_bt_t *bt)
|
||||
return (ret.p);
|
||||
}
|
||||
|
||||
static bool
|
||||
#ifdef JEMALLOC_JET
|
||||
size_t
|
||||
prof_bt_count(void)
|
||||
{
|
||||
size_t bt_count;
|
||||
prof_tdata_t *prof_tdata;
|
||||
|
||||
prof_tdata = prof_tdata_get(false);
|
||||
if ((uintptr_t)prof_tdata <= (uintptr_t)PROF_TDATA_STATE_MAX)
|
||||
return (0);
|
||||
|
||||
prof_enter(prof_tdata);
|
||||
bt_count = ckh_count(&bt2ctx);
|
||||
prof_leave(prof_tdata);
|
||||
|
||||
return (bt_count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef prof_dump_open
|
||||
#define prof_dump_open JEMALLOC_N(prof_dump_open_impl)
|
||||
#endif
|
||||
static int
|
||||
prof_dump_open(bool propagate_err, const char *filename)
|
||||
{
|
||||
int fd;
|
||||
|
||||
prof_dump_fd = creat(filename, 0644);
|
||||
if (prof_dump_fd == -1) {
|
||||
if (propagate_err == false) {
|
||||
malloc_printf(
|
||||
"<jemalloc>: creat(\"%s\"), 0644) failed\n",
|
||||
filename);
|
||||
if (opt_abort)
|
||||
abort();
|
||||
}
|
||||
return (true);
|
||||
fd = creat(filename, 0644);
|
||||
if (fd == -1 && propagate_err == false) {
|
||||
malloc_printf("<jemalloc>: creat(\"%s\"), 0644) failed\n",
|
||||
filename);
|
||||
if (opt_abort)
|
||||
abort();
|
||||
}
|
||||
|
||||
return (false);
|
||||
return (fd);
|
||||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef prof_dump_open
|
||||
#define prof_dump_open JEMALLOC_N(prof_dump_open)
|
||||
prof_dump_open_t *prof_dump_open = JEMALLOC_N(prof_dump_open_impl);
|
||||
#endif
|
||||
|
||||
static bool
|
||||
prof_dump_flush(bool propagate_err)
|
||||
@@ -895,6 +920,7 @@ prof_dump_ctx(bool propagate_err, prof_ctx_t *ctx, const prof_bt_t *bt,
|
||||
goto label_return;
|
||||
}
|
||||
|
||||
ret = false;
|
||||
label_return:
|
||||
prof_dump_ctx_cleanup_locked(ctx, ctx_ql);
|
||||
malloc_mutex_unlock(ctx->lock);
|
||||
@@ -995,7 +1021,7 @@ prof_dump(bool propagate_err, const char *filename, bool leakcheck)
|
||||
prof_leave(prof_tdata);
|
||||
|
||||
/* Create dump file. */
|
||||
if (prof_dump_open(propagate_err, filename))
|
||||
if ((prof_dump_fd = prof_dump_open(propagate_err, filename)) == -1)
|
||||
goto label_open_close_error;
|
||||
|
||||
/* Dump profile header. */
|
||||
|
Reference in New Issue
Block a user