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.2.50.20101116/gdb/Makefile.in
8 ===================================================================
9 --- gdb-7.2.50.20101116.orig/gdb/Makefile.in 2010-11-05 15:31:25.000000000 +0100
10 +++ gdb-7.2.50.20101116/gdb/Makefile.in 2010-11-16 07:56:10.000000000 +0100
11 @@ -972,7 +972,7 @@ gdb.z:gdb.1
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 @@ -1008,7 +1008,25 @@ install-tui:
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 @@ -1030,6 +1048,17 @@ uninstall-tui:
49 rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
50 $(DESTDIR)$(man1dir)/$$transformed_name.1
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 Index: gdb-7.2.50.20101116/gdb/gstack.sh
66 ===================================================================
67 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
68 +++ gdb-7.2.50.20101116/gdb/gstack.sh 2010-11-16 07:55:47.000000000 +0100
72 +if test $# -ne 1; then
73 + echo "Usage: `basename $0 .sh` <process-id>" 1>&2
77 +if test ! -r /proc/$1; then
78 + echo "Process $1 not found." 1>&2
82 +# GDB doesn't allow "thread apply all bt" when the process isn't
83 +# threaded; need to peek at the process to determine if that or the
84 +# simpler "bt" should be used.
87 +if test -d /proc/$1/task ; then
88 + # Newer kernel; has a task/ directory.
89 + if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
90 + backtrace="thread apply all bt"
92 +elif test -f /proc/$1/maps ; then
93 + # Older kernel; go by it loading libpthread.
94 + if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
95 + backtrace="thread apply all bt"
99 +GDB=${GDB:-/usr/bin/gdb}
101 +if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then
102 + readnever=--readnever
107 +# Run GDB, strip out unwanted noise.
108 +$GDB --quiet $readnever -nx /proc/$1/exe $1 <<EOF 2>&1 |
115 + -e 's/^\((gdb) \)*//' \
118 Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.exp
119 ===================================================================
120 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
121 +++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.exp 2010-11-16 07:55:47.000000000 +0100
123 +# Copyright (C) 2010 Free Software Foundation, Inc.
125 +# This program is free software; you can redistribute it and/or modify
126 +# it under the terms of the GNU General Public License as published by
127 +# the Free Software Foundation; either version 3 of the License, or
128 +# (at your option) any later version.
130 +# This program is distributed in the hope that it will be useful,
131 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
132 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133 +# GNU General Public License for more details.
135 +# You should have received a copy of the GNU General Public License
136 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
139 +set executable ${testfile}
140 +set binfile ${objdir}/${subdir}/$executable
141 +if {[build_executable ${testfile} ${executable} "" {debug}] == -1} {
145 +set test "spawn inferior"
146 +set command "${binfile}"
147 +set res [remote_spawn host $command];
148 +if { $res < 0 || $res == "" } {
149 + perror "Spawning $command failed."
153 +set pid [exp_pid -i $res]
155 + -re "looping\r\n" {
163 + fail "$test (timeout)"
169 +# Testcase uses the most simple notification not to get caught by attach on
170 +# exiting the function. Still we could retry the gstack command if we fail.
172 +set test "spawn gstack"
173 +set command "sh -c GDB=$GDB\\ sh\\ ${srcdir}/../gstack.sh\\ $pid\\;echo\\ GSTACK-END"
174 +set res [remote_spawn host $command];
175 +if { $res < 0 || $res == "" } {
176 + perror "Spawning $command failed."
179 +set pid [exp_pid -i $res]
181 + -re {^#0 +0x[0-9a-f]+ in \.?func \(\)\r\n#1 +0x[0-9a-f]+ in \.?main \(\)\r\nGSTACK-END\r\n$} {
188 + fail "$test (timeout)"
193 +remote_exec host "kill -9 $pid"
194 Index: gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.c
195 ===================================================================
196 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
197 +++ gdb-7.2.50.20101116/gdb/testsuite/gdb.base/gstack.c 2010-11-16 07:55:47.000000000 +0100
199 +/* This testcase is part of GDB, the GNU debugger.
201 + Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
203 + This program is free software; you can redistribute it and/or modify
204 + it under the terms of the GNU General Public License as published by
205 + the Free Software Foundation; either version 3 of the License, or
206 + (at your option) any later version.
208 + This program is distributed in the hope that it will be useful,
209 + but WITHOUT ANY WARRANTY; without even the implied warranty of
210 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
211 + GNU General Public License for more details.
213 + You should have received a copy of the GNU General Public License
214 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
223 + const char msg[] = "looping\n";
225 + /* Use the most simple notification not to get caught by attach on exiting
227 + write (1, msg, strlen (msg));