Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2015 12:54:55 -0500
From:      Ed Maste <emaste@freebsd.org>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        Glen Barber <gjb@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: HEADS-UP: Enabling WITH_DEBUG_FILES by default
Message-ID:  <CAPyFy2DJEFOSwcFv_K3_s_F1MMfM9u_Cm9ReAv%2B-wchn19ZoDA@mail.gmail.com>
In-Reply-To: <20150212152936.GA66037@troutmask.apl.washington.edu>
References:  <20150212023912.GG1302@hub.FreeBSD.org> <20150212152936.GA66037@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 12 February 2015 at 10:29, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> Does this feature take into account the optimization level
> that one may set via CFLAGS?  Conventional wisdom used to
> claim that debuggers did not fair too well with code that
> was compiled with -O2 (or -Os and/or other well-known gcc
> options -fomit-frame-pointer, etc.)  The common advice was
> to recompile one's code with -g or '-g -O'.  Does lldb cope
> better with optimized binaries?

The WITH_DEBUG_FILES option builds debug regardless of what
optimization level is set. I'm not quite sure in which way
WITH_DEBUG_FILES would take account of the optimization level.

It's true that debugging is easier if the target is built with -O0.
If I have a reproducible crash as a developer, I would rebuild with
-O0. That may not be feasible for end users though, and doesn't help
in the case of a crash that can't be reproduced.

That said, debugging is still possible with -O2, it just loses
information or makes control flow hard to follow in some (perhaps
many) cases. Type and source line information is still available.  It
may not be possible to read the value of some variables at some times
during execution, and stepping can be confusing. But it's usually
possible to get a useful backtrace and find necessary variables.

All of my systems are built with -O2 and WITH_DEBUG_FILES, and
generally speaking I have a positive experience with postmortem
debugging of core files.

LLDB does handle optimized binaries better than the ancient version of
GDB we have in the base system. Contemporary GDB versions also do so.

Also note that for userland DTrace support we build with -g as part of
the process of generating CTF information, so enabling userland DTrace
also implies an increase in OBJDIR size.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2DJEFOSwcFv_K3_s_F1MMfM9u_Cm9ReAv%2B-wchn19ZoDA>