Sorry ล one correction. When you launch GDB from your mynewt project folder, you have to give it the full path to newt
$gdb $GOPATH/bin/newt On 7/1/16, 4:37 PM, "[email protected]" <[email protected]> wrote: > >Just thought I'd share my debug experience with the newt tool using gdb. > >First, if you are a OS developer, you are probably not messing with newt >so there isn't much use for this tutorial; you may want to ignore this. >But if you are changing the newt or newtmgr code, this may be helpful. > >You must build your go code with the following options... to tell go to >add debug symbols. > > >go build -gcflags "-N -l" > > >Then you can run the debugger on the code. Do this from your mynewt >project folder: > >$gdb newt > >You should see this in the gdb startup: > > >Reading symbols from /Users/paulfdietrich/Development/Go/bin/newt...done. > >Loading Go Runtime support. > > >Once this happens, GDB automatically uses the goenv to set source paths >etc so this should not be a problem. > > >You run the program just like you would with gdb in other languages > > >(gdb) run -l DEBUG -v build app > > >Settings breakpoints is a bit trickier than with C since the namespaces >are required. > >To break in main, use > >(gdb)b main.main > >You must use the fully qualified namespace and function. So for apache my >newt's newt tool, use something like this > >(gdb)b mynewt.apache.org/newt/newt/builder.NewTargetBuilder > >If you have a function with a receiver, you can just add it to the name >like this with more dots in the namespace > >(gdb)b mynewt.apache.org/newt/newt/builder.(*TargetBuilder).Build > > >Happy Debugging!!! > >NOTE: I almost got all of this to work within LiteIDE except that I could >not tell it how to run the program from project directory of my mynewt >project, so I could not get it to find the project.yml files. Anyone >know how to set that stuff in LiteIDE. > >Paul > > > >
