summaryrefslogtreecommitdiffstats
path: root/src/analyze/analyze-plot.c
diff options
context:
space:
mode:
authorJade Lovelace <software@lfcode.ca>2023-10-01 07:21:33 +0200
committerJade Lovelace <software@lfcode.ca>2023-10-04 07:50:25 +0200
commitebaf55499ff975b8c2507bd68b17ea22ba2f2cee (patch)
tree9d4d641cd6437b5774d0b26e2d202e0bd8f24a9a /src/analyze/analyze-plot.c
parentlogind: add HANDLE_ACTION_IS_SLEEP() and HANDLE_ACTION_IS_SHUTDOWN() helpers (diff)
downloadsystemd-ebaf55499ff975b8c2507bd68b17ea22ba2f2cee.tar.xz
systemd-ebaf55499ff975b8c2507bd68b17ea22ba2f2cee.zip
analyze: add tooltips with dependency information to "plot"
This helps a lot with figuring out why units were started when they were, rather than guessing there is a dependency relation. We could perhaps also do fun JavaScript things in the future to highlight dependencies on mouse-over.
Diffstat (limited to 'src/analyze/analyze-plot.c')
-rw-r--r--src/analyze/analyze-plot.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/analyze/analyze-plot.c b/src/analyze/analyze-plot.c
index 0fbe17465e..81fc25b31e 100644
--- a/src/analyze/analyze-plot.c
+++ b/src/analyze/analyze-plot.c
@@ -1,13 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include "analyze.h"
#include "analyze-plot.h"
#include "analyze-time-data.h"
+#include "analyze.h"
#include "bus-error.h"
#include "bus-map-properties.h"
#include "format-table.h"
#include "os-util.h"
#include "sort-util.h"
+#include "strv.h"
+#include "unit-def.h"
#include "version.h"
#define SCALE_X (0.1 / 1000.0) /* pixels per us */
@@ -158,12 +160,32 @@ static void svg_graph_box(double height, double begin, double end) {
SCALE_Y * height);
}
}
+
+static void plot_tooltip(const UnitTimes *ut) {
+ assert(ut);
+ assert(ut->name);
+
+ svg("%s:\n", ut->name);
+
+ UnitDependency i;
+ VA_ARGS_FOREACH(i, UNIT_AFTER, UNIT_BEFORE, UNIT_REQUIRES, UNIT_REQUISITE, UNIT_WANTS, UNIT_CONFLICTS, UNIT_UPHOLDS)
+ if (!strv_isempty(ut->deps[i])) {
+ svg("\n%s:\n", unit_dependency_to_string(i));
+ STRV_FOREACH(s, ut->deps[i])
+ svg(" %s\n", *s);
+ }
+}
+
static int plot_unit_times(UnitTimes *u, double width, int y) {
bool b;
if (!u->name)
return 0;
+ svg("<g>\n");
+ svg("<title>");
+ plot_tooltip(u);
+ svg("</title>\n");
svg_bar("activating", u->activating, u->activated, y);
svg_bar("active", u->activated, u->deactivating, y);
svg_bar("deactivating", u->deactivating, u->deactivated, y);
@@ -175,6 +197,7 @@ static int plot_unit_times(UnitTimes *u, double width, int y) {
u->name, FORMAT_TIMESPAN(u->time, USEC_PER_MSEC));
else
svg_text(b, u->activating, y, "%s", u->name);
+ svg("</g>\n");
return 1;
}
@@ -220,7 +243,7 @@ static int produce_plot_as_svg(
double text_start, text_width;
if (u->activating > boot->finish_time) {
- u->name = mfree(u->name);
+ unit_times_clear(u);
continue;
}