Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve debugger parser #565

Merged
merged 1 commit into from
Feb 6, 2014
Merged

Improve debugger parser #565

merged 1 commit into from
Feb 6, 2014

Conversation

dlsniper
Copy link
Member

This aims to improve the debugger parser (it's actually a rewrite of it).

Progress so far:

  • initial split between target application and GdbMi output
  • convert tokens
  • increase buffer size to 256 KB (not sure we need it or not but it can't hurt, can it?)
  • make run to cursor work
  • add support for breakpoint hit count support
  • add support for pointer variable support
  • mark debugging as stopped when process finishes inside Gdb
  • merge to master and release :)

@dlsniper
Copy link
Member Author

Currently I'm testing this against this app:

package main

import (
    "fmt"
)

type demostr struct {
    A int
    B string
}

func demo() {
    for i:=0; i<10; i++ {
        fmt.Printf("demo(%d)\n", i)
    }
}

func main() {
    a := "qwertyuiop[asdfghjkl;'zxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM:Hello world!!@#$%^&*()_+}|\"??><>~,./'\\]=-0987654321`<";
    b := 1.12
    c := false
    var d [12]demostr
    e := 2.21


    f := b + e
    /**/
    if c {
        fmt.Printf("a: %s \n", a)
        fmt.Printf("f: %v \n", f)
    } else {
        fmt.Printf("f: %v \n", f)
        fmt.Printf("a: %s \n", a)
    }
    /**/
    _ = a
    _ = c
    _ = f
    /**/
    _ = d

    demo();
}

@dlsniper
Copy link
Member Author

@josehsantos can you please have a quick look at it and see if it's working for you?

I'm compiling against go 1.1.2 right now with the plugin doing all the compilation stuff.

The only thing that doesn't work for me is displaying the value of a correctly but I haven't had time to implement it yet.

If you don't want to do the whole new upstream + change branches and stuff you can get the build from here: https://www.dropbox.com/sh/kzcmavr2cmqqdqw/fNqiNeKopr/debugger-google-go-language.jar (it contains the latest master as well).

Thanks a bunch!

@jhsx
Copy link
Contributor

jhsx commented Jan 30, 2014

@dlsniper sorry for the delay, i did downloads of the dropbox version, and almost every things is working, i'm getting an NullPointerException when read the children values,

GDB error
java.lang.NullPointerException
    at uk.co.cwspencer.ideagdb.debug.GdbValue.onGdbChildrenReady(GdbValue.java:122)
    at uk.co.cwspencer.ideagdb.debug.GdbValue.access$000(GdbValue.java:21)
    at uk.co.cwspencer.ideagdb.debug.GdbValue$1.onGdbCommandCompleted(GdbValue.java:92)
    at uk.co.cwspencer.gdb.Gdb.handleResultRecord(Gdb.java:457)
    at uk.co.cwspencer.gdb.Gdb.handleRecord(Gdb.java:405)
    at uk.co.cwspencer.gdb.Gdb.runGdb(Gdb.java:320)
    at uk.co.cwspencer.gdb.Gdb.access$000(Gdb.java:21)
    at uk.co.cwspencer.gdb.Gdb$1.run(Gdb.java:102)
    at java.lang.Thread.run(Thread.java:695)

and watches on global variables is not working, but i think this is gdb bug, i am testing with go 1.2 on mac.

@dlsniper
Copy link
Member Author

No worries ;)
I think watches on global vars aren't something I've tested and I guess for
the child values I still need to implement the parser for the output, so
that's expected.
But if it's working in example I've posted above then I'm happy.

Thanks!


Florin Patan / @dlsniper https://twitter.com/dlsniper
https://github.com/dlsniper
http://www.linkedin.com/in/florinpatan

On Thu, Jan 30, 2014 at 2:28 PM, José Santos notifications@github.comwrote:

@dlsniper https://github.com/dlsniper sorry for the delay, i did
downloads of the dropbox version, and almost every things is working, i'm
getting an NullPointerException when read the children values,

GDB error
java.lang.NullPointerException
at uk.co.cwspencer.ideagdb.debug.GdbValue.onGdbChildrenReady(GdbValue.java:122)
at uk.co.cwspencer.ideagdb.debug.GdbValue.access$000(GdbValue.java:21)
at uk.co.cwspencer.ideagdb.debug.GdbValue$1.onGdbCommandCompleted(GdbValue.java:92)
at uk.co.cwspencer.gdb.Gdb.handleResultRecord(Gdb.java:457)
at uk.co.cwspencer.gdb.Gdb.handleRecord(Gdb.java:405)
at uk.co.cwspencer.gdb.Gdb.runGdb(Gdb.java:320)
at uk.co.cwspencer.gdb.Gdb.access$000(Gdb.java:21)
at uk.co.cwspencer.gdb.Gdb$1.run(Gdb.java:102)
at java.lang.Thread.run(Thread.java:695)

and watches on global variables is not working, but i think this is gdb
bug, i am testing with go 1.2 on mac.


Reply to this email directly or view it on GitHubhttps://github.com//pull/565#issuecomment-33687213
.

@dlsniper
Copy link
Member Author

dlsniper commented Feb 4, 2014

Great news everyone! :D I've finished implementing all the tokens that are needed in order to make the program in this example: #565 (comment) work and as far as I can tell... it works! 💃

I've got a bit of cleanup to do and see how I can fix the remaining points but if this takes too long I'll merge this into the debugger branch. Time will tell.

@dlsniper
Copy link
Member Author

dlsniper commented Feb 5, 2014

I've started testing with a new program which revealed a couple of more unhandled cases (shocker :D).

package main

import (
    "fmt"
)

func foo(i *int) {
    fmt.Println(*i)
}

func test() (err error) {
    defer func() {
        if recover() != nil {
            fmt.Println("exception occured")
        }
    }()

    for i := 0; i <= 10; i++ {
        foo(&i)
    }
    foo(nil) // Should be panic
    return

}

func main() {
    test()
}

It was taken from here: https://github.com/golang-samples/basic

@dlsniper
Copy link
Member Author

dlsniper commented Feb 5, 2014

I've finished testing with the above code sample and it seems to be fine.
I'm not sure how to further test it as I don't have too many complex go apps.

@mtoader
Copy link
Member

mtoader commented Feb 5, 2014

We will use our users to do this ;).

@dlsniper
Copy link
Member Author

dlsniper commented Feb 5, 2014

Yes, indeed! The best kind of testing :D

Jokes aside, I'm not sure how to add support for breakpoint hit count and conditional stop (which would be nice to have) but I've opened a ticket on the forum to ask for some advice / help.

Other then this, I think I've covered all the stuff needed to run this properly. The code is not the state of art, and I think I've broke some sort of record of regular expression usage in a single file, but things can be improved later on :)

@dlsniper
Copy link
Member Author

dlsniper commented Feb 6, 2014

Bummer... Seems GDB doesn't like pointer variables like I'm passing them now... I've added the item to the list for the moment.

@alexandre-normand
Copy link
Contributor

It's with some embarrassment (as someone who had some commits in the early history of this plugin) that I'll admit to having spent the last year or so using GoSublime (to GoSublime's credit, it is quite nice) to write my Go code.

However, I've been watching all the recent activity and I'm pretty excited to see where this is going and trying it again. Anyway, I just wanted to say here that you guys might want to close issue #25 since this seems like this PR has the same goal but going miles further than the original plan was for #25.

@dlsniper
Copy link
Member Author

dlsniper commented Feb 6, 2014

#25 will be closed when debugger lands in master. Until then, since it's only an issue without commits, I'll consider that the anchor for this task.
As for GoSublime, with all due respect for their work, I think right now the plugin is much better, even with its current issues, that it :)

@dlsniper
Copy link
Member Author

dlsniper commented Feb 6, 2014

So.. as it stands, I'll merge this into the debugger branch as it's stable enough (tm).

I could spend more time to work on adding a breakpoint hit-count and a conditional breakpoint but I think for the moment it's enough.

Also, what's not supported (haven't tested) is how this behaves with goroutines and if it's easy to debug them (or even possible at all).

As for debugging the program itself, right now it's a bit of a unnatural way to do it, configure a different runner type, but I have no clue how to change it for now.

@mtoader if you think I should add those two things and further investigate the goroutines I'll try and do it. I will definitely spend time to see if I can make the debugging launching simpler.

After this, I plan to work on gcc compiler support, as I want to use it in my day to day work and I'm too lazy to do it until I have an automated tool to do it.

dlsniper added a commit that referenced this pull request Feb 6, 2014
@dlsniper dlsniper merged commit 69e7575 into go-lang-plugin-org:debugger Feb 6, 2014
@dlsniper dlsniper deleted the improve-debugger branch February 6, 2014 23:27
@alexandre-normand
Copy link
Contributor

@dlsniper: I think you might be right. I think I stopped using the plugin when I started using Go on the Google App Engine and it really didn't work well. All the recent work has me really excited.

@jhsx jhsx mentioned this pull request Feb 7, 2014
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants