Bug 195465 - lang/gcc-aux: Ada symbolic trace is broken
Summary: lang/gcc-aux: Ada symbolic trace is broken
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: John Marino
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-28 10:19 UTC by Natacha Porté
Modified: 2014-11-28 12:44 UTC (History)
0 users

See Also:
natbsd: maintainer-feedback? (marino)


Attachments
patch on lang/gcc-aux to fix addr2line path (906 bytes, patch)
2014-11-28 10:19 UTC, Natacha Porté
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Natacha Porté 2014-11-28 10:19:29 UTC
Created attachment 149950 [details]
patch on lang/gcc-aux to fix addr2line path

I have been developing on AdaControl, which uses GNAT.Traceback.Symbolic.Symbolic_Traceback to report exceptions, and this is an invaluable tool because code paths are so complex.

However, under FreeBSD, the output is less-than-useful, and looks like the following:

> BFD: Dwarf Error: found dwarf version '4', this reader only handles version 2 information.
> 0x7e7773 in asis.gela.contexts.open at ??:0
> 0x78cb43 in asis.ada_environments.open at ??:0
> 0x46a7da in adactl at ??:0
> 0x40690e in main at ??:0
> 0x4069df in <_start> at ??:0
> 0x800da3ffe in ?? at ??:0

with the first line being repeated hundreds of time.

As far as I can tell, the problems comes from the FreeBSD-specific version of `convert_addresses()`, provided in `files/diff-ada`, which resolves the traceback by spawning `/usr/bin/addr2line`. This is the addr2line that comes with binutils from base, and it is significantly older than `/usr/local/bin/addr2line` provided by `devel/binutils` on which `gcc-aux` depends.

The attached patch bumps port revision number and fixes the hardcoded `addr2line` path. With it, in the same situation as above, I get the following output:

> 0x69e403 in asis.ada_environments.open at asis-ada_environments.adb:241
> 0x46a58a in adactl at adactl.adb:90 (discriminator 1)
> 0x4065de in main at b~adactl.adb:1536
> 0x40677d in <_start> at ??:?
> 0x800da3ffe in ?? at ??:0

without any dwarf-related error message.
Comment 1 Bugzilla Automation freebsd_committer 2014-11-28 10:19:29 UTC
Auto-assigned to maintainer marino@FreeBSD.org
Comment 2 John Marino freebsd_committer 2014-11-28 10:28:23 UTC
I'd have to fix it a different way.

1) it hardcodes /usr/local -- which can't be assumed
2) it's a freebsd specific issue, netbsd and dragonfly don't suffer from it.

Also, only FreeBSD requires new binutils, so it would have to be a freebsd-specific solution, but I have an idea how to fix it.
Comment 3 Natacha Porté 2014-11-28 11:04:10 UTC
What about using PATH environment variable then?
Comment 4 John Marino freebsd_committer 2014-11-28 11:06:10 UTC
don't worry, i know how to fix it for freebsd.
Comment 5 commit-hook freebsd_committer 2014-11-28 12:43:43 UTC
A commit references this bug:

Author: marino
Date: Fri Nov 28 12:43:04 UTC 2014
New revision: 373563
URL: https://svnweb.freebsd.org/changeset/ports/373563

Log:
  lang/gcc-aux: Fix symbolic trace on FreeBSD

  Recent gcc creates debug information in dwarf4 format, something that
  the base version of addr2line on FreeBSD cannot understand.  When the
  compiler requires binutils from ports to build, then ensure the
  symbolic tracing code also uses addr2line from the same binutils (which
  is already available due to RUN_DEPENDS requirements).  Since DragonFly
  3.6 and lower are no longer officially supported, this change only
  affects FreeBSD, but it affects all supported releases.  The conditional
  code for DragonFly 3.6 has been removed while here.

  Reported by:	Natacha Porte
  PR:		195465

Changes:
  head/lang/gcc-aux/Makefile
  head/lang/gcc-aux/Makefile.version
Comment 6 John Marino freebsd_committer 2014-11-28 12:44:57 UTC
Thanks for the analysis and suggested fix!
I fixed it a different way but the result is the same.
John