From: Dawid Kuczma Date: Mon, 6 Nov 2017 12:50:59 +0000 (+0100) Subject: Add tool for processing graph generated by busctl dot. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=213ebe9817a3da7c531dcd5d12e68947ec73adcf;p=platform%2Fupstream%2Fsystemd.git Add tool for processing graph generated by busctl dot. Usage: 1) gvpr -f graphinfo.gvpr input_file 2) gvpr -f graphinfo.gvpr input_file -a node -a NODE 3) gvpr -f graphinfo.gvpr input_file -a -node -a NODE Change-Id: Ie4d05c715df17b61c8c7ad1f7724977c9c2f8bb8 --- diff --git a/Makefile.am b/Makefile.am index a43131d..9bc325a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4880,6 +4880,7 @@ BUSNAMES_TARGET_WANTS += \ org.freedesktop.locale1.busname dist_pkgdata_DATA = \ + src/libsystemd/sd-bus/graphinfo.gvpr \ src/locale/kbd-model-map \ src/locale/language-fallback-map diff --git a/packaging/systemd.spec b/packaging/systemd.spec index 100b191..18762bb 100644 --- a/packaging/systemd.spec +++ b/packaging/systemd.spec @@ -514,6 +514,7 @@ fi %{_sbindir}/telinit %{_sbindir}/runlevel %{_sbindir}/udevadm +%{_datadir}/systemd/graphinfo.gvpr %{_datadir}/systemd/kbd-model-map %{_datadir}/systemd/language-fallback-map %{_datadir}/dbus-1/services/org.freedesktop.systemd1.service diff --git a/src/libsystemd/sd-bus/graphinfo.gvpr b/src/libsystemd/sd-bus/graphinfo.gvpr new file mode 100644 index 0000000..c7e0249 --- /dev/null +++ b/src/libsystemd/sd-bus/graphinfo.gvpr @@ -0,0 +1,85 @@ +BEGIN { + string node_to_print = ""; + string pid_to_print = ""; + int edge_count[]; + string result[string]; + string e; + int interface = 0; + string exclude_node[string]; + + int not_excluded_node(edge_t edg) { + if(!strcmp(exclude_node[edg.tail.name], edg.tail.name) || !strcmp(exclude_node[edg.head.name], edg.head.name)) + return 0; + return 1; + } + + void print_interface(edge_t edg) { + string attribute[int]; + count = split(edg.label , attribute); + if (!strcmp(attribute[0], "signal")) { + attribute[0] = sprintf("%s \\n %s", attribute[0], attribute[2]); + } + e = edg.tail.name + edg.head.name + attribute[0]; + edge_count[e] = edge_count[e] + 1; + result[e] = sprintf("\t\"%s\" -> \"%s\" [ label = \" %s \\n %d\" ];\n", edg.tail.name, edg.head.name, attribute[0], edge_count[e]); + } + + void print_basic(edge_t edg) { + e = edg.name + edg.label; + edge_count[e] = edge_count[e] + 1; + result[e] = sprintf("\t\"%s\" -> \"%s\" [ label = \"%s \\n %d\" ];\n", edg.tail.name, edg.head.name, edg.label, edge_count[e]); + } + +} + +BEG_G { + printf("digraph {\n\trankdir=LR\n"); + int arg; + for (arg = 0; arg < ARGC; arg++) { + if (!strcmp(ARGV[arg], "interface")) { + interface = 1; + } + if (!strcmp(ARGV[arg], "node")) { + arg++; + if (arg < ARGC) + node_to_print = ARGV[arg]; + } + if (!strcmp(ARGV[arg], "-node")) { + arg++; + if (arg < ARGC) + exclude_node[ARGV[arg]] = ARGV[arg]; + } + } +} + +E { + if (ARGC > 0) { + if (not_excluded_node($)) { + if (strcmp("", node_to_print)) { + if (!strcmp(node_to_print, $.tail.name) || !strcmp(node_to_print, $.head.name)) { + if (interface) + print_interface($); + else + print_basic($); + } + } + else { + if (interface) + print_interface($); + else + print_basic($); + } + } + } + else + print_basic($); +} + + +END_G { + string var; + for(result[var]) { + printf("%s", result[var]); + } + printf("}\n"); +}