[Libreoffice-commits] .: desktop/prj desktop/scripts

Petr Mladek pmladek at kemper.freedesktop.org
Wed Jun 22 05:51:03 PDT 2011


 desktop/prj/d.lst           |    1 
 desktop/scripts/gdbtrace    |   12 ++++++++
 desktop/scripts/makefile.mk |    3 +-
 desktop/scripts/soffice.sh  |   62 +++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 76 insertions(+), 2 deletions(-)

New commits:
commit dfe7581607e67ced5ff0fce9973b6f2fcd3dee62
Author: Petr Mladek <pmladek at suse.cz>
Date:   Wed Jun 22 14:48:26 2011 +0200

    add --backtrace, --strace, and --valgring option to soffice wrapper
    
    the change is only for Linux; it will help users to provide the needed debug
    info; thanks Kendy for the idea

diff --git a/desktop/prj/d.lst b/desktop/prj/d.lst
index 9fa248f..047b46d 100644
--- a/desktop/prj/d.lst
+++ b/desktop/prj/d.lst
@@ -110,6 +110,7 @@ mkdir: %_DEST%\bin\odf4ms
 ..\%__SRC%\misc\swriter.sh %_DEST%\bin\swriter
 ..\%__SRC%\misc\nswrapper.sh %_DEST%\bin\nswrapper
 ..\%__SRC%\misc\mozwrapper.sh %_DEST%\bin\mozwrapper
+..\%__SRC%\misc\gdbtrace %_DEST%\bin\gdbtrace
 
 mkdir: %COMMON_DEST%\pck\brand
 mkdir: %COMMON_DEST%\pck\brand_dev
diff --git a/desktop/scripts/gdbtrace b/desktop/scripts/gdbtrace
new file mode 100644
index 0000000..548ffe6
--- /dev/null
+++ b/desktop/scripts/gdbtrace
@@ -0,0 +1,12 @@
+set pagination off
+echo log will be saved as gdbtrace.log, this will take some time, patience...\n
+set logging redirect on
+set logging file gdbtrace.log
+set logging on
+set logging overwrite on
+run
+bt
+thread apply all bt
+quit
+set logging off
+echo log is saved as gdbtrace.log\n
diff --git a/desktop/scripts/makefile.mk b/desktop/scripts/makefile.mk
index 5c412f8..ce0c9b8 100755
--- a/desktop/scripts/makefile.mk
+++ b/desktop/scripts/makefile.mk
@@ -47,7 +47,8 @@ UNIXTEXT= \
     $(MISC)$/swriter.sh \
     $(MISC)$/mozwrapper.sh \
     $(MISC)$/unoinfo.sh \
-    $(MISC)$/unopkg.sh
+    $(MISC)$/unopkg.sh \
+    $(MISC)$/gdbtrace
 
 .IF "$(OS)" != "MACOSX"
 
diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh
index 5dd7882..c203c28 100755
--- a/desktop/scripts/soffice.sh
+++ b/desktop/scripts/soffice.sh
@@ -72,6 +72,61 @@ if [ -e $sd_prog/ooenv ] ; then
     . $sd_prog/ooenv
 fi
 
+# try to get some debug output?
+GDBTRACECHECK=
+STRACECHECK=
+VALGRINDCHECK=
+
+# count number of selected checks; only one is allowed
+checks=
+# force the --valgrind option if the VALGRIND variable is set
+test -n "$VALGRIND" && VALGRINDOPT="--vagrind" || VALGRINDOPT=
+
+for arg in $@ $VALGRINDOPT ; do
+    case "$arg" in
+        --backtrace)
+            if which gdb >/dev/null 2>&1 ; then
+                GDBTRACECHECK="gdb -nx --command=$sd_prog/gdbtrace --args"
+                checks="c$checks"
+            else
+                echo "Error: Can't find the tool \"gdb\", --backtrace option will be ignored."
+                exit 1
+            fi
+            ;;
+        --strace)
+            if which strace >/dev/null 2>&1 ; then
+                STRACECHECK="strace -o strace.log -f -tt -s 256"
+                checks="c$checks"
+            else
+                echo "Error: Can't find the tool \"strace\", --strace option will be ignored."
+                exit 1;
+            fi
+            ;;
+         --valgrind)
+            test -n "$VALGRINDCHECK" && continue;
+            if which valgrind >/dev/null 2>&1 ; then
+                # another valgrind tool might be forced via the environment variable
+                test -z "$VALGRIND" && VALGRIND="memcheck"
+                VALGRINDCHECK="valgrind --tool=$VALGRIND --log-file=valgrind.log --trace-children=yes --num-callers=50 --error-exitcode=101"
+                checks="c$checks"
+                if [ "$VALGRIND" = "memcheck" ] ; then
+                    export G_SLICE=always-malloc
+                    export GLIBCXX_FORCE_NEW=1
+                fi
+            else
+                echo "Error: Can't find the tool \"valgrind\", --valgrind option will be ignored"
+                exit 1
+            fi
+            ;;
+    esac
+done
+
+if echo "$checks" | grep -q "cc" ; then
+    echo "Error: The debug options --backtrace, --strace, and --valgrind cannot be used together."
+    echo "       Please, use them one by one."
+    exit 1;
+fi
+
 if [ "$VALGRIND" != "" ]; then
     VALGRINDCHECK="valgrind --tool=$VALGRIND --trace-children=yes --trace-children-skip=*/java --error-exitcode=101"
     export VALGRINDCHECK
@@ -101,5 +156,10 @@ AIX)
     ;;
 esac
 
+# run soffice.bin directly when you want to get the backtrace
+if [ -n "$GDBTRACECHECK" ] ; then
+    exec $GDBTRACECHECK "$sd_prog/soffice.bin" "$@"
+fi
+
 # oosplash does the rest: forcing pages in, javaldx etc. are
-exec $VALGRINDCHECK "$sd_prog/oosplash.bin" "$@"
+exec $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash.bin" "$@"


More information about the Libreoffice-commits mailing list