]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.3-gstack-20050411.patch
- updated to 14.1 + rebased Fedora buildid patches set
[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.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
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 @@ -1104,7 +1104,25 @@ install-strip:
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 @@ -1127,6 +1145,18 @@ uninstall: force $(CONFIG_UNINSTALL)
48         fi
49         @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
50  
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         $(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
70 @@ -0,0 +1,43 @@
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.
90 +    if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
91 +       backtrace="thread apply all bt"
92 +    fi
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"
97 +    fi
98 +fi
99 +
100 +GDB=${GDB:-/usr/bin/gdb}
101 +
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 | 
105 +set width 0
106 +set height 0
107 +set pagination no
108 +$backtrace
109 +EOF
110 +/bin/sed -n \
111 +    -e 's/^\((gdb) \)*//' \
112 +    -e '/^#/p' \
113 +    -e '/^Thread/p'
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
118 @@ -0,0 +1,66 @@
119 +# Copyright (C) 2012 Free Software Foundation, Inc.
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 [standard_output_file $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 +}
149 +set use_gdb_stub 1
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\\ 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."
174 +    fail $test
175 +}
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\$" {
179 +       pass $test
180 +    }
181 +}
182 +gdb_exit
183 +
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
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 +}
This page took 0.09525 seconds and 3 git commands to generate.