--- pstack-1.2.orig/pstack.c +++ pstack-1.2/pstack.c @@ -388,9 +388,15 @@ int fd; Symbols syms; + if (*fname == '\0') + return (Symbols) 0; syms = newSyms(fname); if ((fd = open(fname, O_RDONLY)) < 0) + { + fprintf(stderr, "'%s': ", fname); + perror("opening object file"); quit("Could not open object file."); + } read(fd, &hdr, sizeof(hdr)); verify_ident(&hdr); if (!find_stables(&hdr, fd, syms)) { @@ -599,9 +605,17 @@ return cmd; } +void usage(const char *argv0, const char *param) +{ + fprintf(stderr, "Invalid parameter '%s'.\n", param); + fprintf(stderr, "Usage: %s [one or more]\n", argv0); + exit(1); +} + int main(int argc, char **argv) { int i; + const char *argv0 = argv[0]; /* Arrange to detach if we get an unexpected signal. This prevents threads from being left in a suspended state if (for example) we @@ -612,15 +626,17 @@ signal (i, handle_signal); for (argc--, argv++; argc > 0; argc--, argv++) { - thePid = atoi(*argv); + char *endptr = NULL; + thePid = strtol(*argv, &endptr, 0); + if (!*argv || *endptr || errno==ERANGE) + usage(argv0, *argv); if (!thePid || thePid == getpid()) { fprintf(stderr, "Invalid PID %d\n", thePid); continue; } if (attach(thePid) != 0) { - thePid = 0; - fprintf(stderr, "Could not attach to target.\n"); + fprintf(stderr, "Could not attach to target %d\n", thePid); } else { printf("\n%d: %s\n", thePid, cmdLine(thePid)); loadSymbols(thePid); --- pstack-1.2.orig/debian/changelog +++ pstack-1.2/debian/changelog @@ -0,0 +1,20 @@ +pstack (1.2-2) unstable; urgency=low + + * New maintainer. (Closes: #568574) + * Fix "fails to open object file" error. (Closes: #360922) + * debian/control + - Remove reference to upstream repository from package description + - Bump Standard-Version from 3.6.1 to 3.8.4 (no changes needed). + - Set Vcs-Browser and Vcs-Git fields. + * debian/compat + - Bump debhelper compatibility from 4 to 7 (no changes needed). + + -- Thomas Preud'homme Tue, 10 Aug 2010 01:05:59 +0200 + +pstack (1.2-1) unstable; urgency=low + + * Initial Release. (Closes: #149048) + * Added better handling of command line parameters. + + -- Baruch Even Fri, 8 Oct 2004 17:13:40 +0100 + --- pstack-1.2.orig/debian/watch +++ pstack-1.2/debian/watch @@ -0,0 +1,2 @@ +version=2 +http://download.fedora.redhat.com/pub/fedora/linux/core/development/SRPMS/ pstack-([\d.]+)-[\d.]+\.src.rpm debian uupdate --- pstack-1.2.orig/debian/compat +++ pstack-1.2/debian/compat @@ -0,0 +1 @@ +7 --- pstack-1.2.orig/debian/rules +++ pstack-1.2/debian/rules @@ -0,0 +1,9 @@ +#!/usr/bin/make -f +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/makefile.mk + +DEB_INSTALL_DOCS_ALL:=README +DEB_MAKE_INSTALL_TARGET:=install +export DESTDIR:=`pwd`/debian/pstack +export BINDIR:=$(DESTDIR)/usr/bin +export MANDIR:=$(DESTDIR)/usr/share/man --- pstack-1.2.orig/debian/copyright +++ pstack-1.2/debian/copyright @@ -0,0 +1,14 @@ +This package was debianized by Baruch Even on +Fri, 8 Oct 2004 17:13:40 +0100. + +It was downloaded from http://download.fedora.redhat.com/pub/fedora/linux/core/development/SRPMS/pstack-1.2-4.src.rpm +Upstream homepage should be at: http://www.whatsis.com/pstack/ + +Copyright: Ross Thompson and RedHat + +Upstream Author: Ross Thompson + +License: + +This program is released under the GNU GPL v2 or later, you may find the +license at: /usr/share/common-licenses/GPL-2 --- pstack-1.2.orig/debian/control +++ pstack-1.2/debian/control @@ -0,0 +1,16 @@ +Source: pstack +Section: devel +Priority: optional +Maintainer: Thomas Preud'homme +Build-Depends: debhelper (>= 7.0.0), cdbs +Standards-Version: 3.9.1 +Vcs-Browser: http://git.debian.org/?p=collab-maint/pstack.git;a=summary +Vcs-Git: git://git.debian.org/collab-maint/pstack.git + +Package: pstack +Architecture: i386 +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Display stack trace of a running process + pstack dumps a stack trace for a process, given the pid of that process. If + the process named is part of a thread group, then all the threads in the group + are traced.