On Wed, Aug 25, 2004 at 06:30:17PM -0400, Gerard Seibert wrote:

> OK, I am not that knowledgable about compiling programs, etc. Exactly how
> do I recompile with ("-g" flag on cc). Does this cause it to get a
> backtrace? If not, then how do I go about it?

To compile a program from ports with '-g' you should be able to use
the CFLAGS make variable from /etc/make.conf (ideally, you should be
able to override it from the environment or the command line and avoid
having to fiddle with that file at all, but YMMV).  Taking portmanager as the
example:

    # cd /usr/ports/sysutils/portmanager
    # make clean
    # make CFLAGS='-g -O' all

This will leave you with a copy of the portmanager executable in

    ${WRKDIRPREFIX}/sysutils/portmanager/work/portmanager-0.2.0/portmanager

(${WRKDIRPREFIX} will be /usr/ports, unless you've deliberately changed it)

    % file portmanager 
    portmanager: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), for 
FreeBSD 4.9.1, dynamically linked (uses shared libs), not stripped

That 'not stripped' part is important: it means that this copy of the
executable contains all of the debug symbols the '-g' puts in.
However, if you go ahead and install the port, all of those symbols
will be stripped out -- debug symbols generally take up a huge amount
of space, and that's a waste unless you are actually debugging things.

All is not lost though: go ahead and install the portmanager port, and
do whatever it was that you did which caused it to dump core.  Do
*not* run 'make clean' in the port directory.

You should have a file portmanager.core To obtain a stack trace with
useful information, run:

    # gdb 
${WRKDIRPREFIX}/sysutils/portmanager/work/portmanager-0.2.0/portmanager/portmanager -c 
portmanager.core

(ie. tell gdb to use the unstripped copy of the program, and match it
against the core dump.)

Then when it has loaded all of the symbols etc., type:

    > where

Cut'n'paste that output into your e-mail report to the developers, but
make sure you keep the corefile and the unstripped version of
portmanager to hand, as you may well be asked to run some other gdb(1)
commands to extract further information.

        Cheers,

        Matthew



-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

Attachment: pgpxcN9BUqr25.pgp
Description: PGP signature

Reply via email to