summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--daemon/Makefile.am1
-rw-r--r--daemon/daemon.h3
-rw-r--r--daemon/proto.c6
-rwxr-xr-xsrc/generator.ml20
5 files changed, 29 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 495b8442..a1015476 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,6 +50,7 @@ daemon/actions.h
daemon/guestfsd
daemon/install-sh
daemon/missing
+daemon/names.c
daemon/stubs.c
depcomp
emptydisk
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 8b909c50..141dfadd 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -48,6 +48,7 @@ guestfsd_SOURCES = \
lvm.c \
mknod.c \
mount.c \
+ names.c \
ntfs.c \
pingdaemon.c \
proto.c \
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 553973d9..5f22a4f8 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -55,6 +55,9 @@ extern void udev_settle (void);
extern int verbose;
+/*-- in names.c (auto-generated) --*/
+extern const char *function_names[];
+
/*-- in proto.c --*/
extern int proc_nr;
extern int serial;
diff --git a/daemon/proto.c b/daemon/proto.c
index 39cee5ab..3ca4316a 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -146,8 +146,10 @@ main_loop (int _sock)
start_us = (int64_t) start_t.tv_sec * 1000000 + start_t.tv_usec;
end_us = (int64_t) end_t.tv_sec * 1000000 + end_t.tv_usec;
elapsed_us = end_us - start_us;
- fprintf (stderr, "proc %d serial %d took %d.%02d seconds\n",
- proc_nr, serial,
+ fprintf (stderr, "proc %d (%s) took %d.%02d seconds\n",
+ proc_nr,
+ proc_nr >= 0 && proc_nr < GUESTFS_PROC_NR_PROCS
+ ? function_names[proc_nr] : "UNKNOWN PROCEDURE",
(int) (elapsed_us / 1000000),
(int) ((elapsed_us / 10000) % 100));
}
diff --git a/src/generator.ml b/src/generator.ml
index 29e66513..f41413e8 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -4318,6 +4318,22 @@ and generate_daemon_actions () =
) ["pv", pv_cols; "vg", vg_cols; "lv", lv_cols]
+(* Generate a list of function names, for debugging in the daemon.. *)
+and generate_daemon_names () =
+ generate_header CStyle GPLv2;
+
+ pr "#include <config.h>\n";
+ pr "\n";
+ pr "#include \"daemon.h\"\n";
+ pr "\n";
+
+ pr "/* This array is indexed by proc_nr. See guestfs_protocol.x. */\n";
+ pr "const char *function_names[] = {\n";
+ List.iter (
+ fun (name, _, proc_nr, _, _, _, _) -> pr " [%d] = \"%s\",\n" proc_nr name
+ ) daemon_functions;
+ pr "};\n";
+
(* Generate the tests. *)
and generate_tests () =
generate_header CStyle GPLv2;
@@ -8610,6 +8626,10 @@ Run it from the top source directory using the command
generate_daemon_actions ();
close ();
+ let close = output_to "daemon/names.c" in
+ generate_daemon_names ();
+ close ();
+
let close = output_to "capitests/tests.c" in
generate_tests ();
close ();