summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2014-01-17 23:40:52 (GMT)
committerJason Evans <je@fb.com>2014-01-17 23:40:52 (GMT)
commit772163b4f3d8e9a12343e9215f6b070068507604 (patch)
treefca7a4cfaad0ba53a836ea57f12b5e9f1935d4a1 /src
parenteefdd02e70ec1b9cf11920fcff585835dcbd766b (diff)
downloadjemalloc-772163b4f3d8e9a12343e9215f6b070068507604.zip
jemalloc-772163b4f3d8e9a12343e9215f6b070068507604.tar.gz
jemalloc-772163b4f3d8e9a12343e9215f6b070068507604.tar.bz2
Add heap profiling tests.
Fix a regression in prof_dump_ctx() due to an uninitized variable. This was caused by revision 4f37ef693e3d5903ce07dc0b61c0da320b35e3d9, so no releases are affected.
Diffstat (limited to 'src')
-rw-r--r--src/prof.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/src/prof.c b/src/prof.c
index 0d65212..1d8ccbd 100644
--- a/src/prof.c
+++ b/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. */