Project

General

Profile

Actions

Bug #6348

open

source-level debugging not quite working

Added by Gordon Ross over 5 years ago. Updated about 2 months ago.

Status:
New
Priority:
Normal
Assignee:
Category:
tools - gate/build tools
Start date:
2015-10-17
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:

Description

The fixes for #3844 made it easier to build with -g but source-level debugging is still not quite working correctly. The reason is that #3844 added -g without removing optimization options.
With most tool chains, if you turn on both debug support and optimization, examination of local variables etc. usually doesn't work.

The most common approach for adjusting a Makefile to build for debugging is to modify whatever make variable holds the "optimization" options (i.e. typically "-O" or similar), so that when building for debug the optimization flags are replaced with a "-g" flag. That both turns on full source-level debugging support, and turns off optimization. That's what we should be doing as well.

In most ilumos makefiles, the variable we're interested in for this is COPTFLAG, but sometimes COPTFLAG64, CCOPTFLAG, CCOPTFLAG64


Files

Actions #1

Updated by Gordon Ross about 2 months ago

Just setting COPTFLAG (and related) empty lets debugging work OK.
According to the gcc documentation, -O0 (Oh zero) is better,
and -Og better still, though cw didn't like that last.

I've attached the change I normally apply when I need to use gdb.

Actions #2

Updated by Gordon Ross about 2 months ago

Unfortunately, if you use this and set SOURCEDEBUG during a full build,
the build fails in usr/src/lib/libc with unresolved symbols:
_curthread, __curthread, stkptr, set_lock_byte
apparently because of how the inline functions are defined.
There's no regular (not-inline) instantiation of those.

I normally use this with one of the "quick build" scripts in
usr/src/tools/quick and unset SOURCEDEBUG for libc.

Actions

Also available in: Atom PDF