Diff of /libpp/parse_filename.cpp [261633] .. [a6d955]  Maximize  Restore

Switch to side-by-side view

--- a/libpp/parse_filename.cpp
+++ b/libpp/parse_filename.cpp
@@ -73,13 +73,18 @@
 
 
 /// Handle an anon region. Pretty print the details.
-string const parse_anon(string const & str)
-{
+/// The second argument is the anon portion of the path which will
+/// contain extra details such as the anon region name (unknown, vdso, heap etc.)
+string const parse_anon(string const & str, string const & str2)
+{
+	string name = str2;
+	name.erase(0,6); // Get rid of "{anon:
+	name.erase(name.size() - 1,1); // Get rid of the trailing '}'
 	vector<string> parts = separate_token(str, '.');
 	if (parts.size() != 3)
 		throw invalid_argument("parse_anon() invalid name: " + str);
 
-	string ret = "anon (tgid:";
+	string ret = name +" (tgid:";
 	ret += parts[0] + " range:" + parts[1] + "-" + parts[2] + ")";
 	return ret;
 }
@@ -93,7 +98,8 @@
  *
  * {kern}/name/event_spec
  * {root}/path/to/bin/{dep}/{root}/path/to/bin/event_spec
- * {root}/path/to/bin/{dep}/{anon}/pid.start.end/event_spec
+ * {root}/path/to/bin/{dep}/{anon:anon}/pid.start.end/event_spec
+ * {root}/path/to/bin/{dep}/{anon:[vdso]}/pid.start.end/event_spec
  * {root}/path/to/bin/{dep}/{kern}/name/event_spec
  * {root}/path/to/bin/{dep}/{root}/path/to/bin/{cg}/{root}/path/to/bin/event_spec
 
@@ -143,14 +149,15 @@
 	++i;
 
 	// PP:3.19 {dep}/ must be followed by {kern}/, {root}/ or {anon}/
-	if (path[i] != "{kern}" && path[i] != "{root}" && path[i] != "{anon}") {
-		throw invalid_argument("parse_filename() invalid filename: " +
-				       filename);
-	}
-
-	bool anon = path[i] == "{anon}";
-
-	// skip "{root}", "{kern}" or "{anon}"
+	if (path[i] != "{kern}" && path[i] != "{root}" &&
+	    path[i].find("{anon", 0) != 0) {
+		throw invalid_argument("parse_filename() invalid filename: " +
+				       filename);
+	}
+
+	bool anon = path[i].find("{anon:" ,0) == 0;
+
+	// skip "{root}", "{kern}" or "{anon:.*}"
 	++i;
 
 	for (; i < path.size(); ++i) {
@@ -158,7 +165,8 @@
 			break;
 
 		if (anon) {
-			result.lib_image = parse_anon(path[i++]);
+		  result.lib_image = parse_anon(path[i], path[i - 1]);
+			i++;
 			break;
 		}
 		result.lib_image += "/" + path[i];
@@ -170,17 +178,19 @@
 	// skip "{cg}"
 	++i;
 	if (i == path.size() ||
-	    (path[i] != "{kern}" && path[i] != "{root}" && path[i] != "{anon}")) {
+	    (path[i] != "{kern}" && path[i] != "{root}" &&
+	     path[i].find("{anon", 0) != 0)) {
 		throw invalid_argument("parse_filename() invalid filename: "
 		                       + filename);
 	}
 
 	// skip "{root}", "{kern}" or "{anon}"
-	anon = path[i] == "{anon}";
+	anon = (path[i].find("{anon",0) == 0);
 	++i;
 
 	if (anon) {
-		result.cg_image = parse_anon(path[i++]);
+		result.cg_image = parse_anon(path[i], path[i - 1]);
+		i++;
 	} else {
 		for (; i < path.size(); ++i)
 			result.cg_image += "/" + path[i];