|
|
7a6771 |
2004-11-23 Andrew Cagney <cagney@redhat.com>
|
|
|
7a6771 |
|
|
|
7a6771 |
* Makefile.in (uninstall-gstack, install-gstack): New rules, add
|
|
|
7a6771 |
to install and uninstall.
|
|
|
7a6771 |
* gstack.sh, gstack.1: New files.
|
|
|
7a6771 |
|
|
|
7a6771 |
Index: gdb-7.7/gdb/Makefile.in
|
|
|
7a6771 |
===================================================================
|
|
|
7a6771 |
--- gdb-7.7.orig/gdb/Makefile.in 2014-02-06 20:29:09.401214339 +0100
|
|
|
7a6771 |
+++ gdb-7.7/gdb/Makefile.in 2014-02-06 20:29:09.501214360 +0100
|
|
|
7a6771 |
@@ -1067,7 +1067,7 @@ info install-info clean-info dvi pdf ins
|
|
|
7a6771 |
install: all
|
|
|
7a6771 |
@$(MAKE) $(FLAGS_TO_PASS) install-only
|
|
|
7a6771 |
|
|
|
7a6771 |
-install-only: $(CONFIG_INSTALL)
|
|
|
7a6771 |
+install-only: install-gstack $(CONFIG_INSTALL)
|
|
|
7a6771 |
transformed_name=`t='$(program_transform_name)'; \
|
|
|
7a6771 |
echo gdb | sed -e "$$t"` ; \
|
|
|
7a6771 |
if test "x$$transformed_name" = x; then \
|
|
|
7a6771 |
@@ -1104,7 +1104,25 @@ install-strip:
|
|
|
7a6771 |
install-python:
|
|
|
7a6771 |
$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
|
|
|
7a6771 |
|
|
|
7a6771 |
-uninstall: force $(CONFIG_UNINSTALL)
|
|
|
7a6771 |
+GSTACK=gstack
|
|
|
7a6771 |
+.PHONY: install-gstack
|
|
|
7a6771 |
+install-gstack:
|
|
|
7a6771 |
+ transformed_name=`t='$(program_transform_name)'; \
|
|
|
7a6771 |
+ echo $(GSTACK) | sed -e "$$t"` ; \
|
|
|
7a6771 |
+ if test "x$$transformed_name" = x; then \
|
|
|
7a6771 |
+ transformed_name=$(GSTACK) ; \
|
|
|
7a6771 |
+ else \
|
|
|
7a6771 |
+ true ; \
|
|
|
7a6771 |
+ fi ; \
|
|
|
7a6771 |
+ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
|
|
|
7a6771 |
+ $(INSTALL_PROGRAM) $(srcdir)/$(GSTACK).sh \
|
|
|
7a6771 |
+ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
|
|
|
7a6771 |
+ : $(SHELL) $(srcdir)/../mkinstalldirs \
|
|
|
7a6771 |
+ $(DESTDIR)$(man1dir) ; \
|
|
|
7a6771 |
+ : $(INSTALL_DATA) $(srcdir)/gstack.1 \
|
|
|
7a6771 |
+ $(DESTDIR)$(man1dir)/$$transformed_name.1
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+uninstall: force uninstall-gstack $(CONFIG_UNINSTALL)
|
|
|
7a6771 |
transformed_name=`t='$(program_transform_name)'; \
|
|
|
7a6771 |
echo gdb | sed -e $$t` ; \
|
|
|
7a6771 |
if test "x$$transformed_name" = x; then \
|
|
|
7a6771 |
@@ -1127,6 +1145,18 @@ uninstall: force $(CONFIG_UNINSTALL)
|
|
|
7a6771 |
fi
|
|
|
7a6771 |
@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
|
|
|
7a6771 |
|
|
|
7a6771 |
+.PHONY: uninstall-gstack
|
|
|
7a6771 |
+uninstall-gstack:
|
|
|
7a6771 |
+ transformed_name=`t='$(program_transform_name)'; \
|
|
|
7a6771 |
+ echo $(GSTACK) | sed -e $$t` ; \
|
|
|
7a6771 |
+ if test "x$$transformed_name" = x; then \
|
|
|
7a6771 |
+ transformed_name=$(GSTACK) ; \
|
|
|
7a6771 |
+ else \
|
|
|
7a6771 |
+ true ; \
|
|
|
7a6771 |
+ fi ; \
|
|
|
7a6771 |
+ rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
|
|
|
7a6771 |
+ $(DESTDIR)$(man1dir)/$$transformed_name.1
|
|
|
7a6771 |
+
|
|
|
7a6771 |
# The C++ name parser can be built standalone for testing.
|
|
|
7a6771 |
test-cp-name-parser.o: cp-name-parser.c
|
|
|
7a6771 |
$(COMPILE) -DTEST_CPNAMES cp-name-parser.c
|
|
|
7a6771 |
Index: gdb-7.7/gdb/gstack.sh
|
|
|
7a6771 |
===================================================================
|
|
|
7a6771 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
7a6771 |
+++ gdb-7.7/gdb/gstack.sh 2014-02-06 20:29:09.501214360 +0100
|
|
|
7a6771 |
@@ -0,0 +1,43 @@
|
|
|
7a6771 |
+#!/bin/sh
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+if test $# -ne 1; then
|
|
|
7a6771 |
+ echo "Usage: `basename $0 .sh` <process-id>" 1>&2
|
|
|
7a6771 |
+ exit 1
|
|
|
7a6771 |
+fi
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+if test ! -r /proc/$1; then
|
|
|
7a6771 |
+ echo "Process $1 not found." 1>&2
|
|
|
7a6771 |
+ exit 1
|
|
|
7a6771 |
+fi
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+# GDB doesn't allow "thread apply all bt" when the process isn't
|
|
|
7a6771 |
+# threaded; need to peek at the process to determine if that or the
|
|
|
7a6771 |
+# simpler "bt" should be used.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+backtrace="bt"
|
|
|
7a6771 |
+if test -d /proc/$1/task ; then
|
|
|
7a6771 |
+ # Newer kernel; has a task/ directory.
|
|
|
7a6771 |
+ if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
|
|
|
7a6771 |
+ backtrace="thread apply all bt"
|
|
|
7a6771 |
+ fi
|
|
|
7a6771 |
+elif test -f /proc/$1/maps ; then
|
|
|
7a6771 |
+ # Older kernel; go by it loading libpthread.
|
|
|
7a6771 |
+ if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
|
|
|
7a6771 |
+ backtrace="thread apply all bt"
|
|
|
7a6771 |
+ fi
|
|
|
7a6771 |
+fi
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+GDB=${GDB:-gdb}
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+# Run GDB, strip out unwanted noise.
|
|
|
7a6771 |
+# --readnever is no longer used since .gdb_index is now in use.
|
|
|
7a6771 |
+$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <<EOF 2>&1 |
|
|
|
7a6771 |
+set width 0
|
|
|
7a6771 |
+set height 0
|
|
|
7a6771 |
+set pagination no
|
|
|
7a6771 |
+$backtrace
|
|
|
7a6771 |
+EOF
|
|
|
7a6771 |
+/bin/sed -n \
|
|
|
7a6771 |
+ -e 's/^\((gdb) \)*//' \
|
|
|
7a6771 |
+ -e '/^#/p' \
|
|
|
7a6771 |
+ -e '/^Thread/p'
|
|
|
7a6771 |
Index: gdb-7.7/gdb/testsuite/gdb.base/gstack.exp
|
|
|
7a6771 |
===================================================================
|
|
|
7a6771 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
7a6771 |
+++ gdb-7.7/gdb/testsuite/gdb.base/gstack.exp 2014-02-06 20:43:17.774747352 +0100
|
|
|
7a6771 |
@@ -0,0 +1,66 @@
|
|
|
7a6771 |
+# Copyright (C) 2012 Free Software Foundation, Inc.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
7a6771 |
+# it under the terms of the GNU General Public License as published by
|
|
|
7a6771 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
7a6771 |
+# (at your option) any later version.
|
|
|
7a6771 |
+#
|
|
|
7a6771 |
+# This program is distributed in the hope that it will be useful,
|
|
|
7a6771 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7a6771 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
7a6771 |
+# GNU General Public License for more details.
|
|
|
7a6771 |
+#
|
|
|
7a6771 |
+# You should have received a copy of the GNU General Public License
|
|
|
7a6771 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+set testfile gstack
|
|
|
7a6771 |
+set executable ${testfile}
|
|
|
7a6771 |
+set binfile [standard_output_file $executable]
|
|
|
7a6771 |
+if {[build_executable ${testfile} ${executable} "" {debug}] == -1} {
|
|
|
7a6771 |
+ return -1
|
|
|
7a6771 |
+}
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+set test "spawn inferior"
|
|
|
7a6771 |
+set command "${binfile}"
|
|
|
7a6771 |
+set res [remote_spawn host $command];
|
|
|
7a6771 |
+if { $res < 0 || $res == "" } {
|
|
|
7a6771 |
+ perror "Spawning $command failed."
|
|
|
7a6771 |
+ fail $test
|
|
|
7a6771 |
+ return
|
|
|
7a6771 |
+}
|
|
|
7a6771 |
+set use_gdb_stub 1
|
|
|
7a6771 |
+set pid [exp_pid -i $res]
|
|
|
7a6771 |
+gdb_expect {
|
|
|
7a6771 |
+ -re "looping\r\n" {
|
|
|
7a6771 |
+ pass $test
|
|
|
7a6771 |
+ }
|
|
|
7a6771 |
+ eof {
|
|
|
7a6771 |
+ fail "$test (eof)"
|
|
|
7a6771 |
+ return
|
|
|
7a6771 |
+ }
|
|
|
7a6771 |
+ timeout {
|
|
|
7a6771 |
+ fail "$test (timeout)"
|
|
|
7a6771 |
+ return
|
|
|
7a6771 |
+ }
|
|
|
7a6771 |
+}
|
|
|
7a6771 |
+gdb_exit
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+# Testcase uses the most simple notification not to get caught by attach on
|
|
|
7a6771 |
+# exiting the function. Still we could retry the gstack command if we fail.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+set test "spawn gstack"
|
|
|
7a6771 |
+set command "sh -c GDB=$GDB\\ GDBARGS=-data-directory\\\\\\ $BUILD_DATA_DIRECTORY\\ sh\\ ${srcdir}/../gstack.sh\\ $pid\\;echo\\ GSTACK-END"
|
|
|
7a6771 |
+set res [remote_spawn host $command];
|
|
|
7a6771 |
+if { $res < 0 || $res == "" } {
|
|
|
7a6771 |
+ perror "Spawning $command failed."
|
|
|
7a6771 |
+ fail $test
|
|
|
7a6771 |
+}
|
|
|
7a6771 |
+set pid [exp_pid -i $res]
|
|
|
7a6771 |
+gdb_test_multiple "" $test {
|
|
|
7a6771 |
+ -re "^#0 +(0x\[0-9a-f\]+ in )?\\.?func \\(\\) at \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in \\.?main \\(\\) at \[^\r\n\]*\r\nGSTACK-END\r\n\$" {
|
|
|
7a6771 |
+ pass $test
|
|
|
7a6771 |
+ }
|
|
|
7a6771 |
+}
|
|
|
7a6771 |
+gdb_exit
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+remote_exec host "kill -9 $pid"
|
|
|
7a6771 |
Index: gdb-7.7/gdb/testsuite/gdb.base/gstack.c
|
|
|
7a6771 |
===================================================================
|
|
|
7a6771 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
7a6771 |
+++ gdb-7.7/gdb/testsuite/gdb.base/gstack.c 2014-02-06 20:29:09.502214360 +0100
|
|
|
7a6771 |
@@ -0,0 +1,43 @@
|
|
|
7a6771 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
7a6771 |
+ it under the terms of the GNU General Public License as published by
|
|
|
7a6771 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
7a6771 |
+ (at your option) any later version.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ This program is distributed in the hope that it will be useful,
|
|
|
7a6771 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7a6771 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
7a6771 |
+ GNU General Public License for more details.
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ You should have received a copy of the GNU General Public License
|
|
|
7a6771 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+#include <stdio.h>
|
|
|
7a6771 |
+#include <unistd.h>
|
|
|
7a6771 |
+#include <string.h>
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+void
|
|
|
7a6771 |
+func (void)
|
|
|
7a6771 |
+{
|
|
|
7a6771 |
+ const char msg[] = "looping\n";
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ /* Use the most simple notification not to get caught by attach on exiting
|
|
|
7a6771 |
+ the function. */
|
|
|
7a6771 |
+ write (1, msg, strlen (msg));
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ for (;;);
|
|
|
7a6771 |
+}
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+int
|
|
|
7a6771 |
+main (void)
|
|
|
7a6771 |
+{
|
|
|
7a6771 |
+ alarm (60);
|
|
|
7a6771 |
+ nice (100);
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ func ();
|
|
|
7a6771 |
+
|
|
|
7a6771 |
+ return 0;
|
|
|
7a6771 |
+}
|