This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 118155 - Discovery wizard required dwarf on Mac
Summary: Discovery wizard required dwarf on Mac
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 6.x
Hardware: All Mac OS X
: P3 blocker (vote)
Assignee: Alexander Simon
URL:
Keywords:
: 116354 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-08 21:54 UTC by _ gordonp
Modified: 2007-12-19 19:22 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gordonp 2007-10-08 21:54:04 UTC
The Discovery wizard/process required projects get built with -g3 -gdwarf-2. On the Mac, this
produces an executable which isn't debuggable. Recompiling with -g produces a debuggable exe.

To reproduce with quote:
1. Compile with -g3 -gdwarf-2 (the default flags).
2. Run gdb (from the command line) on the exe
3. Set a breakpoint at lines 104 ("fetchCustomerList()" in main) and 57 ("if ((*it).GetName() == name) {"
   in getDiscountFor(). (Note: These line numbers are pre CDDL/gpl header change so you'll have to
   adjust if you create a new quote app).
4. Run to the 1st breakpoint ("run" command).

Note that you've stopped on line 102 and the message says it breakpoint 2

5. Run to the 2nd breakpoint ("continue" command)

It correctly says its breakpoint 1 and line 104.

Here is the output of my run:

    $  gdb -q dist/Debug/GNU-MacOSX/quote_1
    Reading symbols for shared libraries .... done
    (gdb) b 104
    Breakpoint 1 at 0x3c30: file quote.cc, line 104.
    (gdb) b 57
    Breakpoint 2 at 0x3bea: file quote.cc, line 57.
    (gdb) info breakpoints
    Num Type           Disp Enb Address    What
    1   breakpoint     keep y   0x00003c30 in main at quote.cc:104
    2   breakpoint     keep y   0x00003bea in main at quote.cc:57
    (gdb) run
    Starting program: /Users/gordonp/NetBeansProjects/Quote_1/dist/Debug/GNU-MacOSX/quote_1
    Reading symbols for shared libraries . done
    
    Breakpoint 2, main (argc=1, argv=0xbffffb54) at quote.cc:102
    102         cout << "Support metric quote program" << endl << endl;
    (gdb) continue
    Continuing.
    Support metric quote program
    
    
    Breakpoint 1, main (argc=1, argv=0xbffffb54) at quote.cc:104
    104         fetchCustomersList();
    (gdb) kill
    Kill the program being debugged? (y or n) y
    (gdb) quit
    $
Comment 1 Alexander Simon 2007-10-09 14:00:56 UTC
I think that methods 
GNUCCCompiler.getDevelopmentModeOptions() and GNUCCompiler.getDevelopmentModeOptions()
should return platform dependent compiler flags.
It seems for Mac it should be "-g".
Comment 2 _ gordonp 2007-10-09 14:40:10 UTC
Jesse asked me to file this bug because he wants the discovery system to process Mach-O
debug information. Concurrently, Thomas will be changing the flags generated on the Mac.
I believe Thomas is looking to you for a recommendation as to what debug flags he should
use (just -g or -g3 or ???).
Comment 3 Thomas Preisler 2007-10-09 15:36:19 UTC
yes, just let me know what compiler option I should generate.

Alexander, the problem is if we generate -g the discovery wizard doesn't work and we we generate -g3 -gdwarf-2 gdb
doesn't work well. Can the discovery wizard be changed to understand -g generated debug information?
Comment 4 Alexander Simon 2007-10-10 12:44:06 UTC
In thee "GCC 4.0 Release Notes" on web page:
http://developer.apple.com/releasenotes/DeveloperTools/RN-GCC4/index.html
you can see following note about DWARF:
DWARF debugging format is now supported. However, STABS is still used as default debugging format. In subsequent
releases, DWARF will be used as default debugging format.
Comment 5 Alexander Simon 2007-10-10 12:52:12 UTC
I checked different combination of debug flags.
This is a list of flags that produce debug information for discovery wizard:
-g3 -gdwarf-2
-g -gdwarf-2
-gdwarf-2
This is a list of flags that do not produce debug information for discovery wizard:
-g
-g3
This is a list of flags that do not allowed by compiler:
-g3 -gstabs -gdwarf-2
-g3 -gdwarf-2 -gstabs
Comment 6 Jesse Grodnik 2007-10-10 21:39:53 UTC
In the release notes for xcode:

http://developer.apple.com/tools/xcode/newinxcode23.html

the developer has a UI facility for selecting either stabs or dwarf as the debugging commentary.

It seems likely (from other developer notes) that choosing dwarf in xcode sets the compiler option -ggdb.

We can confirm the actual setting by generating an executable with xcode and the UI dwarf option selected.
Comment 7 _ gordonp 2007-10-10 22:00:50 UTC
A command line only check was positive. I build quote with -g3 -ggdb and could
debug it (I didn't do more than sanity test it, though, but that failed with
-gdwarf-2).
Comment 8 Alexander Simon 2007-10-11 11:31:20 UTC
Flags "-g3 -ggdb -gdwarf-2" produce debug information for discovery wizard.
Flags "-g3 -ggdb" do not.
Comment 9 _ gordonp 2007-10-11 15:08:34 UTC
The debug session in my original entry still fail with "-g3 -ggdb -gdwarf-2".
Comment 10 Alexander Simon 2007-10-11 16:50:42 UTC
Look at: 
http://developer.apple.com/releasenotes/DeveloperTools/RN-GDB/index.html
My understanding is that striping debug information from executable can fix problem.
i.e.
1. compile flags is "-g3 -ggdb -gdwarf-2"
2. linker strip debug information from executable.
Comment 11 _ gordonp 2007-10-11 17:17:17 UTC
How will stripping debug information help make something more debuggable? If there is a
partial strip which removes the -gdwarf-2 stuff but leaves the -ggdb stuff intact (and
leaves the exectable debuggable) then this approach would work. Otherwise it would not.

I tried building with "-g3 -ggdb -gdwarf-2" and linking with -Wl,-Sp. Still couldn't debug.
I can't imagine the other strip options are as likely to work as this one...
Comment 12 Alexander Simon 2007-10-11 17:28:29 UTC
Could you try strip in way described in the section 
"Changes since Xcode 2.2 Developer tools update (gdb-437)" on
http://developer.apple.com/releasenotes/DeveloperTools/RN-GDB/index.html
Comment 13 _ gordonp 2007-10-11 18:21:15 UTC
"gdb-437" refers to a way of getting the debug information in a separate file so a stripped
version can be used. Then you can debug the striped exe by adding the dSYM file at debug time.

That doesn't apply here because the debug information in the dSYM file would be identical to
the original debug information in the executable and .o files. In other words, it would have
both the output of -ggdb and -gdwarf-2 in the dSYM file.
Comment 14 Vladimir Kvashin 2007-10-11 20:12:22 UTC
Options we discuss here are relevant for *managed* projects only.
In contrary, the discovery system only works (and makes sense) with makefile-based projects.
So I believe it's worth just changing default options to -g.
(Moreover, I would propose to change it independently of OS).

We still have an issue regarding how to advise Mac user on building/configuring makefile projects and using discovery
system. But anyhow, I believe this discussion is beyond this IZ.
Comment 15 Thomas Preisler 2007-10-11 20:19:06 UTC
OK, Iwill change it back to -g for GNU compilers on all platforms.
Comment 16 _ gordonp 2007-10-12 03:23:31 UTC
*** Issue 116354 has been marked as a duplicate of this issue. ***
Comment 17 Jesse Grodnik 2007-10-16 18:27:50 UTC
As resolved for beta 2 (with -g) debugging works properly (with stabs). Language model discovery (which benefits from
having dwarf) is limited. The user has a workaround -- explicitly compiling with dwarf during initial project discovery,
and then explicitly compiling with stabs for debugging. We need a better solution, and we'll re-examine with Leopard
later this month. The defect is downgraded to P2.
Comment 18 Alexander Simon 2007-10-17 07:55:30 UTC
Summary table of dwarf information:
flag                | Dwarf information
--------------------+--------------------------
-g                  | not found dwarf
-g3                 | not found dwarf
-g3 -ggdb           | not found dwarf
-g -gdwarf-2        | include paths
-gdwarf-2           | include paths
-ggdb               | include paths
-g3 -gdwarf-2       | macros and include paths
-g3 -ggdb- gdwarf-2 | macros and include paths
--------------------+--------------------------

Comment 19 Jesse Grodnik 2007-10-23 23:07:46 UTC
Downgraded to a P3.
Comment 20 Alexander Simon 2007-11-01 09:22:02 UTC
Summary table of dwarf information for Leopard:
flag                | Dwarf information
--------------------+--------------------------
-g                  | include paths (not full set of included files)
-g3                 | macros and include paths
-g3 -ggdb           | macros and include paths
-g -gdwarf-2        | include paths (not full set of included files)
-gdwarf-2           | include paths (not full set of included files)
-ggdb               | include paths (not full set of included files)
-g3 -gdwarf-2       | macros and include paths
-g3 -ggdb- gdwarf-2 | macros and include paths
--------------------+--------------------------
Comment 21 Jesse Grodnik 2007-12-19 19:22:10 UTC
This is no longer an issue with new release (Leopard) of Mac OS.