]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.3-gstack-20050411.patch
- up to 7.3.1
[packages/gdb.git] / gdb-6.3-gstack-20050411.patch
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
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
12  install: all
13         @$(MAKE) $(FLAGS_TO_PASS) install-only
14  
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:
21  install-python:
22         $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
23  
24 -uninstall: force $(CONFIG_UNINSTALL)
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
42 +
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:
48                 fi ; \
49                 rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
50                       $(DESTDIR)$(man1dir)/$$transformed_name.1
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
62  
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
69 @@ -0,0 +1,48 @@
70 +#!/bin/sh
71 +
72 +if test $# -ne 1; then
73 +    echo "Usage: `basename $0 .sh` <process-id>" 1>&2
74 +    exit 1
75 +fi
76 +
77 +if test ! -r /proc/$1; then
78 +    echo "Process $1 not found." 1>&2
79 +    exit 1
80 +fi
81 +
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.
85 +
86 +backtrace="bt"
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"
91 +    fi
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"
96 +    fi
97 +fi
98 +
99 +GDB=${GDB:-/usr/bin/gdb}
100 +
101 +if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then
102 +    readnever=--readnever
103 +else
104 +    readnever=
105 +fi
106 +
107 +# Run GDB, strip out unwanted noise.
108 +$GDB --quiet $readnever -nx /proc/$1/exe $1 <<EOF 2>&1 | 
109 +set width 0
110 +set height 0
111 +set pagination no
112 +$backtrace
113 +EOF
114 +/bin/sed -n \
115 +    -e 's/^\((gdb) \)*//' \
116 +    -e '/^#/p' \
117 +    -e '/^Thread/p'
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
122 @@ -0,0 +1,71 @@
123 +# Copyright (C) 2010 Free Software Foundation, Inc.
124 +
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.
129 +#
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.
134 +#
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/>.
137 +
138 +set testfile gstack
139 +set executable ${testfile}
140 +set binfile ${objdir}/${subdir}/$executable
141 +if {[build_executable ${testfile} ${executable} "" {debug}] == -1} {
142 +    return -1
143 +}
144 +
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."
150 +    fail $test
151 +    return
152 +}
153 +set pid [exp_pid -i $res]
154 +gdb_expect {
155 +    -re "looping\r\n" {
156 +       pass $test
157 +    }
158 +    eof {
159 +       fail "$test (eof)"
160 +       return
161 +    }
162 +    timeout {
163 +       fail "$test (timeout)"
164 +       return
165 +    }
166 +}
167 +gdb_exit
168 +
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.
171 +
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."
177 +    fail $test
178 +}
179 +set pid [exp_pid -i $res]
180 +gdb_expect {
181 +    -re {^#0 +0x[0-9a-f]+ in \.?func \(\)\r\n#1 +0x[0-9a-f]+ in \.?main \(\)\r\nGSTACK-END\r\n$} {
182 +       pass $test
183 +    }
184 +    eof {
185 +       fail "$test (eof)"
186 +    }
187 +    timeout {
188 +       fail "$test (timeout)"
189 +    }
190 +}
191 +gdb_exit
192 +
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
198 @@ -0,0 +1,43 @@
199 +/* This testcase is part of GDB, the GNU debugger.
200 +
201 +   Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
202 +
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.
207 +
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.
212 +
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/>.  */
215 +
216 +#include <stdio.h>
217 +#include <unistd.h>
218 +#include <string.h>
219 +
220 +void
221 +func (void)
222 +{
223 +  const char msg[] = "looping\n";
224 +
225 +  /* Use the most simple notification not to get caught by attach on exiting
226 +     the function.  */
227 +  write (1, msg, strlen (msg));
228 +  
229 +  for (;;);
230 +}
231 +
232 +int
233 +main (void)
234 +{
235 +  alarm (60);
236 +  nice (100);
237 +
238 +  func ();
239 +
240 +  return 0;
241 +}
This page took 0.048638 seconds and 3 git commands to generate.