*BSD News Article 46612


Return to BSD News archive

Newsgroups: comp.unix.bsd.freebsd.misc
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!daffy!uwvax!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!Germany.EU.net!EU.net!uknet!eldorado.net-tel.co.uk!usenet
From: Andrew Gordon <andrew.gordon@net-tel.co.uk>
Subject: Re: gdb debugger question (FreeBSD 2.0)
X-Nntp-Posting-Host: evening-star.net-tel.co.uk
Content-Type: text/plain; charset=us-ascii
Message-ID: <DBGIpn.KGx@net-tel.co.uk>
Sender: usenet@net-tel.co.uk (usenet poster)
Content-Transfer-Encoding: 7bit
Organization: NET-TEL Computer Systems Ltd
References: <rjb-0807952240230001@palpk-s13.intac.com>
Mime-Version: 1.0
Date: Sun, 9 Jul 1995 16:20:10 GMT
X-Mailer: Mozilla 1.1N (Macintosh; I; PPC)
X-Url: news:rjb-0807952240230001@palpk-s13.intac.com
Lines: 51

rjb@intac.com (Bob Badaracco) wrote:
>1. What compiler options do I need to turn on in order to generate a
>symbol table for the debugger to use?

-g

>2. When my program dies, how can I get the debugger to stop where it
> happens?

If you were already running in the debugger, it just stops where the 
fault happened:

arg (monorail)% cc -g -o silly silly.c
arg (monorail)% gdb silly
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for 
details.
GDB 4.13 (i386-unknown-freebsd),
Copyright 1994 Free Software Foundation, Inc...
(gdb) run
Starting program: /cambridge/arg/silly
helloworld

Program received signal SIGSEGV, Segmentation fault.
0x15be in main () at silly.c:8
8         z = *p;
(gdb)



Alternatively, if you ran the program on its own and produced a 
coredump, gdb will show you where it happened:

arg (monorail)% ./silly
helloworld
Segmentation fault (core dumped)
arg (monorail)% gdb silly silly.core
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for 
details.
GDB 4.13 (i386-unknown-freebsd),
Copyright 1994 Free Software Foundation, Inc...
Core was generated by `silly'.
Program terminated with signal 11, Segmentation fault.
#0  0x15be in main () at silly.c:8
8         z = *p;
(gdb)