]>
Commit | Line | Data |
---|---|---|
3a58abaf AM |
1 | 2004-11-23 Andrew Cagney <cagney@redhat.com> |
2 | ||
3 | * Makefile.in (uninstall-gstack, install-gstack): New rules, add | |
4 | to install and uninstall. | |
5 | * gstack.sh, gstack.1: New files. | |
6 | ||
f412e1b4 | 7 | Index: gdb-7.4.50.20120103/gdb/Makefile.in |
3a58abaf | 8 | =================================================================== |
f412e1b4 PS |
9 | --- gdb-7.4.50.20120103.orig/gdb/Makefile.in 2012-01-03 05:52:15.000000000 +0100 |
10 | +++ gdb-7.4.50.20120103/gdb/Makefile.in 2012-01-03 05:53:25.974210230 +0100 | |
11 | @@ -1017,7 +1017,7 @@ gdb.z:gdb.1 | |
6ed6bacf AM |
12 | install: all |
13 | @$(MAKE) $(FLAGS_TO_PASS) install-only | |
3a58abaf | 14 | |
6ed6bacf AM |
15 | -install-only: $(CONFIG_INSTALL) |
16 | +install-only: install-gstack $(CONFIG_INSTALL) | |
3a58abaf AM |
17 | transformed_name=`t='$(program_transform_name)'; \ |
18 | echo gdb | sed -e "$$t"` ; \ | |
19 | if test "x$$transformed_name" = x; then \ | |
f412e1b4 | 20 | @@ -1039,7 +1039,25 @@ install-only: $(CONFIG_INSTALL) |
51a5ef0f PS |
21 | install-python: |
22 | $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb | |
23 | ||
24 | -uninstall: force $(CONFIG_UNINSTALL) | |
3a58abaf AM |
25 | +GSTACK=gstack |
26 | +.PHONY: install-gstack | |
27 | +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) ; \ | |
32 | + else \ | |
33 | + true ; \ | |
34 | + fi ; \ | |
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 | |
51a5ef0f | 42 | + |
3a58abaf AM |
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 \ | |
f412e1b4 | 47 | @@ -1051,6 +1069,18 @@ uninstall: force $(CONFIG_UNINSTALL) |
3a58abaf | 48 | $(DESTDIR)$(man1dir)/$$transformed_name.1 |
f412e1b4 PS |
49 | @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do |
50 | ||
3a58abaf AM |
51 | +.PHONY: uninstall-gstack |
52 | +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) ; \ | |
57 | + else \ | |
58 | + true ; \ | |
59 | + fi ; \ | |
60 | + rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \ | |
61 | + $(DESTDIR)$(man1dir)/$$transformed_name.1 | |
f412e1b4 | 62 | + |
3a58abaf AM |
63 | # The C++ name parser can be built standalone for testing. |
64 | test-cp-name-parser.o: cp-name-parser.c | |
f412e1b4 PS |
65 | $(COMPILE) -DTEST_CPNAMES cp-name-parser.c |
66 | Index: gdb-7.4.50.20120103/gdb/gstack.sh | |
3a58abaf AM |
67 | =================================================================== |
68 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | |
f412e1b4 PS |
69 | +++ gdb-7.4.50.20120103/gdb/gstack.sh 2012-01-03 05:52:37.278385632 +0100 |
70 | @@ -0,0 +1,43 @@ | |
3a58abaf AM |
71 | +#!/bin/sh |
72 | + | |
73 | +if test $# -ne 1; then | |
74 | + echo "Usage: `basename $0 .sh` <process-id>" 1>&2 | |
75 | + exit 1 | |
76 | +fi | |
77 | + | |
78 | +if test ! -r /proc/$1; then | |
79 | + echo "Process $1 not found." 1>&2 | |
80 | + exit 1 | |
81 | +fi | |
82 | + | |
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. | |
86 | + | |
87 | +backtrace="bt" | |
88 | +if test -d /proc/$1/task ; then | |
89 | + # Newer kernel; has a task/ directory. | |
51a5ef0f | 90 | + if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then |
3a58abaf AM |
91 | + backtrace="thread apply all bt" |
92 | + fi | |
93 | +elif test -f /proc/$1/maps ; then | |
94 | + # Older kernel; go by it loading libpthread. | |
51a5ef0f | 95 | + if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then |
3a58abaf AM |
96 | + backtrace="thread apply all bt" |
97 | + fi | |
98 | +fi | |
99 | + | |
51a5ef0f | 100 | +GDB=${GDB:-/usr/bin/gdb} |
3a58abaf | 101 | + |
3a58abaf | 102 | +# Run GDB, strip out unwanted noise. |
f412e1b4 PS |
103 | +# --readnever is no longer used since .gdb_index is now in use. |
104 | +$GDB --quiet -nx /proc/$1/exe $1 <<EOF 2>&1 | | |
7566401a ER |
105 | +set width 0 |
106 | +set height 0 | |
107 | +set pagination no | |
3a58abaf AM |
108 | +$backtrace |
109 | +EOF | |
51a5ef0f PS |
110 | +/bin/sed -n \ |
111 | + -e 's/^\((gdb) \)*//' \ | |
3a58abaf AM |
112 | + -e '/^#/p' \ |
113 | + -e '/^Thread/p' | |
f412e1b4 | 114 | Index: gdb-7.4.50.20120103/gdb/testsuite/gdb.base/gstack.exp |
51a5ef0f PS |
115 | =================================================================== |
116 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | |
f412e1b4 PS |
117 | +++ gdb-7.4.50.20120103/gdb/testsuite/gdb.base/gstack.exp 2012-01-03 05:52:37.279385629 +0100 |
118 | @@ -0,0 +1,66 @@ | |
119 | +# Copyright (C) 2012 Free Software Foundation, Inc. | |
51a5ef0f PS |
120 | + |
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. | |
125 | +# | |
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. | |
130 | +# | |
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/>. | |
133 | + | |
134 | +set testfile gstack | |
135 | +set executable ${testfile} | |
136 | +set binfile ${objdir}/${subdir}/$executable | |
137 | +if {[build_executable ${testfile} ${executable} "" {debug}] == -1} { | |
138 | + return -1 | |
139 | +} | |
140 | + | |
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." | |
146 | + fail $test | |
147 | + return | |
148 | +} | |
f412e1b4 | 149 | +set use_gdb_stub 1 |
51a5ef0f PS |
150 | +set pid [exp_pid -i $res] |
151 | +gdb_expect { | |
152 | + -re "looping\r\n" { | |
153 | + pass $test | |
154 | + } | |
155 | + eof { | |
156 | + fail "$test (eof)" | |
157 | + return | |
158 | + } | |
159 | + timeout { | |
160 | + fail "$test (timeout)" | |
161 | + return | |
162 | + } | |
163 | +} | |
164 | +gdb_exit | |
165 | + | |
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. | |
168 | + | |
169 | +set test "spawn gstack" | |
170 | +set command "sh -c GDB=$GDB\\ 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." | |
174 | + fail $test | |
175 | +} | |
176 | +set pid [exp_pid -i $res] | |
f412e1b4 PS |
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\$" { | |
51a5ef0f PS |
179 | + pass $test |
180 | + } | |
51a5ef0f PS |
181 | +} |
182 | +gdb_exit | |
183 | + | |
184 | +remote_exec host "kill -9 $pid" | |
f412e1b4 | 185 | Index: gdb-7.4.50.20120103/gdb/testsuite/gdb.base/gstack.c |
51a5ef0f PS |
186 | =================================================================== |
187 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | |
f412e1b4 | 188 | +++ gdb-7.4.50.20120103/gdb/testsuite/gdb.base/gstack.c 2012-01-03 05:52:37.279385629 +0100 |
51a5ef0f PS |
189 | @@ -0,0 +1,43 @@ |
190 | +/* This testcase is part of GDB, the GNU debugger. | |
191 | + | |
192 | + Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc. | |
193 | + | |
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. | |
198 | + | |
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. | |
203 | + | |
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/>. */ | |
206 | + | |
207 | +#include <stdio.h> | |
208 | +#include <unistd.h> | |
209 | +#include <string.h> | |
210 | + | |
211 | +void | |
212 | +func (void) | |
213 | +{ | |
214 | + const char msg[] = "looping\n"; | |
215 | + | |
216 | + /* Use the most simple notification not to get caught by attach on exiting | |
217 | + the function. */ | |
218 | + write (1, msg, strlen (msg)); | |
219 | + | |
220 | + for (;;); | |
221 | +} | |
222 | + | |
223 | +int | |
224 | +main (void) | |
225 | +{ | |
226 | + alarm (60); | |
227 | + nice (100); | |
228 | + | |
229 | + func (); | |
230 | + | |
231 | + return 0; | |
232 | +} |