--- a/libop/op_mangle.c
+++ b/libop/op_mangle.c
@@ -19,12 +19,14 @@
 #include "op_sample_file.h"
 #include "op_config.h"
 
-static void append_image(char * dest, int flags, int anon, char const * name)
+static void append_image(char * dest, int flags, int anon, char const * name, char const * anon_name)
 {
 	if ((flags & MANGLE_KERNEL) && !strchr(name, '/')) {
 		strcat(dest, "{kern}/");
 	} else if (anon) {
-		strcat(dest, "{anon}/");
+		strcat(dest, "{anon:");
+		strcat(dest, anon_name);
+		strcat(dest,"}/");
 	} else {
 		strcat(dest, "{root}/");
 	}
@@ -44,6 +46,7 @@
 	 * them), see P:3, FIXME: this is a bit weirds, we prolly need to
 	 * reword pp_interface */
 	char const * image_name = values->dep_name;
+	char const * anon_name = values->anon_name;
 	char const * dep_name = values->image_name;
 	char const * cg_image_name = values->cg_image_name;
 
@@ -53,6 +56,9 @@
 	if (values->flags & MANGLE_CALLGRAPH)
 		len += strlen(cg_image_name) + 1;
 
+	if (anon || cg_anon)
+		len += strlen(anon_name);
+
 	/* provision for tgid, tid, unit_mask, cpu and some {root}, {dep},
 	 * {kern}, {anon} and {cg} marker */
 	/* FIXME: too ugly */
@@ -61,14 +67,15 @@
 	mangled = xmalloc(len);
 
 	strcpy(mangled, op_samples_current_dir);
-	append_image(mangled, values->flags, 0, image_name);
+	append_image(mangled, values->flags, 0, image_name, anon_name);
 
 	strcat(mangled, "{dep}" "/");
-	append_image(mangled, values->flags, anon, dep_name);
+	append_image(mangled, values->flags, anon, dep_name, anon_name);
 
 	if (values->flags & MANGLE_CALLGRAPH) {
 		strcat(mangled, "{cg}" "/");
-		append_image(mangled, values->flags, cg_anon, cg_image_name);
+		append_image(mangled, values->flags, cg_anon,
+		             cg_image_name, anon_name);
 	}
 
 	strcat(mangled, values->event_name);