Comments (11)
👍 // godebug: break
Throw an error/warning when a breakpoint is not possible.
from godebug.
@omeld 's suggestion seems to resolve the problem of improper placement, just error out.
I particularly like this comment based breakpoint idea also because then break points could have meaningful names/phrases attached to them rather than being known by numbers only when enabling/disabling/deleting/making conditional/managing breakpoints.
e.g.
// godebug: break "top of main event loop"
Granted this isn't needed when debugging in, say, emacs; but until you get full source code for context, knowing which breakpoint you've stopped on can instantly give you the relevant context.
from godebug.
Nice, I like the labeled breakpoint idea.
from godebug.
I implemented something different:
_ = "breakpoint"
I prefer the look of // godebug: break
, but implementing it was trickier than I expected. Since comments are not part of the AST, it's not clear where to put the breakpoint for a comment in all cases. Here's an example weird case:
for {
fmt.Println("y")
} // godebug: break
The go/ast package provides a mapping function between AST nodes and associated comments, but there is a fair amount of extra work to do to go from an arbitrary AST statement node to the appropriate place in the tree to insert a breakpoint function call.
_ = "breakpoint
, on the other hand, is straightforward. It is parsed as part of the AST. All we have to do is replace its node with the AST representation of godebug.SetTraceGen(ctx)
.
I considered _ = "godebug: break"
, but thought it looked too complicated. I expect _ = "breakpoint"
to be easier to memorize.
from godebug.
Very clever solution. I especially like that its a no-op without godebug, so I can leave it in the code. Can _ = "breakpoint" style breakpoints have comments on top? I'm imagining a conditional breakpoint syntax.
for i:=1; i < 200; i++ {
_ = "breakpoint" // if i == 100
}
from godebug.
You can do conditional breakpoints like this for now:
for i:=1; i < 200; i++ {
if i == 100 {
_ = "breakpoint"
}
}
from godebug.
I know. I just thought it would blow people's minds when they saw it. ;-)
from godebug.
I do like getting to blow people's minds :) I'll think about it.
from godebug.
I am not sure if I am liking the new syntax. Having to change code for break points is not the best way to go in my opinion.
I understand that comment basted instrumentation maybe slightly slow but some proper caching can mitigate that issue.
from godebug.
blow people's minds
As far as I know, most users of Go prefer simple, obvious, dumb solutions, rather than shocking, unexpected, complex or mind-blowing. :)
from godebug.
I am not sure if I am liking the new syntax. Having to change code for break points is not the best way to go in my opinion.
What do you think is bad about changing the code like this for a breakpoint?
I understand that comment basted instrumentation maybe slightly slow but some proper caching can mitigate that issue.
Slowness is not the issue with using comment syntax. When I said "there is a fair amount of extra work to do to go from an arbitrary AST statement node to the appropriate place in the tree", I meant that there was a fair amount of extra thought and programming work to do, not that it would be slow at runtime.
_ = "breakpoint"
was just a lot easier to implement.
from godebug.
Related Issues (20)
- Does it work on Windows? HOT 4
- Feature Request: Auto-print after breakpoint HOT 1
- Windows binaries lack .exe extension
- Functions defined as part of an array or slice literal are not instrumented
- Can't convert variables to other types to inspect with print command HOT 2
- --ldflags is not supported HOT 1
- godebug not found HOT 2
- Auto instrument packages with breakpoints
- Can't get `godebug test` to work on Terraform codebase
- Doesn't handle bad recover usage
- Godebug does not work with vendoring HOT 5
- syntax highlighting
- search package only in base gopath HOT 3
- Website not updated
- cannot find package "golang_org/x/net/route" HOT 1
- godebug does not work with code that imports net/http (since go 1.6) HOT 10
- godebug fails after addition of net/http package HOT 1
- cgdb like TUI for godebug.
- So what's the deal? HOT 3
- question a bout debuger HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godebug.