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 131802 - Gdb could not be started
Summary: Gdb could not be started
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P1 blocker (vote)
Assignee: _ gordonp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-02 10:20 UTC by alexandrov
Modified: 2009-06-25 10:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch containing the fix (6.65 KB, text/plain)
2008-04-03 19:11 UTC, _ gordonp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alexandrov 2008-04-02 10:20:02 UTC
Assume tools(cygwin, mingw) are not in the system PATH. Add tool collection in Tools/Options/C/C++/Build Tools, set gdb
there. If to choose step into in project context menu then in debugger console user can see only "Launching...", but all
debugger tools are not acceptible.
Comment 1 _ gordonp 2008-04-02 15:58:30 UTC
This is not limited to debugging. I get similar behavior trying to run a project on Windows.

I looked at the gdb log when this happened and the program is correctly loaded but fails when
given the run command (with an unknown target exception). Running the project also fails.
I suspect that runtime libraries aren't found because the compiler path isn't in the path. I
think we need to add the compiler path directory when we run or debug a program.

I think this is a P1 on the project system because the ability to develop without either Cygwin
or MinGW directories in the user's path was intended to be a significant feature in this release.
But it doesn't work because runtime libraries aren't found.
Comment 2 Jesse Grodnik 2008-04-02 22:37:06 UTC
See also http://www.netbeans.org/issues/show_bug.cgi?id=120836
Comment 3 Thomas Preisler 2008-04-03 06:20:12 UTC
Yes, it's the same core problem: path to environment (that's where the compilers are) is not added to run environment. I added the path(s) to the run environment and GdbLite needs to do the 
same. Here is the code I added:

                    // Append compilerset base to run path. (IZ 120836)
                    ArrayList<String> env1 = new ArrayList<String>();
                    String csname = ((MakeConfiguration) pae.getConfiguration()).getCompilerSet().getOption();
                    String csdirs = CompilerSetManager.getDefault().getCompilerSet(csname).getDirectory();
                    if (((MakeConfiguration)pae.getConfiguration()).getCompilerSet().getFlavor().equals(CompilerFlavor.MinGW.toString())) {
                        // Also add msys to path. Thet's where sh, mkdir, ... are.
                        String msysBase = CppUtils.getMSysBase();
                        if (msysBase != null && msysBase.length() > 0) {
                            csdirs = csdirs + File.pathSeparator + msysBase + File.separator + "bin"; // NOI18N
                        }
                    }
                    boolean gotpath = false;
                    String pathname = Path.getPathName() + '=';
                    int i;
                    for (i = 0; i < env.length; i++) {
                        if (env[i].startsWith(pathname)) {
                            env1.add(env[i] + File.pathSeparator + csdirs); // NOI18N
                            gotpath = true;
                        } else {
                            env1.add(env[i]);
                        }
                    }
                    if (!gotpath) {
                        env1.add(pathname + Path.getPathAsString() + File.pathSeparator + csdirs);
                    }
                    env = env1.toArray(new String[env1.size()]);

GdbLite needs to add some similar code where it handles the debug environment. Reassigning to Gordon.
Comment 4 Thomas Preisler 2008-04-03 06:25:45 UTC
Note: I found (and fixed) a bug in CppUtils.getMSysBase. It didn't work on (my) Vista. I changed the logic so it looks for ':' and not '\t'. There are no tabs in the 
value on my Vista! You should double check that getCygwinBase and getMinGWBase also work on Vista. They seems to have been coded after the same 
pattern as getMSysBase.
Comment 5 _ gordonp 2008-04-03 15:49:14 UTC
Changing back to gdb subcat, since thats where the fix needs to be.
Comment 6 _ gordonp 2008-04-03 19:11:08 UTC
Created attachment 59636 [details]
Patch containing the fix
Comment 7 _ gordonp 2008-04-03 19:19:27 UTC
Fixed in trunk and the patch is attached. QA please verify the patch works so I can
integrate into release61.
Comment 8 alexandrov 2008-04-04 13:34:13 UTC
verified in trunk 200804040003
Comment 9 _ gordonp 2008-04-05 08:09:03 UTC
Fixed in trunk with http://hg.netbeans.org/main?cmd=changeset;node=b89dc7d05d97.
Fixed in release61 with http://hg.netbeans.org/release61/rev/d16e512b86ca.
Comment 10 Alexander Pepin 2008-04-09 14:02:14 UTC
verified in NB6.1RC1 (build 200804082140)