Author Topic: troubles with getting GDB to work correctly  (Read 12262 times)

Mike H

  • Community Member
  • Posts: 26
  • Hero Points: 3
troubles with getting GDB to work correctly
« on: June 20, 2007, 06:29:04 pm »
I'm still a newbie and need some help getting GDB going.  I'm just using the GNU C wizard with the "Hello World" program.  First off, \cygwin\bin is NOT in my DOS path and I'd like to keep it this way if possible.

At first the program doesn't build, but if a explicitly tell SE where gcc is located (i.e. c:\cygwin\bin\gcc.exe), and add "Set PATH=/bin" in the Advanced portion of Project->Project Properties->Tools tab for Build, the project builds.  So far so good.

Now I want to launch the debugger by clicking Debug->Step Into.  With all default settings, I get "GDB has terminated prematurely".  From looking at other posts, I gather this is because SE can't find cygwin1.dll.  So I do the same thing as in the build command, add "Set PATH=/bin" in the Advanced portion for the Debug tool.  Now when I try "Debug->Step Into"  I get an error message saying vsdebug not found:
vsdebugio -prog "L:\SlickEdit\se_practice\Debug\se_practice.exe"
vsbuild: File not found (vsdebugio)

I think I messed something up in my path.  Can someone help! :P

Note that if I edit my path environment variable by appending c:\cygwin\bin to the end of it and relaunch SE, GDB will invoke just fine, so I'm pretty sure the issue is in defining my path.  It should be easy to set up, I just need some guidance.

thanks in advance,
Mike


ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: troubles with getting GDB to work correctly
« Reply #1 on: June 20, 2007, 09:23:37 pm »
Just like you told SlickEdit where the compiler is, you need to tell it where the debugger is. Select Debug > Debugger Options and click on the Configuration tab. If there isn't an entry for GDB (which there probably shouldn't be based on your description), click the Add button to add it.

That should get the debugger working.

--Scott

Mike H

  • Community Member
  • Posts: 26
  • Hero Points: 3
Re: troubles with getting GDB to work correctly
« Reply #2 on: June 21, 2007, 05:57:18 pm »
Thanks for your help, Scott.  But this doesn't help either.  Initially, the debug configuration is set to "Standard GDB" which is the version that ships with SE.  This is located in the SE\win folder.  I'd like to use that version.  Is that not possible?  Using that debugger is what gives the "vsdebugio not found error".  That's why I think my path is somehow messed up.

If I change and use the GDB in my cygwin folder (i.e. ADD c:\cygwin\bin\gdb.exe and set this as the Default native debugging configuration), I also get the same error.

so i'm still lost... :'(

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3231
  • Hero Points: 459
Re: troubles with getting GDB to work correctly
« Reply #3 on: June 21, 2007, 06:30:34 pm »
From the 12.0.1 readme:

Quote
               For users who can't or do not want to use Cygwin for GDB, you can download and
               install the MINGW-based version of GDB, gdb-6.3-2.exe, from
               http://www.mingw.org/download.shtml

                This version of GDB is known to work with SlickEdit and does not depend
                on cygwin1.dll.
                Use the Configurations tab on the Debugger Options dialog (Debug >
                Debugger Options
or debug_props command) to make it the default
                native GDB debugger configuration.

Mike H

  • Community Member
  • Posts: 26
  • Hero Points: 3
Re: troubles with getting GDB to work correctly
« Reply #4 on: June 21, 2007, 09:34:04 pm »
wow!  Is this really the only solution?  To download the mingw package and call out their GDB?  ???
According to other posts in the forum, this lacks way behing cygwin gdb in features and stability.

Let me pose my problem another way.  I think all I need to do is ADD c:\cygwin\bin to the environment path when SE wants to use any cygwin tools: gcc, gdb, make, etc.  Is there a way to do this when SE launches?  I see in Project Properties there is a tab called Open that executes commands when a project is opened.  Can this be used to append c:\cygwin\bin to the environment path?

Or I think I should be able to go into the Advanced section of the Project Properties - tab - Tools and append c:\cygwin\bin to the environment path of each tool (i.e. build, Rebuild, Debug).  I'm just not sure how to do this correctly.  All I seem to be able to do is reset the whole path to c:\cygwin\bin.

still looking for the ideal solution... ::)

Mike

Phil Barila

  • Senior Community Member
  • Posts: 742
  • Hero Points: 61
Re: troubles with getting GDB to work correctly
« Reply #5 on: June 21, 2007, 11:33:17 pm »
All I seem to be able to do is reset the whole path to c:\cygwin\bin.
Are you including the dereference of the original path so it actually gets appended (or prepended, as the case may be) instead of simply replacing the existing path?  If you issue a set in the Pre Build Commands, it would be like this (The server seems to be trying to interpret the literal percent sign character, so substitute that char for <percent sign>:
Code: [Select]
set path=<percent sign>(path);C:\Cygwin\bin

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3231
  • Hero Points: 459
Re: troubles with getting GDB to work correctly
« Reply #6 on: June 22, 2007, 02:02:59 pm »
Sorry, my reply was based on the fact that you are averse to putting cygwin on your path. Therefore, I assumed you didn't care if you used a recent cygwin version of GDB or not.  So I offered a solution where you don't have to deal with any path issues.

As far as the Debug tool goes, don't mess with setting the environment in the Advanced tool settings, you will not accomplish anything doing that.  Think about it.  SlickEdit has to communicate with GDB.  The only way to do that is through stdio/stdout pipes.  So, the only way we can launch GDB is by CreateProcess, so GDB is going to acquire the enviornment of the editor.  Not vsbuild's environment, and not the build window's environment.  The advanced settings for normal build tools, not things that are necessarily special cased like the GDB debugger.

There are four ways that you could add cygwin/bin to your PATH so that GDB will find it when it is launched.

    (1) Append cygwin/bin to the end of your system PATH
    (2) Append cygwin/bin to your PATH in vslick.ini (in your configuration directory) 
    (3) Append cygwin/bin to your PATH by setting up your workspace environment
         (Project > Workspace Properties > Environment...)
    (4) add "set PATH=..." to your project open commands.
         (Project > Project Properties... > Open)

Mike H

  • Community Member
  • Posts: 26
  • Hero Points: 3
Re: troubles with getting GDB to work correctly
« Reply #7 on: June 22, 2007, 05:09:14 pm »
Thanks for the help guys.  It seems to be working fine now.  I chose option (3) from Dennis' list but (2) or (4) would probably work just as well.  I think part of the problem was my syntax was incorrect for appending to the current value of PATH.  So Phil gets a thumbs up for that.

I think SE is a little deceptive about the path.  In a normal case, if I use <esc> command "set path",
SE dumps the complete string of the PATH variable.  This is fine.  Now when I append something to the end of PATH using options 2-4 from Dennis and then do the set path command, the response is:
"<percent sign>path<percent sign>;c:\cygwin\bin\".  In other words, it doesn't substitute the original value and append the added path as you would expect.  I concluded that it wasn't properly interpreting the "<percent sign>path<percent sign>" as a variable.  In fact, I don't know how to see what the true value of PATH is after modifying it inside SE.  Even if I go to the build window and type "set", the value for PATH is "Path=<percent sign>path<percent sign>;C:\cygwin\bin\".

But, I seem to be able to compile and launch GDB, which was my original goal!  After all this, maybe modifying vslick.ini is a cleaner way to go since I would guess issue "set path" will dump the whole value of PATH.

thanks,
Mike

hs2

  • Senior Community Member
  • Posts: 2752
  • Hero Points: 291
Re: troubles with getting GDB to work correctly
« Reply #8 on: June 26, 2007, 02:08:24 pm »
@SlickTeam:
BTW: While discussing cygwin PATH setup issues another small problem came back into my mind.
There might be a 'namespace pollution/collision' issue caused by the SE 'grep' utility in conjunction with e.g. an installed cygwin environment or another (indispensible) UNIX utils package if both bin/win-path prefixes are included in the PATH env.var.
So I'd propose to rename it e.g. 'vgrep'.

HS2

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5735
  • Hero Points: 458
Re: troubles with getting GDB to work correctly
« Reply #9 on: June 26, 2007, 02:54:25 pm »
On Unix, we name our grep utility "sgrep" so there is no conflict.  On Windows, I actually copy our executable elsewhere as "sgrep" so I know I'm getting ours.  What if we renamed it to "sgrep" on Windows?  "vgrep" or "vsgrep" also works.

Clark

hs2

  • Senior Community Member
  • Posts: 2752
  • Hero Points: 291
Re: troubles with getting GDB to work correctly
« Reply #10 on: June 26, 2007, 03:03:02 pm »
@Clark: Didn't know (though I assumed it) that your UNIX platform support already handles this situation.
'sgrep' is perfect and could be uniformly handled in your code - well, maybe not... ;)

Thanks,
HS2

hs2

  • Senior Community Member
  • Posts: 2752
  • Hero Points: 291
Re: troubles with getting GDB to work correctly
« Reply #11 on: September 13, 2007, 02:23:55 pm »
v12.03 on WXP still comes with 'grep.exe' - no 'sgrep.exe' :(
HS2