Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtolio/crawlspace
If enabled, allows live debug scripting of a running process's Go objects and types over a TCP socket.
https://github.com/jtolio/crawlspace
debugging go golang
Last synced: 10 days ago
JSON representation
If enabled, allows live debug scripting of a running process's Go objects and types over a TCP socket.
- Host: GitHub
- URL: https://github.com/jtolio/crawlspace
- Owner: jtolio
- License: apache-2.0
- Created: 2015-09-27T05:24:40.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-05-21T19:34:44.000Z (6 months ago)
- Last Synced: 2024-10-16T14:58:09.420Z (22 days ago)
- Topics: debugging, go, golang
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crawlspace
https://pkg.go.dev/github.com/jtolio/crawlspace
package crawlspace provides a means to dynamically interact with registered Go
objects in a live process, using small scripting language based around the
reflect package.Inspiration is mainly from Twisted's manhole library:
https://twistedmatrix.com/documents/current/api/twisted.conch.manhole.htmlExample usage:
```
package mainimport (
"github.com/jtolds/crawlspace"
)type MyType struct{ x int }
func (m *MyType) Set(x int) { m.x = x }
func (m *MyType) Get() int { return m.x }func main() {
space := crawlspace.New(nil)
space.RegisterVal("x", &MyType{})
panic(crawlspace.ListenAndServe("localhost:2222"))
}
```After running the above program, you can now connect via telnet or netcat
to localhost:2222, and run the following interaction:```
> x.Get()
0
> x.Set(5)
> x.Get()
5
```If you import the `github.com/jtolds/crawlspace/tools` package, you can have an
extremely powerful experience that doesn't require type registration, driven by
https://github.com/zeebo/goof.```
space := crawlspace.New(tools.Env)
```And here's an example history inspecting a process:
```
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
github.com/jtolio/[email protected]
github.com/jtolio/crawlspace-test@(devel)
> import "net"
> import "reflect"
> import "unsafe"
> conn := reflect.NewAt(net.conn, unsafe.Pointer(uintptr(0xc00028e038))).Interface()
> dir(conn)
[]string{"Close", "File", "LocalAddr", "Read", "RemoteAddr", "SetDeadline", "SetReadBuffer", "SetReadDeadline", "SetWriteBuffer", "SetWriteDeadline", "Write", "fd"}
> addr := conn.RemoteAddr()
> addr.String()
"127.0.0.1:43868"
> dir(addr)
[]string{"AddrPort", "IP", "Network", "Port", "String", "Zone"}
> ips, err := net.LookupIP("google.com")
> err
nil
> ips[1].String()
"172.217.2.46"
>
```Copyright 2015-2023, JT Olds. Licensed under Apache License 2.0