]> 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 From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2 From: Andrew Cagney <cagney@gnu.org>
3 Date: Fri, 27 Oct 2017 21:07:50 +0200
4 Subject: gdb-6.3-gstack-20050411.patch
5
6 FileName: gdb-6.3-gstack-20050411.patch
7
8 ;; Add a wrapper script to GDB that implements pstack using the
9 ;; --readnever option.
10 ;;=push
11
12 2004-11-23  Andrew Cagney  <cagney@redhat.com>
13
14         * Makefile.in (uninstall-gstack, install-gstack): New rules, add
15         to install and uninstall.
16         * gstack.sh, gstack.1: New files.
17 ---
18  gdb/Makefile.in                   | 34 ++++++++++++++++++--
19  gdb/gstack.sh                     | 43 +++++++++++++++++++++++++
20  gdb/testsuite/gdb.base/gstack.c   | 43 +++++++++++++++++++++++++
21  gdb/testsuite/gdb.base/gstack.exp | 66 +++++++++++++++++++++++++++++++++++++++
22  4 files changed, 184 insertions(+), 2 deletions(-)
23  create mode 100644 gdb/gstack.sh
24  create mode 100644 gdb/testsuite/gdb.base/gstack.c
25  create mode 100644 gdb/testsuite/gdb.base/gstack.exp
26
27 diff --git a/gdb/Makefile.in b/gdb/Makefile.in
28 index 17b71c6e7c..e77d6a5c03 100644
29 --- a/gdb/Makefile.in
30 +++ b/gdb/Makefile.in
31 @@ -1744,7 +1744,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
32  install: all
33         @$(MAKE) $(FLAGS_TO_PASS) install-only
34  
35 -install-only: $(CONFIG_INSTALL)
36 +install-only: install-gstack $(CONFIG_INSTALL)
37         transformed_name=`t='$(program_transform_name)'; \
38                           echo gdb | sed -e "$$t"` ; \
39                 if test "x$$transformed_name" = x; then \
40 @@ -1784,7 +1784,25 @@ install-guile:
41  install-python:
42         $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
43  
44 -uninstall: force $(CONFIG_UNINSTALL)
45 +GSTACK=gstack
46 +.PHONY: install-gstack
47 +install-gstack:
48 +       transformed_name=`t='$(program_transform_name)'; \
49 +                         echo $(GSTACK) | sed -e "$$t"` ; \
50 +               if test "x$$transformed_name" = x; then \
51 +                 transformed_name=$(GSTACK) ; \
52 +               else \
53 +                 true ; \
54 +               fi ; \
55 +               $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \
56 +               $(INSTALL_PROGRAM) $(srcdir)/$(GSTACK).sh \
57 +                       $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \
58 +               : $(SHELL) $(srcdir)/../mkinstalldirs \
59 +                       $(DESTDIR)$(man1dir) ; \
60 +               : $(INSTALL_DATA) $(srcdir)/gstack.1 \
61 +                       $(DESTDIR)$(man1dir)/$$transformed_name.1
62 +
63 +uninstall: force uninstall-gstack $(CONFIG_UNINSTALL)
64         transformed_name=`t='$(program_transform_name)'; \
65                           echo gdb | sed -e $$t` ; \
66                 if test "x$$transformed_name" = x; then \
67 @@ -1807,6 +1825,18 @@ uninstall: force $(CONFIG_UNINSTALL)
68         fi
69         @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
70  
71 +.PHONY: uninstall-gstack
72 +uninstall-gstack:
73 +       transformed_name=`t='$(program_transform_name)'; \
74 +                         echo $(GSTACK) | sed -e $$t` ; \
75 +               if test "x$$transformed_name" = x; then \
76 +                 transformed_name=$(GSTACK) ; \
77 +               else \
78 +                 true ; \
79 +               fi ; \
80 +               rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \
81 +                     $(DESTDIR)$(man1dir)/$$transformed_name.1
82
83  # The C++ name parser can be built standalone for testing.
84  test-cp-name-parser.o: cp-name-parser.c
85         $(COMPILE) -DTEST_CPNAMES cp-name-parser.c
86 diff --git a/gdb/gstack.sh b/gdb/gstack.sh
87 new file mode 100644
88 index 0000000000..f7f07248f7
89 --- /dev/null
90 +++ b/gdb/gstack.sh
91 @@ -0,0 +1,43 @@
92 +#!/bin/sh
93 +
94 +if test $# -ne 1; then
95 +    echo "Usage: `basename $0 .sh` <process-id>" 1>&2
96 +    exit 1
97 +fi
98 +
99 +if test ! -r /proc/$1; then
100 +    echo "Process $1 not found." 1>&2
101 +    exit 1
102 +fi
103 +
104 +# GDB doesn't allow "thread apply all bt" when the process isn't
105 +# threaded; need to peek at the process to determine if that or the
106 +# simpler "bt" should be used.
107 +
108 +backtrace="bt"
109 +if test -d /proc/$1/task ; then
110 +    # Newer kernel; has a task/ directory.
111 +    if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
112 +       backtrace="thread apply all bt"
113 +    fi
114 +elif test -f /proc/$1/maps ; then
115 +    # Older kernel; go by it loading libpthread.
116 +    if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
117 +       backtrace="thread apply all bt"
118 +    fi
119 +fi
120 +
121 +GDB=${GDB:-gdb}
122 +
123 +# Run GDB, strip out unwanted noise.
124 +# --readnever is no longer used since .gdb_index is now in use.
125 +$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <<EOF 2>&1 | 
126 +set width 0
127 +set height 0
128 +set pagination no
129 +$backtrace
130 +EOF
131 +/bin/sed -n \
132 +    -e 's/^\((gdb) \)*//' \
133 +    -e '/^#/p' \
134 +    -e '/^Thread/p'
135 diff --git a/gdb/testsuite/gdb.base/gstack.c b/gdb/testsuite/gdb.base/gstack.c
136 new file mode 100644
137 index 0000000000..dc10813f04
138 --- /dev/null
139 +++ b/gdb/testsuite/gdb.base/gstack.c
140 @@ -0,0 +1,43 @@
141 +/* This testcase is part of GDB, the GNU debugger.
142 +
143 +   Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
144 +
145 +   This program is free software; you can redistribute it and/or modify
146 +   it under the terms of the GNU General Public License as published by
147 +   the Free Software Foundation; either version 3 of the License, or
148 +   (at your option) any later version.
149 +
150 +   This program is distributed in the hope that it will be useful,
151 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
152 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
153 +   GNU General Public License for more details.
154 +
155 +   You should have received a copy of the GNU General Public License
156 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
157 +
158 +#include <stdio.h>
159 +#include <unistd.h>
160 +#include <string.h>
161 +
162 +void
163 +func (void)
164 +{
165 +  const char msg[] = "looping\n";
166 +
167 +  /* Use the most simple notification not to get caught by attach on exiting
168 +     the function.  */
169 +  write (1, msg, strlen (msg));
170 +  
171 +  for (;;);
172 +}
173 +
174 +int
175 +main (void)
176 +{
177 +  alarm (60);
178 +  nice (100);
179 +
180 +  func ();
181 +
182 +  return 0;
183 +}
184 diff --git a/gdb/testsuite/gdb.base/gstack.exp b/gdb/testsuite/gdb.base/gstack.exp
185 new file mode 100644
186 index 0000000000..1186ec57bc
187 --- /dev/null
188 +++ b/gdb/testsuite/gdb.base/gstack.exp
189 @@ -0,0 +1,66 @@
190 +# Copyright (C) 2012 Free Software Foundation, Inc.
191 +
192 +# This program is free software; you can redistribute it and/or modify
193 +# it under the terms of the GNU General Public License as published by
194 +# the Free Software Foundation; either version 3 of the License, or
195 +# (at your option) any later version.
196 +#
197 +# This program is distributed in the hope that it will be useful,
198 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
199 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
200 +# GNU General Public License for more details.
201 +#
202 +# You should have received a copy of the GNU General Public License
203 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
204 +
205 +set testfile gstack
206 +set executable ${testfile}
207 +set binfile [standard_output_file $executable]
208 +if {[build_executable ${testfile} ${executable} "" {debug}] == -1} {
209 +    return -1
210 +}
211 +
212 +set test "spawn inferior"
213 +set command "${binfile}"
214 +set res [remote_spawn host $command];
215 +if { $res < 0 || $res == "" } {
216 +    perror "Spawning $command failed."
217 +    fail $test
218 +    return
219 +}
220 +set use_gdb_stub 1
221 +set pid [exp_pid -i $res]
222 +gdb_expect {
223 +    -re "looping\r\n" {
224 +       pass $test
225 +    }
226 +    eof {
227 +       fail "$test (eof)"
228 +       return
229 +    }
230 +    timeout {
231 +       fail "$test (timeout)"
232 +       return
233 +    }
234 +}
235 +gdb_exit
236 +
237 +# Testcase uses the most simple notification not to get caught by attach on
238 +# exiting the function.  Still we could retry the gstack command if we fail.
239 +
240 +set test "spawn gstack"
241 +set command "sh -c GDB=$GDB\\ GDBARGS=-data-directory\\\\\\ $BUILD_DATA_DIRECTORY\\ sh\\ ${srcdir}/../gstack.sh\\ $pid\\;echo\\ GSTACK-END"
242 +set res [remote_spawn host $command];
243 +if { $res < 0 || $res == "" } {
244 +    perror "Spawning $command failed."
245 +    fail $test
246 +}
247 +set pid [exp_pid -i $res]
248 +gdb_test_multiple "" $test {
249 +    -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\$" {
250 +       pass $test
251 +    }
252 +}
253 +gdb_exit
254 +
255 +remote_exec host "kill -9 $pid"
256 -- 
257 2.14.3
258
This page took 0.077152 seconds and 3 git commands to generate.