• Stars
    star
    2,507
  • Rank 17,618 (Top 0.4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DEPRECATED! https://github.com/derekparker/delve

DEPRECATED! There will be no further development. Please use https://github.com/derekparker/delve. But if you want to keep the project going and ready to become its maintaner please contact us and we can make you one.

godebug


Linux Build Status Windows Build Status

A cross-platform debugger for Go.

How?

godebug uses source code generation to instrument your program with debugging calls. go tool cover takes a similar approach to code coverage. When you run godebug, it parses your program, instruments function calls, variable declarations, and statement lines, outputs the resulting code somewhere, and runs/compiles it. When this modified code runs, it stops at breakpoints and lets you step through the program and inspect variables.

For more detail, see the end of this README.

Status

godebug is still very new. File an issue or send me an email if you find any rough edges:

contact

Installation:

$ go get github.com/mailgun/godebug

Getting started:

Insert a breakpoint anywhere in a source file you want to debug:

_ = "breakpoint"

If the breakpoint is in package main and you don't want to examine any imported packages, you can just run:

$ godebug run gofiles... [arguments...]

If you want to trace the program outside of the main package, list the packages to trace in the -instrument flag:

$ godebug run -instrument=pkg1,pkg2,pkg3 gofiles... [arguments...]

If you are debugging a test, use 'godebug test' like you would use 'go test':

$ godebug test [-instrument pkgs...] [packages]

Finally, you can [cross-]compile a debugging binary using 'godebug build':

$ godebug build [-instrument pkgs...] [-o output] [package]

The compiled binary has no dependencies, so you can build it locally and then debug on i.e. a staging server.

That's it. See 'godebug help' for the full usage.

Debugger commands:

The current commands are:

command result
h(elp) show help message
n(ext) run the next line
s(tep) run for one step
c(ontinue) run until the next breakpoint
l(ist) show the current line in context of the code around it
p(rint) [expression] print a variable or any other Go expression
q(uit) exit the program

Caveats

It is not currently possible to step into standard library packages. (Issue #12)

How it works (more detail)

Consider this program:

package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
}

Now let's modify it a bit:

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    fmt.Println(`-> fmt.Println("Hello, world!")`)
    bufio.NewScanner(os.Stdin).Scan()
    fmt.Println("Hello, world!")
}

When we run this modified version, we see:

-> fmt.Println("Hello, world!")

And then the program waits for input before proceeding.

We have just implemented a debugger for the first program! It may not seem like much, but this program implements two fundamental debugger behaviors: (1) display the current state of the program, and (2) do not proceed until instructed by the user. Furthermore, the changes we made were straightforward and easy to automate:

  • insert import statements for bufio and os, if not already present.
  • in main(), insert the statement fmt.Println(<quote next line>)
  • in main(), insert the statement bufio.NewScanner(os.Stdin).Scan().

We could do exactly the same thing for any other program with a single-line main function. And it's not hard to see how to generalize this to multiple lines. This, in essence, is what godebug does. Parse source code, insert extra code that implements the behavior of a debugger for that program, output and run the result. godebug handles many more cases than this simple example and implements more interesting debugging behavior, but the principle is exactly the same.

More Repositories

1

transactional-email-templates

Responsive transactional HTML email templates
HTML
6,820
star
2

flanker

Python email address and Mime parsing library
Python
1,618
star
3

talon

Python
1,235
star
4

mailgun-php

Mailgun's Official SDK for PHP
PHP
1,078
star
5

gubernator

High Performance Rate Limiting MicroService and Library
Go
944
star
6

mailgun-js-boland

A simple Node.js helper module for Mailgun API.
JavaScript
896
star
7

kafka-pixy

gRPC/REST proxy for Kafka
Go
752
star
8

mailgun-go

Go library for sending mail with the Mailgun API.
Go
678
star
9

mailgun.js

Javascript SDK for Mailgun
TypeScript
501
star
10

mailgun-ruby

Mailgun's Official Ruby Library
Ruby
462
star
11

groupcache

Clone of golang/groupcache with TTL and Item Removal support
Go
424
star
12

expiringdict

Dictionary with auto-expiring values for caching purposes.
Python
331
star
13

holster

A place to keep useful golang functions and small libraries
Go
277
star
14

validator-demo

Mailgun email address jquery validation plugin http://mailgun.github.io/validator-demo/
JavaScript
259
star
15

node-prelaunch

A Mailgun powered landing page to capture early sign ups
JavaScript
230
star
16

dnsq

DNS Query Tool
Python
107
star
17

documentation

Mailgun Documentation
CSS
79
star
18

scroll

Scroll is a lightweight library for building Go HTTP services at Mailgun.
Go
61
star
19

kafka-http

Kafka http endpoint
Scala
51
star
20

forge

email dataset for email signature parsing
51
star
21

wordpress-plugin

Mailgun's Wordpress Plugin
PHP
47
star
22

lemma

Mailgun Cryptographic Tools
Go
39
star
23

multibuf

Bytes buffer that implements seeking and partially persisting to disk
Go
37
star
24

ttlmap

In memory dictionary with TTLs
Go
22
star
25

frontend-best-practices

Guides for React and Javascript coding style and best practices
21
star
26

pong

Generates http servers that respond in predefined manner
Go
20
star
27

proxyproto

High performance implementation of V1 and V2 Proxy Protocol
Go
19
star
28

log

Go logging library used at Mailgun.
Go
19
star
29

mailgun-meteor-demo

Simple meteor-based emailer with geolocation and UA tracking
JavaScript
16
star
30

timetools

Go library with various time utilities used at Mailgun.
Go
11
star
31

mailgun-java

Java SDK for integrating with Mailgun
Java
11
star
32

pelican-protocol

In ancient Egypt the pelican was believed to possess the ability to prophesy safe passage in the underworld. Pelicans are ferocious eaters of fish.
Go
11
star
33

metrics

Go library for emitting metrics to StatsD.
Go
11
star
34

roman

Obtain, cache, and automatically reload TLS certificates from an ACME server
Go
10
star
35

sandra

Go library providing some convenience wrappers around gocql.
Go
10
star
36

iptools

Go library providing utilities for working with hosts' IP addresses.
Go
9
star
37

cfg

Go library for working with app's configuration files used at Mailgun.
Go
9
star
38

minheap

Slightly more user-friendly heap on top of containers/heap
Go
8
star
39

logrus-hooks

Go
8
star
40

pebblezgo

go example of the pebblez transport: protocol buffers over zeromq
Go
7
star
41

glogutils

Utils for working with google logging library
Go
7
star
42

pylemma

Mailgun Cryptographic Tools
Python
5
star
43

callqueue

Serialized call queues
Go
4
star
44

media

Logos and brand guidelines
4
star
45

sneakercopy

A tool for creating encrypted tar archives for transferring sensitive data.
Rust
4
star
46

scripts

Example scripts that show how to interact with the Mailgun API
Python
1
star
47

etcd3-slim

Thin wrapper around Etcd3 gRPC stubs
Python
1
star