1 2004-11-23 Andrew Cagney <cagney@redhat.com>
3 * Makefile.in (uninstall-gstack, install-gstack): New rules, add
4 to install and uninstall.
5 * gstack.sh, gstack.1: New files.
7 Index: gdb-7.7/gdb/Makefile.in
8 ===================================================================
9 --- gdb-7.7.orig/gdb/Makefile.in 2014-02-06 20:29:09.401214339 +0100
10 +++ gdb-7.7/gdb/Makefile.in 2014-02-06 20:29:09.501214360 +0100
11 @@ -1067,7 +1067,7 @@ info install-info clean-info dvi pdf ins
13 @$(MAKE) $(FLAGS_TO_PASS) install-only
15 -install-only: $(CONFIG_INSTALL)
16 +install-only: install-gstack $(CONFIG_INSTALL)
17 transformed_name=`t='$(program_transform_name)'; \
18 echo gdb | sed -e "$$t"` ; \
19 if test "x$$transformed_name" = x; then \
20 @@ -1104,7 +1104,25 @@ install-strip:
22 $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
24 -uninstall: force $(CONFIG_UNINSTALL)
26 +.PHONY: install-gstack
28 + transformed_name=`t='$(program_transform_name)'; \
29 + echo $(GSTACK) | sed -e "$$t"` ; \
30 + if test "x$$transformed_name" = x; then \
31 + transformed_name=$(GSTACK) ; \
35 + $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
36 + $(INSTALL_PROGRAM) $(srcdir)/$(GSTACK).sh \
37 + $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
38 + : $(SHELL) $(srcdir)/../mkinstalldirs \
39 + $(DESTDIR)$(man1dir) ; \
40 + : $(INSTALL_DATA) $(srcdir)/gstack.1 \
41 + $(DESTDIR)$(man1dir)/$$transformed_name.1
43 +uninstall: force uninstall-gstack $(CONFIG_UNINSTALL)
44 transformed_name=`t='$(program_transform_name)'; \
45 echo gdb | sed -e $$t` ; \
46 if test "x$$transformed_name" = x; then \
47 @@ -1127,6 +1145,18 @@ uninstall: force $(CONFIG_UNINSTALL)
49 @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
51 +.PHONY: uninstall-gstack
53 + transformed_name=`t='$(program_transform_name)'; \
54 + echo $(GSTACK) | sed -e $$t` ; \
55 + if test "x$$transformed_name" = x; then \
56 + transformed_name=$(GSTACK) ; \
60 + rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
61 + $(DESTDIR)$(man1dir)/$$transformed_name.1
63 # The C++ name parser can be built standalone for testing.
64 test-cp-name-parser.o: cp-name-parser.c
65 $(COMPILE) -DTEST_CPNAMES cp-name-parser.c
66 Index: gdb-7.7/gdb/gstack.sh
67 ===================================================================
68 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
69 +++ gdb-7.7/gdb/gstack.sh 2014-02-06 20:29:09.501214360 +0100
73 +if test $# -ne 1; then
74 + echo "Usage: `basename $0 .sh` <process-id>" 1>&2
78 +if test ! -r /proc/$1; then
79 + echo "Process $1 not found." 1>&2
83 +# GDB doesn't allow "thread apply all bt" when the process isn't
84 +# threaded; need to peek at the process to determine if that or the
85 +# simpler "bt" should be used.
88 +if test -d /proc/$1/task ; then
89 + # Newer kernel; has a task/ directory.
90 + if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
91 + backtrace="thread apply all bt"
93 +elif test -f /proc/$1/maps ; then
94 + # Older kernel; go by it loading libpthread.
95 + if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
96 + backtrace="thread apply all bt"
100 +GDB=${GDB:-/usr/bin/gdb}
102 +# Run GDB, strip out unwanted noise.
103 +# --readnever is no longer used since .gdb_index is now in use.
104 +$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <<EOF 2>&1 |
111 + -e 's/^\((gdb) \)*//' \
114 Index: gdb-7.7/gdb/testsuite/gdb.base/gstack.exp
115 ===================================================================
116 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
117 +++ gdb-7.7/gdb/testsuite/gdb.base/gstack.exp 2014-02-06 20:43:17.774747352 +0100
119 +# Copyright (C) 2012 Free Software Foundation, Inc.
121 +# This program is free software; you can redistribute it and/or modify
122 +# it under the terms of the GNU General Public License as published by
123 +# the Free Software Foundation; either version 3 of the License, or
124 +# (at your option) any later version.
126 +# This program is distributed in the hope that it will be useful,
127 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
128 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
129 +# GNU General Public License for more details.
131 +# You should have received a copy of the GNU General Public License
132 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
135 +set executable ${testfile}
136 +set binfile [standard_output_file $executable]
137 +if {[build_executable ${testfile} ${executable} "" {debug}] == -1} {
141 +set test "spawn inferior"
142 +set command "${binfile}"
143 +set res [remote_spawn host $command];
144 +if { $res < 0 || $res == "" } {
145 + perror "Spawning $command failed."
150 +set pid [exp_pid -i $res]
152 + -re "looping\r\n" {
160 + fail "$test (timeout)"
166 +# Testcase uses the most simple notification not to get caught by attach on
167 +# exiting the function. Still we could retry the gstack command if we fail.
169 +set test "spawn gstack"
170 +set command "sh -c GDB=$GDB\\ GDBARGS=-data-directory\\\\\\ $BUILD_DATA_DIRECTORY\\ sh\\ ${srcdir}/../gstack.sh\\ $pid\\;echo\\ GSTACK-END"
171 +set res [remote_spawn host $command];
172 +if { $res < 0 || $res == "" } {
173 + perror "Spawning $command failed."
176 +set pid [exp_pid -i $res]
177 +gdb_test_multiple "" $test {
178 + -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\$" {
184 +remote_exec host "kill -9 $pid"
185 Index: gdb-7.7/gdb/testsuite/gdb.base/gstack.c
186 ===================================================================
187 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
188 +++ gdb-7.7/gdb/testsuite/gdb.base/gstack.c 2014-02-06 20:29:09.502214360 +0100
190 +/* This testcase is part of GDB, the GNU debugger.
192 + Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
194 + This program is free software; you can redistribute it and/or modify
195 + it under the terms of the GNU General Public License as published by
196 + the Free Software Foundation; either version 3 of the License, or
197 + (at your option) any later version.
199 + This program is distributed in the hope that it will be useful,
200 + but WITHOUT ANY WARRANTY; without even the implied warranty of
201 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
202 + GNU General Public License for more details.
204 + You should have received a copy of the GNU General Public License
205 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
214 + const char msg[] = "looping\n";
216 + /* Use the most simple notification not to get caught by attach on exiting
218 + write (1, msg, strlen (msg));