help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: identifying cause of segfault with gdb?


From: Guy Harrison
Subject: Re: identifying cause of segfault with gdb?
Date: Tue, 13 Jul 2004 12:59:45 GMT
User-agent: KNode/0.7.7

Amit Bhatia wrote:

> Hello.
>  Is it possible to identify the source of a segmentation fault(which is
>  most
> probably being caused due to memory access of place which I am not allowed
> to) using gdb?
>  I wish to know the name of the erring call or line no in the method where
> this could be happening.
>  I am using g++ 3.2 on redhat 9.0, and do compile with -c -pg flag.(and
> finally make libmyown.a and then link it to the compiled test program).

Pass "-g" flag to compilations then run program under 'gdb'. If it crashes
then use "bt' (backtrace) command to unwind it. For trivial problems the
fault may become apparent just from that. Alternatively recompile with "-g
-O0" (no optimisation), keep fingers crossed it still crashes, then start
stepping through it. Optimised code sometimes has the debugger jumping
about all over the place - trouble is, in some situations (because the
code's changed) the fault can move around, or even "vanish" (it hasn't)
entirely. A useful gui for gdb is 'ddd' as it allows you to type gdb
commands as well as point 'n' click (and vice-versa).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]