Bug 209398 - [new port] sysutils/bstack : utility to print the backtrace of a running process using GDB
Summary: [new port] sysutils/bstack : utility to print the backtrace of a running proc...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Olivier Cochard
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-05-09 15:16 UTC by luca.pizzamiglio
Modified: 2016-08-04 12:32 UTC (History)
2 users (show)

See Also:


Attachments
The patch that create the new port (1.95 KB, patch)
2016-05-09 15:16 UTC, luca.pizzamiglio
luca.pizzamiglio: maintainer-approval+
Details | Diff
The shar version of the port (1.93 KB, text/plain)
2016-06-19 11:12 UTC, luca.pizzamiglio
luca.pizzamiglio: maintainer-approval+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description luca.pizzamiglio 2016-05-09 15:16:36 UTC
Created attachment 170147 [details]
The patch that create the new port

Creating the new port bstack: bstack is the port of the Linux gstack, a utility to print the backtrace of a running process using GDB.

It's a simple shell script retrieving information of the running process using procstat and then invoking gdb to show the backtrace of all threads.

I choose the sysutils as category for the port, because similar tools like pstack and pstacku are in the same category.
Comment 1 Olivier Cochard freebsd_committer freebsd_triage 2016-06-19 06:43:02 UTC
Can you provide a shar file in place of a patch (Using patch < didn't create directory).
Thanks.
Comment 2 luca.pizzamiglio 2016-06-19 11:12:32 UTC
Created attachment 171567 [details]
The shar version of the port

The submitted shar create the new port directory, but it doesn't modify the sysutil's Makefile.

I've also added the NO_ARCH = yes, as suggested by Q/A, because it's olny a couple of scripts.
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-06-20 08:19:22 UTC
A commit references this bug:

Author: olivier
Date: Mon Jun 20 08:18:30 UTC 2016
New revision: 417144
URL: https://svnweb.freebsd.org/changeset/ports/417144

Log:
  New port: sysutils/bstack

  bstack - gstack for FreeBSD

  This is a port of gstack, a script build around gdb on RedHat and other
  Linux distros, to FreeBSD.

  bstack take a PID as only parameter and print out the back trace of that
  running process. If the process is multithread, the backtrace of all
  threads is printed.

  It works with the last version of GDB

  WWW: https://github.com/pizzamig/bstack

  PR:		209398
  Submitted by:	luca.pizzamiglio@gmail.com
  Approved by:	jadawin (mentor)
  Differential Revision:	https://reviews.freebsd.org/D6899

Changes:
  head/sysutils/Makefile
  head/sysutils/bstack/
  head/sysutils/bstack/Makefile
  head/sysutils/bstack/distinfo
  head/sysutils/bstack/pkg-descr
Comment 4 Olivier Cochard freebsd_committer freebsd_triage 2016-06-20 08:26:52 UTC
Thanks for your new port!
Comment 5 John Marino freebsd_committer freebsd_triage 2016-08-03 23:09:47 UTC
luca, olivier:

There is a minor problem with this port, specifically this line:

RUN_DEPENDS=    gdb:devel/gdb

From the description of the tool I can infer this is supposed to be used with gdb from ports.  However, the RUN_DEPENDS is never registered?  Why is that, you say? because every single release of FreeBSD (and DragonFly) has gdb in base and in the standard path.  

The ports framework (or pkg, not sure which) sees gdb in the path and doesn't register devel/gdb as a dependency.

The fix is to change the line to:

RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb


I will probably make this change without waiting for confirmation (after I test build it) but if you guys see this post, a confirmation that you agree would be nice.
Comment 6 luca.pizzamiglio 2016-08-04 08:03:53 UTC
(In reply to John Marino from comment #5)

Hi John,
you are totally right.

I've seen poudriere build devel/gdb, because it's a dependency.
But during the build phase, no gdb is installed.

Another solution would be:

RUN_DEPENDS=    gdb>=7:devel/gdb

But LOCALBASE solution seems more solid to me.

thanks for the fix!
Comment 7 John Marino freebsd_committer freebsd_triage 2016-08-04 12:32:01 UTC
right, using a version specifier is in effect the same thing (maybe not as clear but that's subjective).

FYI I caught this using synth.
For a healthy port  (we'll use bstack as an example), if you do this:
"synth just-build sysutils/bstack"
followed by the same command:
"synth just-build sysutils/bstack"

The result of the second command should be nothing; synth should say it's already built.  In bstack's case, it built it again because the port makefile said gdb was supposed to be a dependency but synth didn't detect gdb registered in the package (it uses pkg to probe existing packages).  So bstack built over and over and over again.

Anyway, that's a little trick for the future.  Matt Dillon found 40 of these after we built the whole tree with synth and ran synth on the tree again without changing anything.