Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    132
    Rep Power
    2

    Debugging and breakpoints in Eclipse.


    Hi.

    is there a way to let the program run and start debugging from a specified line of code?
    from what i understand, it can be done with breakpoints, but when i set a breakpoint (by marking a blue dot on the numbers line at the left), the program just ignores it and skips the breakpoint.

    thanks in advanced!
  2. #2
  3. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    I don't use eclipse but it's likely that the code is never getting to the line containing the breakpoint. Put the breakpoint on an earlier line - that you know is executed.

    Maybe there is also a difference between choosing Run or Debug - perhaps Run ignores the breakpoints.

    If neither of these are solutions then I'm guessing the debugging is not configured correctly.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    132
    Rep Power
    2
    Originally Posted by AndrewSW
    I don't use eclipse but it's likely that the code is never getting to the line containing the breakpoint. Put the breakpoint on an earlier line - that you know is executed.

    Maybe there is also a difference between choosing Run or Debug - perhaps Run ignores the breakpoints.

    If neither of these are solutions then I'm guessing the debugging is not configured correctly.
    Hi AndrewSW,
    thanks for the help.

    i know for a fact that the program gets to the lines that contains the breakpoints, because when i run the program it gets to the end of the code.
    i also tried several breakpoints, but it skipped them all.

    how and where do i configure the debugger?
  6. #4
  7. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    I don't know if these links will help. Otherwise you might be better served in an eclipse forum. I would search the forum first as the question will have been asked many times before.

    Added: Actually, if you installed eclipse via PHP Development Tools (PDT) then you should be able to configure it from Run/ Debug Configurations.. and/or Run Configurations...

    I should say that I hate eclipse..
    Last edited by AndrewSW; December 15th, 2012 at 05:42 PM.
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    It is not enough to just set the breakpoint alone. You must also run the program in debugging mode (not in Run mode, which is what I suspect you are doing). In eclipse, this is a separate button usually to the left of the green play button (looks like a little green bug). Alternatively, you can do the same thing by hitting F11 to run in debug mode, or select Run --> Debug
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    132
    Rep Power
    2
    thank you both for the help.

    Scorpions4ever,
    i noticed the difference between run mode and debug mode.
    when i press debug (little green bug button, like you mentioned) - it start debugging from the first line, instead of just run the program until the first breakpoint.

    AndrewSW,
    thanks, i'll try at the Eclipse forums.
    btw, why do you hate Eclipse?
    what are you using?

    i'm only asking because even though i'm enjoying Eclipse, i don't care trying new alternatives (i'm kinda new to programming...).
  12. #7
  13. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    In the debug configuration I mentioned there is a tick-box that says something like "Debug from first line..": un-tick this.

    Hate is probably over-stating it:
    I don't like all the Workspace, Project, Perspective nonsense - I want the ability to just open any file or folder!
    It is very awkward to update - you can't just do something like 'Tools/ Options/ Update'.
    Inserting plug-ins is a pain - although I believe there is a plug-in to help with the plug-ins .

    You might look at NetBeans - it's easier to work with and configure. [If you are looking at PHP and programming as a profession you might persist with eclipse for a while as it is widely used - but there is no harm in using/knowing both.]

    I actually use Komodo Edit , but it doesn't have PHP debugging (the commercial version does). Well, mainly I use Sublime Text but it (by default) has neither debugging tools nor error-highlighting/indicators - I don't need them .

    I, like, I suspect, a lot of PHP programmers, very rarely use PHP debugging. PHP has echo, print_r, var_dump, and many other ways to check what is happening while a page is running, and setting up the debugger can be a pain.

    That said, you are almost there! Once you've got the debugging feature working it could help you to learn PHP, and it's a useful PHP skill to have.
    Last edited by AndrewSW; December 16th, 2012 at 05:18 AM.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    132
    Rep Power
    2
    Thanks but this all too advanced for me.
    i just started learning C, and im still a newbie...
  16. #9
  17. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    Originally Posted by so.very.tired
    Thanks but this all too advanced for me.
    i just started learning C, and im still a newbie...
    Sorry, don't know why I assumed you were using PHP?! But NetBeans is for C/C++ as well.

    Good luck.
  18. #10
  19. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    For what it is worth, I use Eclipse for Java development and it is very well suited for that.

    For C, C++, php, perl and python, I use emacs or mg (or vim if you insist) on *nix environments, only because I've been doing that for ever.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  20. #11
  21. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Originally Posted by so.very.tired
    Scorpions4ever,
    i noticed the difference between run mode and debug mode.
    when i press debug (little green bug button, like you mentioned) - it start debugging from the first line, instead of just run the program until the first breakpoint.
    You can either fiddle with the Debug Configuration and uncheck the Debug from First Line checkbox like Andrew mentioned, or you can hit F8 and the code will run until it hits your first breakpoint.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    132
    Rep Power
    2
    Hi, Scorpions4ever.

    i couldn't find anything that says "Debug from first line.." or similar to it.
    here's the Debug Configuration window:











    if you have any idea how tofix it i'll be gratful.
    my code is gettin bigger and bigger, and this exercise is due to friday night...
    breakpoints will make my life so much easier and might give me a chance to submit this on time.

    thanks again.
  24. #13
  25. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    Originally Posted by so.very.tired
    Hi, Scorpions4ever.

    i couldn't find anything that says "Debug from first line.." or similar to it.
    Did you try pressing F8 as Scorpions4ever suggested? Are you sure the line containing your breakpoint is actually executed when you run the code?
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    132
    Rep Power
    2
    Originally Posted by AndrewSW
    Did you try pressing F8 as Scorpions4ever suggested? Are you sure the line containing your breakpoint is actually executed when you run the code?
    yup.
    tried F8 but nothing seems to happen,
    also, this is how i set the breakpoints:
    i double click the left panel (where the lines index) and a blue dot appears.
  28. #15
  29. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Hit F11 or press the button with the green bug to start executing. When it starts debugging from the first line, hit F8 to make it continue till it hits the break point.

    Debugging tip: Say you have some code like this:
    Code:
    void some_func() {
        my_func(foo, bar);
        printf("Hello World");
    }
    and your break point is currently at my_func(foo, bar)
    F6 will execute one line at a time. So it will execute my_func(foo, bar) and then place the next debugging mark on the next line (the printf() line)
    F5 will drill down into the function and execute that one line at a time. So it will place the next debugging mark in the first line of my_func()
    F7 will execute the entire body of the function some_func() and place the next debugging mark in the function that called some_func()
    F8 will continue to the next breakpoint, wherever it may be.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo