summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2011-06-22 14:48:26 +0200
committerPetr Mladek <pmladek@suse.cz>2011-06-22 14:48:26 +0200
commitdfe7581607e67ced5ff0fce9973b6f2fcd3dee62 (patch)
tree31c9531e667551fbfbf78b102532141850f6f035
parent3768ced8096af7ff6a50c89b2cae8694684d586c (diff)
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
-rw-r--r--desktop/prj/d.lst1
-rw-r--r--desktop/scripts/gdbtrace12
-rwxr-xr-xdesktop/scripts/makefile.mk3
-rwxr-xr-xdesktop/scripts/soffice.sh62
4 files changed, 76 insertions, 2 deletions
diff --git a/desktop/prj/d.lst b/desktop/prj/d.lst
index 9fa248f290..047b46d334 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 0000000000..548ffe6512
--- /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 5c412f8187..ce0c9b8ed2 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 5dd7882953..c203c2833c 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" "$@"