Home Download Buy Blog Forum Support

Debuging

Debuging

Postby dbabo on Tue Jun 26, 2012 2:11 pm

Hello,
is there a way to add some kind of debuging plugin maybe? To be able to add breakpoints and see local vars will be 70% of what i need @ the moment.
At the moment i 'm interested in GDB integration since this is what is used by go(lang)
Please let me know
dbabo
 
Posts: 25
Joined: Tue Jun 26, 2012 1:47 pm


Re: Debuging

Postby dbabo on Tue Jun 26, 2012 5:09 pm

this is reaaaal good. Thank you!

a few hopefully queick questions and observations:
a. when i start the debugger (f5), right click on the variable -> "add to watches" the sublime hangs ofr a few seconds. I have 3 core AMD and it goes for 4% utilization ( nothing else is running ).
b. sorry about this naive question.
what is the right sequence for debugging session? Right now i'm doing this:
1. save file.
2. set breakpoint
3. right click on the var to add it to the watch.
3. F5 to start the debugger and F5 to advance to the breakpoint.

but i don't see any indication of the degugger running, nor i see where the current line is ....
Obviously i'm doing something wrong.
Please advise.
dbabo
 
Posts: 25
Joined: Tue Jun 26, 2012 1:47 pm

Re: Debuging

Postby quarnster on Tue Jun 26, 2012 6:25 pm

Which OS are you using? The plugin is pretty much untested on Windows and has issues on Linux, making it impossible to add breakpoints or watches while the target is running. Feel free to contribute code fixing it.

As for running status, you'll want to check the callstack view and the threads view. To fix anything that's broken, you'll likely want to keep an eye in the GDB Session view which will print all the commands sent to gdb and all the data that is received from it in raw format.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: Debuging

Postby dbabo on Tue Jun 26, 2012 7:04 pm

quarnster wrote:Which OS are you using? The plugin is pretty much untested on Windows and has issues on Linux, making it impossible to add breakpoints or watches while the target is running. Feel free to contribute code fixing it.

i'm on RH6 64. The link does not point to the issue i experienced - in my case the sublime is getting frozen for a few seconds while no execution/debugging is happening. It's rather minor @ this point for me.

...
As for running status, you'll want to check the callstack view and the threads view. To fix anything that's broken, you'll likely want to keep an eye in the GDB Session view which will print all the commands sent to gdb and all the data that is received from it in raw format.


right - but do i do this right - set breakpoint, hit F5 and hit F5 again to get the program to advance to the breakpoint? becasue i see no changes anywhere. And it's a simple code really:

package main

import (
//
"example/newmath"
"fmt"
"os"
)

type F_error struct {
f_name string
}

var (
F_name1 string = "/tmp/abc.txt"
F_name2 string
)

func main() {

// Open a file.
// Read from the file and print on to the screen
file_1, err := os.Open(F_name1)
if err != nil {
fmt.Println(err)
}

fmt.Println("File name is %v ", &file_1)
// Read from another file and append original
// and replace the original file

fmt.Printf("Hello, world. Sqrt(2) = %v\n", newmath.Sqrt(2))
// os.Open(new_file)

}
dbabo
 
Posts: 25
Joined: Tue Jun 26, 2012 1:47 pm

Re: Debuging

Postby quarnster on Tue Jun 26, 2012 7:10 pm

Never done anything go releated. Check the GDB session view for info on what it's doing.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: Debuging

Postby dbabo on Tue Jun 26, 2012 7:22 pm

quarnster wrote:Never done anything go releated. Check the GDB session view for info on what it's doing.


ok. it seems it's waiting for "file" ... hmmm
another question:
one closed (with mouse) all the "little" windows - stack etc. But the area where there were is still open. How can i close it if restart doesn't help ?
dbabo
 
Posts: 25
Joined: Tue Jun 26, 2012 1:47 pm

Re: Debuging

Postby quarnster on Tue Jun 26, 2012 7:40 pm

If it's waiting for "file" you probably haven't set sublimegdb_commandline properly in the configuration so it doesn't know what executable you are trying to debug.

The layout is restored when the gdb session exits (select stop debugging in the right click menu). If stopping debugging doesn't work, you can also use the layout shortcuts or menu item. Menu item View->Layout->Single for example.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: Debuging

Postby dbabo on Tue Jun 26, 2012 7:55 pm

quarnster wrote:If it's waiting for "file" you probably haven't set sublimegdb_commandline properly in the configuration so it doesn't know what executable you are trying to debug.



correct you are . I haven't touched anything. now i opened the sublimegdb.sublime-settings and it has this :
Code: Select all
// All options in here can also be specified in your project settings
    // with a prepended "sublimegdb_". You probably want to
    // have something like this in your project settings:
    //
    // "settings":
    // {
    //      "sublimegdb_sourcedir": "/path/to/your/project/source",
    //      "sublimegdb_workingdir": "/path/to/your/project",
    //      // NOTE: You MUST provide --interpreter=mi for the plugin to work
    //      "sublimegdb_commandline": "gdb --interpreter=mi ./your_executable_name"
*    //      ]
    // }
    //
    "workingdir": "/tmp",

    // NOTE: You MUST provide --interpreter=mi for the plugin to work
    "commandline": "gdb --interpreter=mi ./executable",


can i have the executable_name as a dynamic value? for example if i need to review the package it will have a different name from the main exec file.
i added "*" in one of the lines above. I believe there should be a "}" not a "]".

how do i find out where the gdb gets executed? it seemed to unable to locate my file... -- aha! i must have the sublimegdb_workingdi set.

The layout is restored when the gdb session exits (select stop debugging in the right click menu). If stopping debugging doesn't work, you can also use the layout shortcuts or menu item. Menu item View->Layout->Single for example.


perfect - that worked like a charm. thank you !


now , once i added the sction above to the project file the gdb seemed to pick up on the file. At least i see some meaningful information.
here is what i noticed tho in gdb session window:
Code: Select all
/usr/local/go/src/pkg/runtime/runtime-gdb.py (referenced in .debug_gdb_scripts): No such file or directory\n"
(gdb)
(gdb)
33^error,msg="Undefined show command: \"interpreter\".  Try \"help show\"."
(gdb)

i can't locate the .debug_gdb_scripts file. where is it and is it important? --- this is something GO specific. I'm looking into this. please ignore.
update: there is a http://code.google.com/p/go/issues/detail?id=3180

do i need to care about the "interpreter" error ?

i replaced the code above with the simple loop:
Code: Select all
for i := 0; i < 10; i++ {
      println(i)
   }

put the breakpoint @ println line
now in gdb console i see the println (i'm assuming) printing the sequence of 0123... but how can i see the actual value in variable?
the gdb variables window is empty.
the gdb breakpoints has this :
Code: Select all
-1 - watch: F_name1
-1 - watch: file_1
-1 - watch: i
1 - /home/azz/work/workspace/src/az/main.go:35


and in the gdb Session ( once i add the i thru the gdb drop down manu "Add watch":
Code: Select all
225-break-watch i
225^error,msg="No symbol \"i\" in current context."
(gdb)

dbabo
 
Posts: 25
Joined: Tue Jun 26, 2012 1:47 pm

Re: Debuging

Postby dbabo on Wed Jun 27, 2012 2:31 pm

dbabo wrote:....
now , once i added the section above to the project file the gdb seemed to pick up on the file. At least i see some meaningful information.
here is what i noticed tho in gdb session window:
Code: Select all
/usr/local/go/src/pkg/runtime/runtime-gdb.py (referenced in .debug_gdb_scripts): No such file or directory\n"
(gdb)
(gdb)
33^error,msg="Undefined show command: \"interpreter\".  Try \"help show\"."
(gdb)

i can't locate the .debug_gdb_scripts file. where is it and is it important? --- this is something GO specific. I'm looking into this. please ignore.
update: there is a http://code.google.com/p/go/issues/detail?id=3180

do i need to care about the "interpreter" error ?

i replaced the code above with the simple loop:
Code: Select all
for i := 0; i < 10; i++ {
      println(i)
   }

put the breakpoint @ println line
now in gdb console i see the println (i'm assuming) printing the sequence of 0123... but how can i see the actual value in variable?
the gdb variables window is empty.
the gdb breakpoints has this :
Code: Select all
-1 - watch: F_name1
-1 - watch: file_1
-1 - watch: i
1 - /home/azz/work/workspace/src/az/main.go:35


and in the gdb Session ( once i add the i thru the gdb drop down manu "Add watch":
Code: Select all
225-break-watch i
225^error,msg="No symbol \"i\" in current context."
(gdb)



I think the error "no symbol" is specific to GO. According to this manual GO vars are "package.var" (http://golang.org/doc/gdb).
This guy seemed to got GDB to play nicer %) with his IDE (http://code.google.com/p/liteide/) at least i can see all variables in the "variable" window during debugging.

I really wish i'm missing something obvious since over 2 days i've been playing with your extension and Sublime i found myself enjoying it much better then other implementations.
dbabo
 
Posts: 25
Joined: Tue Jun 26, 2012 1:47 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests