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

Debugger (fixes #25) #588

Merged
merged 17 commits into from Feb 24, 2014
Merged

Debugger (fixes #25) #588

merged 17 commits into from Feb 24, 2014

Conversation

dlsniper
Copy link
Member

@dlsniper dlsniper commented Feb 7, 2014

The unicorn. At last.

  • Unfortunately, support for pointer vars is really bad at the moment as far as I've tested so this should be improved before merging (if possible)
  • default gdb path should work out of the box, maybe we can get away with using just gdb instead of full path
  • add version check
  • stop process once debugger is stopped
  • check that breakpoints work with goroutines
  • check that debugger works with an http app

Early access preview download here: https://www.dropbox.com/sh/kzcmavr2cmqqdqw/j8wjp8SdNH (the debugger-.. jar). Please understand this is a beta :)

@jhsx
Copy link
Contributor

jhsx commented Feb 7, 2014

Hi @dlsniper, i was testing with latest updates, for some reason the breakpoints are not working, i tried with the code posted in #565 and with some examples

@dlsniper
Copy link
Member Author

dlsniper commented Feb 7, 2014

I think I've broke something in some of the commits today.

If you run the code as it is now, from the debugger branch, can you please tell me the output from the console? There should be a bunch of lines starting with {[Parsing line]}. If they are not there, pass -Dgo.gdb.dev.debug=true to IDEA when launching it.

Also, which GDB version are you running on?

Thanks!

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

I am running with GDB 7.6.1 and Go 1.2

{[Parsing line]} =thread-group-added,id="i1"
{[Parsing line]} ~"GNU gdb (GDB) 7.6.1\n"
{[Parsing line]} ~"Copyright (C) 2013 Free Software Foundation, Inc.\n"
{[Parsing line]} ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
{[Parsing line]} ~"This GDB was configured as \"x86_64-apple-darwin13.0.0\".\nFor bug reporting instructions, please see:\n"
{[Parsing line]} ~"<http://www.gnu.org/software/gdb/bugs/>.\n"
{[Parsing line]} (gdb) 
{[Parsing line]} 1^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","python"]
{[Parsing line]} (gdb) 
{[Parsing line]} &"add-auto-load-safe-path /usr/local/go\n"
{[Parsing line]} 2^done
{[Parsing line]} (gdb) 
{[Parsing line]} &"file /Users/josesantos/Documents/Dart/Examaple/Examaple\n"
{[Parsing line]} ~"Reading symbols from /Users/josesantos/Documents/Dart/Examaple/Examaple..."
{[Parsing line]} ~"done.\n"
{[Parsing line]} 3^done
{[Parsing line]} (gdb) 
{[Parsing line]} 4^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000002035",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="9",thread-groups=["i1"],times="0",original-location="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:9"}
{[Parsing line]} (gdb) 
{[Parsing line]} &"run\n"
{[Parsing line]} ~"Starting program: /Users/josesantos/Documents/Dart/Examaple/Examaple \n"
{[Parsing line]} =thread-group-started,id="i1",pid="2064"
{[Parsing line]} =thread-created,id="1",group-id="i1"
{[Parsing line]} 5^running
{[Parsing line]} *running,thread-id="all"
{[Parsing line]} (gdb) 
{[Parsing line]} =thread-created,id="2",group-id="i1"
{[Parsing line]} ~"[New Thread 0x170b of process 2064]\n"
{[Parsing line]} =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000002035",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="9",thread-groups=["i1"],times="1",original-location="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:9"}
{[Parsing line]} ~"\nBreakpoint "
{[Parsing line]} ~"1, main.main () at /Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:9\n"
{[Parsing line]} ~"9\t\tloc++\n"
{[Parsing line]} *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x0000000000002035",func="main.main",args=[],file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="9"},thread-id="1",stopped-threads="all"
{[Parsing line]} (gdb) 
{[Parsing line]} 6^exit
{[Parsing line]} =thread-exited,id="2",group-id="i1"
{[Parsing line]} =thread-exited,id="1",group-id="i1"
{[Parsing line]} =thread-group-exited,id="i1"

Thanks you.

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

@josehsantos seems that for some reason it couldn't load the Go GDB Runtime.
From what I can see, the following line is missing: {[Parsing line]} &"Loading Go Runtime support.\n" from output.

Also, it looks like there's no core="core-num" value in the output. so I think that's the reason why the breakpoint interception failed. It's a bit bad because I'm using a bunch of regex to do the output parsing and since you are using the same version as me then I can't even rely on the output to be correct at all :(

I'll continue to investigate this further. Thanks for helping out!

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

@josehsantos I've made some changes and it should now work for you again. Please let me know the outcome of this. Thanks!

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

It looks like even with Go 1.1.2, gdb itself is not able to read pointer vars. Unfortunately I'm on Ubuntu 13.10 which means Python 3 for me and the Go team has the gdb helper script for Python 2.7 (oh joy).

At least I'm happy to say it works as good as gdb works.

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

@dlsniper, breakpoints are ok 👍 but for some reason the "step(s)" are not working, seems like the python helper scripts is not being loaded.

{[Parsing line]} =thread-group-added,id="i1"
{[Parsing line]} ~"GNU gdb (GDB) 7.6.1\n"
{[Parsing line]} ~"Copyright (C) 2013 Free Software Foundation, Inc.\n"
{[Parsing line]} ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
{[Parsing line]} ~"This GDB was configured as \"x86_64-apple-darwin13.0.0\".\nFor bug reporting instructions, please see:\n"
{[Parsing line]} ~"<http://www.gnu.org/software/gdb/bugs/>.\n"
{[Parsing line]} (gdb) 
{[Parsing line]} 1^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","python"]
{[Parsing line]} (gdb) 
{[Parsing line]} &"add-auto-load-safe-path /usr/local/go\n"
{[Parsing line]} 2^done
{[Parsing line]} (gdb) 
{[Parsing line]} &"file /Users/josesantos/Documents/Dart/Examaple/Examaple\n"
{[Parsing line]} ~"Reading symbols from /Users/josesantos/Documents/Dart/Examaple/Examaple..."
{[Parsing line]} ~"done.\n"
{[Parsing line]} 3^done
{[Parsing line]} (gdb) 
{[Parsing line]} 4^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000002058",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="16",thread-groups=["i1"],times="0",original-location="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:16"}
{[Parsing line]} (gdb) 
{[Parsing line]} 5^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000002022",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="8",thread-groups=["i1"],times="0",original-location="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:8"}
{[Parsing line]} (gdb) 
{[Parsing line]} &"run\n"
{[Parsing line]} ~"Starting program: /Users/josesantos/Documents/Dart/Examaple/Examaple \n"
{[Parsing line]} =thread-group-started,id="i1",pid="7356"
{[Parsing line]} =thread-created,id="1",group-id="i1"
{[Parsing line]} 6^running
{[Parsing line]} *running,thread-id="all"
{[Parsing line]} (gdb) 
{[Parsing line]} =thread-created,id="2",group-id="i1"
{[Parsing line]} ~"[New Thread 0x170b of process 7356]\n"
{[Parsing line]} =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000002022",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="8",thread-groups=["i1"],times="1",original-location="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:8"}
{[Parsing line]} ~"\nBreakpoint "
{[Parsing line]} ~"2, main.main () at /Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:8\n"
{[Parsing line]} ~"8\t\tprintln(loc)\n"
{[Parsing line]} *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={addr="0x0000000000002022",func="main.main",args=[],file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="8"},thread-id="1",stopped-threads="all"
{[Parsing line]} (gdb) 
{[Parsing line]} 7^done,stack=[frame={level="0",addr="0x0000000000002022",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="8"}]
{[Parsing line]} (gdb) 
{[Parsing line]} 8^done,variables=[{name="loc"}]
{[Parsing line]} (gdb) 
{[Parsing line]} 9^done,name="var1",numchild="0",value="1",type="int",thread-id="1",has_more="0"
{[Parsing line]} (gdb) 
{[Parsing line]} 10^done,changelist=[]
{[Parsing line]} (gdb) 
{[Parsing line]} 11^running
{[Parsing line]} *running,thread-id="1"
{[Parsing line]} (gdb) 
{[Parsing line]} *running,thread-id="all"
{[Parsing line]} =thread-created,id="3",group-id="i1"
{[Parsing line]} ~"[New Thread 0x180b of process 7356]\n"
{[Parsing line]} =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000002058",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="16",thread-groups=["i1"],times="1",original-location="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:16"}
{[Parsing line]} ~"[Switching to Thread 0x180b of process 7356]\n"
{[Parsing line]} *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x0000000000002058",func="main.main",args=[],file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="16"},thread-id="3",stopped-threads="all"
{[Parsing line]} =thread-selected,id="3"
{[Parsing line]} (gdb) 
{[Parsing line]} 12^done,stack=[frame={level="0",addr="0x0000000000002058",func="main.main",file="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",fullname="/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go",line="16"}]
{[Parsing line]} (gdb) 
{[Parsing line]} 13^done,variables=[{name="loc"}]
{[Parsing line]} (gdb) 
{[Parsing line]} 14^done,changelist=[{name="var1",value="8",in_scope="true",type_changed="false",has_more="0"}]
{[Parsing line]} (gdb) 
{[Parsing line]} 15^running
{[Parsing line]} *running,thread-id="3"
{[Parsing line]} (gdb) 
{[Parsing line]} *running,thread-id="all"
{[Parsing line]} =thread-exited,id="3",group-id="i1"
{[Parsing line]} =thread-exited,id="2",group-id="i1"
{[Parsing line]} =thread-exited,id="1",group-id="i1"
{[Parsing line]} =thread-group-exited,id="i1",exit-code="0"
{[Parsing line]} *stopped,reason="exited-normally"
{[Parsing line]} (gdb) 
{[Parsing line]} 16^exit

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

i tried debugging manually with gdb to see if this is a problem with the gdb + Go, seems to be working.

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

@josehsantos cool.

Lets try this:

  • get the latest sources (if you haven't done so already)
  • in the configuration of the gdb runner, in the startup commands, add the following line:
    source PATH/TO/GOROOT/src/pkg/runtime/runtime-gdb.py

When you now run debugger it should work / load the runtime stuff now.

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

@dlsniper the runtime has loaded, but this continue to failing to step, i also had noted that the variable a from the previous code

a := "qwertyuiop[asdfghjkl;'zxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM:Hello world!!@#$%^&*()_+}|\"??><>~,./'\\]=-0987654321`<";

is receiving unexptected data received from GDB

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

@josehsantos this should work better now :)

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

And also the plugin forces the source thing automatically now since there's no issue with it.

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

@mtoader if everything goes ok and there are no complaints about it anymore, I'd like to have this merged into master so I can allow others to play around with it, do some other cleanup and have 0.9.16 released soonish :)

Thanks!

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

@dlsniper cool :), the issue with the string is fixed, but step(ing) is not working.

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

Which type of stepping doesn't work? And where do you have the breakpoints?

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

i have breakpoints in function calls, and variables operations. all step types are not working, even when i type

n

to step in the GDB Console is not working.

17:54:02.603 0> /usr/local/bin/gdb --interpreter=mi2
17:54:02.666 < [notify] thread-group-added: [id: "i1"]
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin13.0.0".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
17:54:02.703 1> -list-features
17:54:02.703 2> add-auto-load-safe-path /usr/local/go
17:54:02.704 3> source /usr/local/go/src/pkg/runtime/runtime-gdb.py
17:54:02.704 4> file /Users/josesantos/Documents/Dart/Examaple/Examaple
17:54:02.704 5> -break-insert -f /Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:25
17:54:02.704 6> -break-insert -f /Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:37
17:54:02.704 7> run
17:54:02.712 <1 [immediate] done: [features: [""frozen-varobjs"", ""pending-breakpoints"", ""thread-info"", ""data-read-memory-bytes"", ""breakpoint-notifications"", ""ada-task-info"", ""python""]]
add-auto-load-safe-path /usr/local/go
17:54:02.721 <2 [immediate] done
source /usr/local/go/src/pkg/runtime/runtime-gdb.py
Loading Go Runtime support.
Traceback (most recent call last):
  File "/usr/local/go/src/pkg/runtime/runtime-gdb.py", line 23, in <module>
    goobjfile = gdb.current_objfile() or gdb.objfiles()[0]
IndexError: list index out of range
17:54:02.721 <3 [immediate] done
file /Users/josesantos/Documents/Dart/Examaple/Examaple
Reading symbols from /Users/josesantos/Documents/Dart/Examaple/Examaple...done.
17:54:02.753 <4 [immediate] done
17:54:02.762 <5 [immediate] done: [bkpt: {number: "1", type: "breakpoint", disp: "keep", enabled: "y", addr: "0x000000000000217b", func: "main.main", file: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", fullname: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", line: "25", thread-groups: ["i1"], times: "0", original-location: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:25"}]
17:54:02.769 <6 [immediate] done: [bkpt: {number: "2", type: "breakpoint", disp: "keep", enabled: "y", addr: "0x0000000000002325", func: "main.main", file: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", fullname: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", line: "37", thread-groups: ["i1"], times: "0", original-location: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:37"}]
run
Starting program: /Users/josesantos/Documents/Dart/Examaple/Examaple 
17:54:02.775 < [notify] thread-group-started: [id: "i1", pid: "36741"]
17:54:02.775 < [notify] thread-created: [id: "1", group-id: "i1"]
17:54:02.781 <7 [immediate] running
17:54:02.781 <7 [exec] running: [thread-id: "all"]
17:54:02.790 < [notify] thread-created: [id: "2", group-id: "i1"]
[New Thread 0x170b of process 36741]
17:54:02.799 < [notify] thread-created: [id: "3", group-id: "i1"]
[New Thread 0x1803 of process 36741]
17:54:02.799 < [notify] thread-created: [id: "4", group-id: "i1"]
[New Thread 0x1903 of process 36741]
17:54:02.799 < [notify] breakpoint-modified: [bkpt: {number: "1", type: "breakpoint", disp: "keep", enabled: "y", addr: "0x000000000000217b", func: "main.main", file: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", fullname: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", line: "25", thread-groups: ["i1"], times: "1", original-location: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:25"}]

Breakpoint 1, main.main () at /Users/josesantos/Documents/Dart/Examaple/src/Examaple.go:25
25        demo()
17:54:02.799 < [exec] stopped: [reason: "breakpoint-hit", disp: "keep", bkptno: "1", frame: {addr: "0x000000000000217b", func: "main.main", args: [], file: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", fullname: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", line: "25"}, thread-id: "1", stopped-threads: "all", core: "1"]
17:54:02.975 8> -stack-list-frames
17:54:02.984 <8 [immediate] done: [stack: [frame: {level: "0", addr: "0x000000000000217b", func: "main.main", file: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", fullname: "/Users/josesantos/Documents/Dart/Examaple/src/Examaple.go", line: "25"}]]
17:54:03.013 9> -stack-list-variables --thread 1 --frame 0 --no-values
17:54:03.021 <9 [immediate] done: [variables: [{name: "c"}, {name: "e"}, {name: "b"}, {name: "f"}, {name: "a"}, {name: "d"}]]
17:54:03.023 10> -var-create --thread 1 --frame 0 - @ c
17:54:03.024 11> -var-create --thread 1 --frame 0 - @ e
17:54:03.024 12> -var-create --thread 1 --frame 0 - @ b
17:54:03.024 13> -var-create --thread 1 --frame 0 - @ f
17:54:03.024 14> -var-create --thread 1 --frame 0 - @ a
17:54:03.024 15> -var-create --thread 1 --frame 0 - @ d
17:54:03.024 16> -var-update --thread 1 --frame 0 --all-values *
17:54:03.030 <10 [immediate] done: [name: "var1", numchild: "0", value: "false", type: "bool", thread-id: "1", has_more: "0"]
17:54:03.038 <11 [immediate] done: [name: "var2", numchild: "0", value: "2.21", type: "float64", thread-id: "1", has_more: "0"]
17:54:03.041 <12 [immediate] done: [name: "var3", numchild: "0", value: "1.1200000000000001", type: "float64", thread-id: "1", has_more: "0"]
17:54:03.042 <13 [immediate] done: [name: "var4", numchild: "0", value: "7.8114940627634463e-318", type: "float64", thread-id: "1", has_more: "0"]
17:54:03.044 <14 [immediate] done: [name: "var5", numchild: "2", value: "{...}", type: "struct string", thread-id: "1", has_more: "0"]
17:54:03.046 <15 [immediate] done: [name: "var6", numchild: "33", value: "[33]", type: "[12]main.demostr", thread-id: "1", has_more: "0"]
17:54:03.048 <16 [immediate] done: [changelist: []]
17:54:03.158 17> -var-list-children --all-values "var5"
17:54:03.165 <17 [immediate] done: [numchild: "2", children: [child: {name: "var5.str", exp: "str", numchild: "1", value: "qwertyuiop[asdfghjkl;'zxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM:Hello world!!@#$%^&*()_+}|\\\"??><>~,./'\\\\]=-0987654321`<", type: "uint8 *", thread-id: "1"}, child: {name: "var5.len", exp: "len", numchild: "0", value: "109", type: "int64", thread-id: "1"}], has_more: "0"]
17:54:07.779 18> n
n
17:54:07.794 <18 [immediate] running
17:54:07.794 <18 [exec] running: [thread-id: "1"]
17:54:07.794 < [exec] running: [thread-id: "all"]
27        f := b + e
17:54:07.795 < [exec] stopped
17:54:07.796 19> -gdb-exit
17:54:07.804 <19 [immediate] exit
17:54:07.809 <19 [notify] thread-exited: [id: "4", group-id: "i1"]
17:54:07.809 < [notify] thread-exited: [id: "3", group-id: "i1"]
17:54:07.809 < [notify] thread-exited: [id: "2", group-id: "i1"]
17:54:07.809 < [notify] thread-exited: [id: "1", group-id: "i1"]
17:54:07.809 < [notify] thread-group-exited: [id: "i1"]

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

Can you please paste the file go file as well? I don't have the same lines as you for some reason based on the output. Thanks!

@dlsniper
Copy link
Member Author

dlsniper commented Feb 8, 2014

Also, did you run 2to3 on your runtime-gdb.py file? I'm not sure how to get the version of Python GDB is using, but I see an issue with this:

Traceback (most recent call last):
  File "/usr/local/go/src/pkg/runtime/runtime-gdb.py", line 23, in <module>
    goobjfile = gdb.current_objfile() or gdb.objfiles()[0]

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

sure, i am using the code from previous PR

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

    demo()

    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

dlsniper commented Feb 8, 2014

Cool. As a note, at least for me, GDB doesn't stop either on lines like _ = a. But it should work to stop on line 25 and it should work on with stepping into / next. Have you converted the runtime-gdb.py file with 2to3 ?

@jhsx
Copy link
Contributor

jhsx commented Feb 8, 2014

i have python 2.7.5

@dlsniper
Copy link
Member Author

dlsniper commented Feb 9, 2014

@mtoader afaik, there shouldn't be any issues with GDB now. I guess we need more testers now :)

Thanks!

@jhsx
Copy link
Contributor

jhsx commented Feb 10, 2014

hi @dlsniper, i am receiving a ClassNotFoundException on class uk.co.cwspencer.ideagdb.run.GdbRunConfigurationModule

/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java -Xmx512m -Xms256m -XX:MaxPermSize=250m -Didea.is.internal=true -ea -Dgo.skip.dev.warn=true -Dgo.gdb.dev.debug=true "-Xbootclasspath/a:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/boot.jar" -Didea.config.path=/Users/josesantos/Library/Caches/IdeaIC13/plugins-sandbox/config -Didea.system.path=/Users/josesantos/Library/Caches/IdeaIC13/plugins-sandbox/system -Didea.plugins.path=/Users/josesantos/Library/Caches/IdeaIC13/plugins-sandbox/plugins -Didea.smooth.progress=false -Dapple.laf.useScreenMenuBar=true -Didea.platform.prefix=Idea -Didea.launcher.port=7533 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 13 CE EAP.app/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/lib/tools.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/idea_rt.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/idea.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/bootstrap.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/extensions.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/util.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/openapi.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/trove4j.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/jdom.jar:/Applications/IntelliJ IDEA 13 CE EAP.app/lib/log4j.jar" com.intellij.rt.execution.application.AppMain com.intellij.idea.Main
[  13641]  ERROR - llij.ide.plugins.PluginManager - Fatal error initializing 'com.intellij.execution.RunManager' 
com.intellij.ide.plugins.PluginManager$StartupAbortedException: Fatal error initializing 'com.intellij.execution.RunManager'
    at com.intellij.ide.plugins.PluginManager.handleComponentError(PluginManager.java:239)
    at com.intellij.openapi.components.impl.PlatformComponentManagerImpl.handleInitComponentError(PlatformComponentManagerImpl.java:39)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:570)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:590)
    at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:225)
    at com.intellij.util.pico.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:212)
    at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:199)
    at org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer.getComponentInstance(AbstractDelegatingMutablePicoContainer.java:75)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponent(ComponentManagerImpl.java:121)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:112)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:89)
    at com.intellij.openapi.project.impl.ProjectImpl.init(ProjectImpl.java:307)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.initProject(ProjectManagerImpl.java:278)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.access$300(ProjectManagerImpl.java:82)
    at com.intellij.openapi.project.impl.ProjectManagerImpl$9.compute(ProjectManagerImpl.java:562)
    at com.intellij.openapi.project.impl.ProjectManagerImpl$9.compute(ProjectManagerImpl.java:558)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$4.run(ProgressManagerImpl.java:240)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:274)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.application.impl.ApplicationImpl$10$1.run(ApplicationImpl.java:642)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:420)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:150)
Caused by: java.lang.NoClassDefFoundError: uk/co/cwspencer/ideagdb/run/GdbRunConfigurationModule
    at uk.co.cwspencer.ideagdb.run.GoGdbRunConfigurationType$1.createTemplateConfiguration(GoGdbRunConfigurationType.java:17)
    at com.intellij.execution.configurations.ConfigurationFactory.createTemplateConfiguration(ConfigurationFactory.java:74)
    at com.intellij.execution.impl.RunManagerImpl.doCreateConfiguration(RunManagerImpl.java:139)
    at com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl.readExternal(RunnerAndConfigurationSettingsImpl.java:217)
    at com.intellij.execution.impl.RunManagerImpl.loadConfiguration(RunManagerImpl.java:775)
    at com.intellij.execution.impl.RunManagerImpl.readExternal(RunManagerImpl.java:670)
    at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.initJdomExternalizable(ComponentStoreImpl.java:179)
    at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.access$100(ComponentStoreImpl.java:44)
    at com.intellij.openapi.components.impl.stores.ComponentStoreImpl$1.run(ComponentStoreImpl.java:81)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:897)
    at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.initComponent(ComponentStoreImpl.java:74)
    at com.intellij.openapi.project.impl.ProjectImpl.initializeComponent(ProjectImpl.java:217)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:546)
    ... 28 more
Caused by: java.lang.ClassNotFoundException: uk.co.cwspencer.ideagdb.run.GdbRunConfigurationModule PluginClassLoader[ro.redeul.google.go, 0.9.16-dev]
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:68)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 41 more
[  13644]  ERROR - llij.ide.plugins.PluginManager - IntelliJ IDEA (Community Edition) IC-133.818  Build #IC-133.818 
[  13644]  ERROR - llij.ide.plugins.PluginManager - JDK: 1.7.0_45 
[  13645]  ERROR - llij.ide.plugins.PluginManager - VM: Java HotSpot(TM) 64-Bit Server VM 
[  13645]  ERROR - llij.ide.plugins.PluginManager - Vendor: Oracle Corporation 
[  13645]  ERROR - llij.ide.plugins.PluginManager - OS: Mac OS X 
[  13645]  ERROR - llij.ide.plugins.PluginManager - Last Action:  

Process finished with exit code 2

@dlsniper
Copy link
Member Author

That's strange. I was sure we are building the plugin for the CI against IDEA IC yet Travis seems to be ok... Maybe there's something wrong in the scripts.

I'll check against PHPStorm and IDEA IC when I get home to see what's up but the latest changes should not bring any changes that could cause that.

@jhsx
Copy link
Contributor

jhsx commented Feb 10, 2014

@dlsniper sorry was my fault, is all ok, i messed up with my local branch :( because of that i was getting the exception.

@m0sth8
Copy link
Member

m0sth8 commented Feb 11, 2014

@dlsniper is it hard to add support for remote debug?

@dlsniper
Copy link
Member Author

I guess it shouldn't be that hard. I was already thinking about adding debugging support for an already existing process so I guess remote debugging would be a good next step.

I do however want this merged to master first since it's quite big as it is and doing 10k changes PRs is something I usually don't do :D

@dlsniper
Copy link
Member Author

I've tested the debugger against the example provided in here: https://github.com/Unknwon/build-web-application-with-golang_EN/blob/master/eBook/11.2.md using full workflow described and everything went well.
Also, I could use the debugger both from the UI as well as send the commands directly to gdb via console (which I believe is very sexy that it worked :D)

mtoader added a commit that referenced this pull request Feb 24, 2014
@mtoader mtoader merged commit 3a21e14 into master Feb 24, 2014
@dlsniper dlsniper deleted the debugger branch February 24, 2014 08:16
@dvirsky
Copy link
Contributor

dvirsky commented Feb 24, 2014

I tried using it today (built master) with a fresh project and couldn't get it to work. (linux, idea 13, go 1.2). Are there any special instructions on configuration? hitting the debug button didn't do anything .

@dlsniper
Copy link
Member Author

Which gdb version are you using? Also, at the moment you need to create a separate runner from the run configuration, called Go Debug. I know it's not that intuitive but I couldn't figure out how to make it run with the other existing runner. Sorry.

@dlsniper
Copy link
Member Author

Also, the debugger will only be as good as gdb + go is, which in case of 1.2.. well it's not that good unfortunately.

@dvirsky
Copy link
Contributor

dvirsky commented Feb 25, 2014

I tried it again now on an existing project, I dunno what I did differently but it works now :)
I'm using gdb 7.5.91 on ubuntu 64 bit so you can mark that one as tested as well.

This is super fucking awesome, thanks to whoever worked on this, it's going to take mainstream Go development in general to the next level IMHO :)

@dlsniper
Copy link
Member Author

Cool, I'll send a PR to change the supported gdb versions tonight. Thanks for helping out :)

@dvirsky
Copy link
Contributor

dvirsky commented Feb 25, 2014

I have to say that this build from master solved a lot of the issues that bugged me last time I tried using the plugin. I hope it will be an official build soon.

@dlsniper
Copy link
Member Author

Yes, we are aware of it, we had some great contributions that fixed a lot of problems ^^.

I'll push for adding better support for GOPATH by the end of this (or next week) but unfortunately I can't promise a deadline on this as my job drains most of the resources I have these days.

With GOPATH issue enhanced we should have better support for new users as well as an easier to use IDE.

If you do find something that's not covered by a issue, feel free to open a new one. Thanks for helping us testing this!

@dvirsky
Copy link
Contributor

dvirsky commented Feb 25, 2014

I came across this little issue, tell me if it's reported: I create my own embedding wrapper around http.ServeMux that had its own Handle func with different arguments than http.ServeMux.Handle . The IDE highlighted it as an error with wrong number of arguments. It ran just fine of course. Is this a known issue?

@dlsniper
Copy link
Member Author

Hmm, it doesn't look familiar. If you can submit a new issue with a sample of code that reproduces it that would be great. Thanks.

@dvirsky
Copy link
Contributor

dvirsky commented Feb 25, 2014

sure thing, I'll try to create a contained example.

@dvirsky
Copy link
Contributor

dvirsky commented Feb 25, 2014

that's odd, I can't recreate it in an isolated project, and sadly the project I'm working on is not opened so I can't just have you clone it :( it muse be some edge case of namespaces etc

@twoolie
Copy link

twoolie commented Feb 27, 2014

@dlsniper when using this plugin the "Go Debug" run config is greyed out and displays the following error.

image

Is there any log that I can check to see what is going wrong? There's nothing displayed in the IntelliJ Event Log.

@dlsniper
Copy link
Member Author

@twoolie thanks for helping out with testing this. Can you please share more details for it? Which IDEA version (or other IDE) you are using, how did you installed it and what steps have you took to have that appear? Also, what's your gdb version and on which OS are you on? Please feel free to open a separate issue for this.

Thank you!

@twoolie
Copy link

twoolie commented Feb 27, 2014

I'm running Idea 13.0.2 on Ubuntu 13.04 with go 1.1.1 and gdb 1.1.27.5.91.

To install, I unpacked Idea, installed the latest google-go-language.jar available from dropbox as of today then configured it to recognise the go sdk and my simple test package. When I restarted Idea, there was a new Run Configuration called Go Debug which was greyed out with a red cross, and when editing the debug configuration, I found the message given above.

I will certainly submit a bug if this is a new error, and not simply an unsupported combination.

@twoolie
Copy link

twoolie commented Mar 4, 2014

@dlsniper I've managed to get past the error by deleting the run configuration that was automatically created, and creating a new "Go Application" configuration, however I've hit another issue. When trying to run the debugger the following commands are issued to GDB.

16:16:20.765 1> -list-features
16:16:20.765 2> add-auto-load-safe-path /usr/lib/go
16:16:20.765 3> source /usr/lib/go/src/pkg/runtime/runtime-gdb.py
16:16:20.766 4> file /go
16:16:20.766 5> -break-insert -f /home/twoolie/go/src/simple-project/main.go:11
16:16:20.766 6> -break-insert -f /home/twoolie/go/src/simple-project/main.go:13
16:16:20.766 7> run

The problem is that command 4 incorrectly specifies the file to run. Is there any extra configuration I'm missing, or is this just a failure to compute the correct binary output directory?

I'm running with the same system as the previous comment, but with the newest version of google-go-language.jar from dropbox (uploaded 32 hours ago). Please let me know if there's any more information I can provide you.

@twoolie
Copy link

twoolie commented Mar 4, 2014

I managed to get past the previous error by setting the "Build before run" option under the run tab.


Rest of report moved to: #639

@dlsniper
Copy link
Member Author

dlsniper commented Mar 4, 2014

@twoolie thanks for reporting that. But could yo please open new issues in the future so that I can keep track of them better? I'll create a new one out of your report now but it's nicer that way. Thanks.

@dlsniper dlsniper mentioned this pull request Mar 4, 2014
@twoolie
Copy link

twoolie commented Mar 4, 2014

@dlsniper yes, I will open a new report in the future.

@d3xter
Copy link
Contributor

d3xter commented Mar 5, 2014

The previous error happened, because when "Build before run" is disabled, there is no OutputDir and gdb wont find the executable. Fixed by #644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants