hal: Branch 'origin'

Holger Macht homac at kemper.freedesktop.org
Mon Dec 4 02:11:58 PST 2006


 hald/.gitignore     |    1 +
 hald/hald.c         |   13 ++++++++++++-
 hald/massif-hald.sh |   29 +++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

New commits:
diff-tree e3996a7b5fa880657458494ef4a4f99ed6d4fe5e (from 0aa15edea346a236441cf8bc2a5e7e53f8da7398)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 30 21:42:29 2006 +0000

    add --retain-privileges so we can use massif
    
    I've been using massif, with local HAL patches to make it work -
    I've found you can't drop privs, else massif won't write the output
    files.
    The default of dropping privs is the same as before.

diff --git a/hald/.gitignore b/hald/.gitignore
index b5a7e69..f70abcb 100644
--- a/hald/.gitignore
+++ b/hald/.gitignore
@@ -9,3 +9,4 @@ hald_marshal.h
 *.o
 *~
 .local-fdi
+massif.*
diff --git a/hald/hald.c b/hald/hald.c
index 44ee2bf..4e3c8da 100644
--- a/hald/hald.c
+++ b/hald/hald.c
@@ -213,6 +213,7 @@ usage ()
 		 "\n"
 		 "        --daemon=yes|no       Become a daemon\n"
 		 "        --verbose=yes|no      Print out debug (overrides HALD_VERBOSE)\n"
+		 "        --retain-privileges   Retain privileges (for debugging)\n"
  		 "        --use-syslog          Print out debug messages to syslog instead of\n"
 		 "                              stderr. Use this option to get debug messages\n"
 		 "                              if hald runs as a daemon.\n"
@@ -232,6 +233,9 @@ usage ()
 /** If #TRUE, we will daemonize */
 static dbus_bool_t opt_become_daemon = TRUE;
 
+/** If #TRUE, we will retain privs */
+static dbus_bool_t opt_retain_privileges = FALSE;
+
 /** If #TRUE, we will spew out debug */
 dbus_bool_t hald_is_verbose = FALSE;
 dbus_bool_t hald_use_syslog = FALSE;
@@ -408,6 +412,7 @@ main (int argc, char *argv[])
 			{"exit-after-probing", 0, NULL, 0},
 			{"daemon", 1, NULL, 0},
 			{"verbose", 1, NULL, 0},
+			{"retain-privileges", 0, NULL, 0},
 			{"use-syslog", 0, NULL, 0},
 			{"help", 0, NULL, 0},
 			{"version", 0, NULL, 0},
@@ -449,6 +454,8 @@ main (int argc, char *argv[])
 					usage ();
 					return 1;
 				}
+			} else if (strcmp (opt, "retain-privileges") == 0) {
+                                opt_retain_privileges = TRUE;
 			} else if (strcmp (opt, "use-syslog") == 0) {
                                 hald_use_syslog = TRUE;
 			}
@@ -581,7 +588,11 @@ main (int argc, char *argv[])
 	/* initialize privileged operating system specific parts */
 	osspec_privileged_init ();
 
-	drop_privileges(0);
+	/* sometimes we don't want to drop root privs, for instance
+	   if we are profiling memory usage */
+	if (opt_retain_privileges == FALSE) {
+		drop_privileges(0);
+	}
 
 	/* initialize operating system specific parts */
 	osspec_init ();
diff --git a/hald/massif-hald.sh b/hald/massif-hald.sh
new file mode 100755
index 0000000..f53396c
--- /dev/null
+++ b/hald/massif-hald.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+export HALD_RUNNER_PATH=`pwd`/linux:`pwd`/linux/probing:`pwd`/linux/addons:`pwd`/.:`pwd`/../tools:`pwd`/../tools/linux
+export PATH=`pwd`/../hald-runner:$PATH
+
+if [ "$1" = "--skip-fdi-install" ] ; then
+    shift
+else
+    rm -rf .local-fdi
+    make -C ../fdi install DESTDIR=`pwd`/.local-fdi prefix=/
+fi
+export HAL_FDI_SOURCE_PREPROBE=.local-fdi/share/hal/fdi/preprobe
+export HAL_FDI_SOURCE_INFORMATION=.local-fdi/share/hal/fdi/information
+export HAL_FDI_SOURCE_POLICY=.local-fdi/share/hal/fdi/policy
+
+#delete all old memory outputs, else we get hundreds
+rm massif.*
+
+valgrind --tool=massif --format=html --depth=10 \
+	 --alloc-fn=g_malloc --alloc-fn=g_realloc \
+	 --alloc-fn=g_try_malloc --alloc-fn=g_malloc0 --alloc-fn=g_mem_chunk_alloc \
+	 ./hald --daemon=no --verbose=yes --retain-privileges --exit-after-probing
+
+#massif uses the pid file, which is hard to process.
+mv massif.*.html massif.html
+mv massif.*.ps massif.ps
+#convert to pdf, and make readable by normal users
+ps2pdf massif.ps massif.pdf
+chmod a+r massif.*


More information about the hal-commit mailing list