perf hists: Catch and handle out-of-date hist entry maps.
[linux-flexiantxendom0.git] / tools / perf / util / hist.c
index 216e33a..e0a0970 100644 (file)
@@ -230,6 +230,18 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
                if (!cmp) {
                        he->period += period;
                        ++he->nr_events;
+
+                       /* If the map of an existing hist_entry has
+                        * become out-of-date due to an exec() or
+                        * similar, update it.  Otherwise we will
+                        * mis-adjust symbol addresses when computing
+                        * the history counter to increment.
+                        */
+                       if (he->ms.map != entry.ms.map) {
+                               he->ms.map = entry.ms.map;
+                               if (he->ms.map)
+                                       he->ms.map->referenced = true;
+                       }
                        goto out;
                }