Change-Id: I39a9908c5c84fe0e064dbfd8c022eb4cfd3bb263
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3293
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,233 @@ |
| 0 |
+2017-07-19 Rui Gu <ruig@vmware.com> |
|
| 1 |
+ |
|
| 2 |
+ * Makefile.in (uninstall-pstack, install-pstack): New rules, add |
|
| 3 |
+ to install and uninstall. |
|
| 4 |
+ * pstack.sh, pstack.1: New files. |
|
| 5 |
+ |
|
| 6 |
+Index: gdb-7.12/gdb/Makefile.in |
|
| 7 |
+=================================================================== |
|
| 8 |
+--- gdb-7.12.orig/gdb/Makefile.in 2014-02-06 20:29:09.401214339 +0100 |
|
| 9 |
+@@ -1067,7 +1067,7 @@ info install-info clean-info dvi pdf ins |
|
| 10 |
+ install: all |
|
| 11 |
+ @$(MAKE) $(FLAGS_TO_PASS) install-only |
|
| 12 |
+ |
|
| 13 |
+-install-only: $(CONFIG_INSTALL) |
|
| 14 |
++install-only: install-pstack $(CONFIG_INSTALL) |
|
| 15 |
+ transformed_name=`t='$(program_transform_name)'; \ |
|
| 16 |
+ echo gdb | sed -e "$$t"` ; \ |
|
| 17 |
+ if test "x$$transformed_name" = x; then \ |
|
| 18 |
+@@ -1104,7 +1104,25 @@ install-strip: |
|
| 19 |
+ install-python: |
|
| 20 |
+ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb |
|
| 21 |
+ |
|
| 22 |
+-uninstall: force $(CONFIG_UNINSTALL) |
|
| 23 |
++PSTACK=pstack |
|
| 24 |
++.PHONY: install-pstack |
|
| 25 |
++install-pstack: |
|
| 26 |
++ transformed_name=`t='$(program_transform_name)'; \ |
|
| 27 |
++ echo $(PSTACK) | sed -e "$$t"` ; \ |
|
| 28 |
++ if test "x$$transformed_name" = x; then \ |
|
| 29 |
++ transformed_name=$(PSTACK) ; \ |
|
| 30 |
++ else \ |
|
| 31 |
++ true ; \ |
|
| 32 |
++ fi ; \ |
|
| 33 |
++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \ |
|
| 34 |
++ $(INSTALL_PROGRAM) $(srcdir)/$(PSTACK).sh \ |
|
| 35 |
++ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \ |
|
| 36 |
++ : $(SHELL) $(srcdir)/../mkinstalldirs \ |
|
| 37 |
++ $(DESTDIR)$(man1dir) ; \ |
|
| 38 |
++ : $(INSTALL_DATA) $(srcdir)/pstack.1 \ |
|
| 39 |
++ $(DESTDIR)$(man1dir)/$$transformed_name.1 |
|
| 40 |
++ |
|
| 41 |
++uninstall: force uninstall-pstack $(CONFIG_UNINSTALL) |
|
| 42 |
+ transformed_name=`t='$(program_transform_name)'; \ |
|
| 43 |
+ echo gdb | sed -e $$t` ; \ |
|
| 44 |
+ if test "x$$transformed_name" = x; then \ |
|
| 45 |
+@@ -1127,6 +1145,18 @@ uninstall: force $(CONFIG_UNINSTALL) |
|
| 46 |
+ fi |
|
| 47 |
+ @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do |
|
| 48 |
+ |
|
| 49 |
++.PHONY: uninstall-pstack |
|
| 50 |
++uninstall-pstack: |
|
| 51 |
++ transformed_name=`t='$(program_transform_name)'; \ |
|
| 52 |
++ echo $(PSTACK) | sed -e $$t` ; \ |
|
| 53 |
++ if test "x$$transformed_name" = x; then \ |
|
| 54 |
++ transformed_name=$(PSTACK) ; \ |
|
| 55 |
++ else \ |
|
| 56 |
++ true ; \ |
|
| 57 |
++ fi ; \ |
|
| 58 |
++ rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \ |
|
| 59 |
++ $(DESTDIR)$(man1dir)/$$transformed_name.1 |
|
| 60 |
++ |
|
| 61 |
+ # The C++ name parser can be built standalone for testing. |
|
| 62 |
+ test-cp-name-parser.o: cp-name-parser.c |
|
| 63 |
+ $(COMPILE) -DTEST_CPNAMES cp-name-parser.c |
|
| 64 |
+Index: gdb-7.12/gdb/pstack.sh |
|
| 65 |
+=================================================================== |
|
| 66 |
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000 |
|
| 67 |
+@@ -0,0 +1,43 @@ |
|
| 68 |
++#!/bin/sh |
|
| 69 |
++ |
|
| 70 |
++if test $# -ne 1; then |
|
| 71 |
++ echo "Usage: `basename $0 .sh` <process-id>" 1>&2 |
|
| 72 |
++ exit 1 |
|
| 73 |
++fi |
|
| 74 |
++ |
|
| 75 |
++if test ! -r /proc/$1; then |
|
| 76 |
++ echo "Process $1 not found." 1>&2 |
|
| 77 |
++ exit 1 |
|
| 78 |
++fi |
|
| 79 |
++ |
|
| 80 |
++# GDB doesn't allow "thread apply all bt" when the process isn't |
|
| 81 |
++# threaded; need to peek at the process to determine if that or the |
|
| 82 |
++# simpler "bt" should be used. |
|
| 83 |
++ |
|
| 84 |
++backtrace="bt" |
|
| 85 |
++if test -d /proc/$1/task ; then |
|
| 86 |
++ # Newer kernel; has a task/ directory. |
|
| 87 |
++ if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then |
|
| 88 |
++ backtrace="thread apply all bt" |
|
| 89 |
++ fi |
|
| 90 |
++elif test -f /proc/$1/maps ; then |
|
| 91 |
++ # Older kernel; go by it loading libpthread. |
|
| 92 |
++ if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then |
|
| 93 |
++ backtrace="thread apply all bt" |
|
| 94 |
++ fi |
|
| 95 |
++fi |
|
| 96 |
++ |
|
| 97 |
++GDB=${GDB:-gdb}
|
|
| 98 |
++ |
|
| 99 |
++# Run GDB, strip out unwanted noise. |
|
| 100 |
++# --readnever is no longer used since .gdb_index is now in use. |
|
| 101 |
++$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <<EOF 2>&1 | |
|
| 102 |
++set width 0 |
|
| 103 |
++set height 0 |
|
| 104 |
++set pagination no |
|
| 105 |
++$backtrace |
|
| 106 |
++EOF |
|
| 107 |
++/bin/sed -n \ |
|
| 108 |
++ -e 's/^\((gdb) \)*//' \ |
|
| 109 |
++ -e '/^#/p' \ |
|
| 110 |
++ -e '/^Thread/p' |
|
| 111 |
+Index: gdb-7.12/gdb/testsuite/gdb.base/pstack.exp |
|
| 112 |
+=================================================================== |
|
| 113 |
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000 |
|
| 114 |
+@@ -0,0 +1,66 @@ |
|
| 115 |
++# Copyright (C) 2012 Free Software Foundation, Inc. |
|
| 116 |
++ |
|
| 117 |
++# This program is free software; you can redistribute it and/or modify |
|
| 118 |
++# it under the terms of the GNU General Public License as published by |
|
| 119 |
++# the Free Software Foundation; either version 3 of the License, or |
|
| 120 |
++# (at your option) any later version. |
|
| 121 |
++# |
|
| 122 |
++# This program is distributed in the hope that it will be useful, |
|
| 123 |
++# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 124 |
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 125 |
++# GNU General Public License for more details. |
|
| 126 |
++# |
|
| 127 |
++# You should have received a copy of the GNU General Public License |
|
| 128 |
++# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 129 |
++ |
|
| 130 |
++set testfile pstack |
|
| 131 |
++set executable ${testfile}
|
|
| 132 |
++set binfile [standard_output_file $executable] |
|
| 133 |
++if {[build_executable ${testfile} ${executable} "" {debug}] == -1} {
|
|
| 134 |
++ return -1 |
|
| 135 |
++} |
|
| 136 |
++ |
|
| 137 |
++set test "spawn inferior" |
|
| 138 |
++set command "${binfile}"
|
|
| 139 |
++set res [remote_spawn host $command]; |
|
| 140 |
++if { $res < 0 || $res == "" } {
|
|
| 141 |
++ perror "Spawning $command failed." |
|
| 142 |
++ fail $test |
|
| 143 |
++ return |
|
| 144 |
++} |
|
| 145 |
++set use_gdb_stub 1 |
|
| 146 |
++set pid [exp_pid -i $res] |
|
| 147 |
++gdb_expect {
|
|
| 148 |
++ -re "looping\r\n" {
|
|
| 149 |
++ pass $test |
|
| 150 |
++ } |
|
| 151 |
++ eof {
|
|
| 152 |
++ fail "$test (eof)" |
|
| 153 |
++ return |
|
| 154 |
++ } |
|
| 155 |
++ timeout {
|
|
| 156 |
++ fail "$test (timeout)" |
|
| 157 |
++ return |
|
| 158 |
++ } |
|
| 159 |
++} |
|
| 160 |
++gdb_exit |
|
| 161 |
++ |
|
| 162 |
++# Testcase uses the most simple notification not to get caught by attach on |
|
| 163 |
++# exiting the function. Still we could retry the pstack command if we fail. |
|
| 164 |
++ |
|
| 165 |
++set test "spawn pstack" |
|
| 166 |
++set command "sh -c GDB=$GDB\\ GDBARGS=-data-directory\\\\\\ $BUILD_DATA_DIRECTORY\\ sh\\ ${srcdir}/../pstack.sh\\ $pid\\;echo\\ GSTACK-END"
|
|
| 167 |
++set res [remote_spawn host $command]; |
|
| 168 |
++if { $res < 0 || $res == "" } {
|
|
| 169 |
++ perror "Spawning $command failed." |
|
| 170 |
++ fail $test |
|
| 171 |
++} |
|
| 172 |
++set pid [exp_pid -i $res] |
|
| 173 |
++gdb_test_multiple "" $test {
|
|
| 174 |
++ -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\$" {
|
|
| 175 |
++ pass $test |
|
| 176 |
++ } |
|
| 177 |
++} |
|
| 178 |
++gdb_exit |
|
| 179 |
++ |
|
| 180 |
++remote_exec host "kill -9 $pid" |
|
| 181 |
+Index: gdb-7.12/gdb/testsuite/gdb.base/pstack.c |
|
| 182 |
+=================================================================== |
|
| 183 |
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000 |
|
| 184 |
+@@ -0,0 +1,43 @@ |
|
| 185 |
++/* This testcase is part of GDB, the GNU debugger. |
|
| 186 |
++ |
|
| 187 |
++ Copyright 2005, 2007, 2008, 2009 Free Software Foundation, Inc. |
|
| 188 |
++ |
|
| 189 |
++ This program is free software; you can redistribute it and/or modify |
|
| 190 |
++ it under the terms of the GNU General Public License as published by |
|
| 191 |
++ the Free Software Foundation; either version 3 of the License, or |
|
| 192 |
++ (at your option) any later version. |
|
| 193 |
++ |
|
| 194 |
++ This program is distributed in the hope that it will be useful, |
|
| 195 |
++ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 196 |
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 197 |
++ GNU General Public License for more details. |
|
| 198 |
++ |
|
| 199 |
++ You should have received a copy of the GNU General Public License |
|
| 200 |
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|
| 201 |
++ |
|
| 202 |
++#include <stdio.h> |
|
| 203 |
++#include <unistd.h> |
|
| 204 |
++#include <string.h> |
|
| 205 |
++ |
|
| 206 |
++void |
|
| 207 |
++func (void) |
|
| 208 |
++{
|
|
| 209 |
++ const char msg[] = "looping\n"; |
|
| 210 |
++ |
|
| 211 |
++ /* Use the most simple notification not to get caught by attach on exiting |
|
| 212 |
++ the function. */ |
|
| 213 |
++ write (1, msg, strlen (msg)); |
|
| 214 |
++ |
|
| 215 |
++ for (;;); |
|
| 216 |
++} |
|
| 217 |
++ |
|
| 218 |
++int |
|
| 219 |
++main (void) |
|
| 220 |
++{
|
|
| 221 |
++ alarm (60); |
|
| 222 |
++ nice (100); |
|
| 223 |
++ |
|
| 224 |
++ func (); |
|
| 225 |
++ |
|
| 226 |
++ return 0; |
|
| 227 |
++} |
|
| 228 |
+ |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
Summary: C debugger |
| 2 | 2 |
Name: gdb |
| 3 | 3 |
Version: 7.8.2 |
| 4 |
-Release: 5%{?dist}
|
|
| 4 |
+Release: 6%{?dist}
|
|
| 5 | 5 |
License: GPLv2+ |
| 6 | 6 |
URL: http://www.gnu.org/software/%{name}
|
| 7 | 7 |
Source0: http://ftp.gnu.org/gnu/gdb/%{name}-%{version}.tar.gz
|
| ... | ... |
@@ -9,6 +9,7 @@ Source0: http://ftp.gnu.org/gnu/gdb/%{name}-%{version}.tar.gz
|
| 9 | 9 |
Group: Development/Tools |
| 10 | 10 |
Vendor: VMware, Inc. |
| 11 | 11 |
Distribution: Photon |
| 12 |
+Patch0: gdb-7.12-pstack.patch |
|
| 12 | 13 |
Requires: python3 |
| 13 | 14 |
Requires: expat |
| 14 | 15 |
Requires: ncurses >= 6.0-3 |
| ... | ... |
@@ -23,6 +24,7 @@ GDB, the GNU Project debugger, allows you to see what is going on |
| 23 | 23 |
another program was doing at the moment it crashed. |
| 24 | 24 |
%prep |
| 25 | 25 |
%setup -q |
| 26 |
+%patch0 -p1 |
|
| 26 | 27 |
%build |
| 27 | 28 |
./configure \ |
| 28 | 29 |
--prefix=%{_prefix} \
|
| ... | ... |
@@ -61,6 +63,8 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
|
| 61 | 61 |
%{_mandir}/*/*
|
| 62 | 62 |
|
| 63 | 63 |
%changelog |
| 64 |
+* Thu Jul 20 2017 Rui Gu <ruig@vmware.com> 7.8.2-6 |
|
| 65 |
+- Add pstack wrapper which will invoke gdb. |
|
| 64 | 66 |
* Tue May 30 2017 Xiaolin Li <xiaolinl@vmware.com> 7.8.2-5 |
| 65 | 67 |
- Build gdb with python3. |
| 66 | 68 |
* Mon Apr 3 2017 Alexey Makhalov <amakhalov@vmware.com> 7.8.2-4 |