Giter Site home page Giter Site logo

grok's People

Contributors

mertenvg avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

grok's Issues

bad pointer in write barrier

I am doing this on value tr of type *TestResult:

		grok.Value(tr)
		grok.InteractiveStack()

This yields a fatal error

value *TestResult = {
    Name string = "PricelistPackageExport" 22
    Request PricelistPackageExportRequest as interface{}Message = {
        PackageID uint64 = 334538
        TargetCurrency Currency = EUR
        DeprecatedTargetLabel Label = UNKNOWN_LABEL
    }
    Expect GRPCResult = {
        Response PricelistPackageExportReply as interface{}Message = {
            DeprecatedPriceExports []*PriceExport = []
            DeprecatedPriceType PriceType = PRICE_UNKNOWN_TYPE
            ChildPax uint64 = 0
            ChildPrices []*ChildPrice = []
            Prices []*Price = []
        }
        Error interface{}error = <nil>
    }
    Actual GRPCResult = {
        Response PricelistPackageExportReply as interface{}Message = {
            DeprecatedPriceExports []*PriceExport = []
            DeprecatedPriceType PriceType = PRICE_UNKNOWN_TYPE
            ChildPax uint64 = 0
            ChildPrices []*ChildPrice = []
            Prices []*Price = []
        }
        Error interface{}error = <nil>
    }
}
Interactive stack:

> help (h)          prints this help menu
> exit (x)          exits the interactive stack
> show (?)          repeats the current position
> quick (q)         summary of the entire stack
> next (n)          next item in the stack
> prev (p)          previous item in the stack
> top (t)           go to the top of the stack
> jump (j) {index}  jumps to the entry at the given index
> dump (d) {index}  prints a dump of the value corresponding to {index} of the current stack entry

position: 0
identifier: +0x38c
package: github.com/leisurespecials/coins/coins-refactor/pricing.(*ValidatingPriceServer).validateResult(0xc420124ea0, 0xaeb0c6, 0x16, 0xde8040, 0xc4204329e0, 0xde8000, 0xc4202c6780, 0x0, 0x0, 0xde8000, ..
receiver: 
function: )
args: 
    [0] 0xc420124ea0 0xc420124ea0
    [1] 0xaeb0c6 0xaeb0c6
runtime: writebarrierptr *0xc4204c8298 = 0x16
fatal error: bad pointer in write barrier

runtime stack:
runtime.throw(0xaef525, 0x1c)
	/usr/lib/go/src/runtime/panic.go:596 +0x95
runtime.writebarrierptr.func1()
	/usr/lib/go/src/runtime/mbarrier.go:208 +0xbd
runtime.systemstack(0xc420022000)
	/usr/lib/go/src/runtime/asm_amd64.s:327 +0x79
runtime.mstart()
	/usr/lib/go/src/runtime/proc.go:1132

goroutine 48 [running]:
runtime.systemstack_switch()
	/usr/lib/go/src/runtime/asm_amd64.s:281 fp=0xc4202b3250 sp=0xc4202b3248
runtime.writebarrierptr(0xc4204c8298, 0x16)
	/usr/lib/go/src/runtime/mbarrier.go:209 +0x96 fp=0xc4202b3288 sp=0xc4202b3250
github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok.(*point).out(0xc4200b6900, 0x0, 0xde2b40, 0xc42000e008, 0x4, 0x1, 0xa, 0x64)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok/stack.go:330 +0xa08 fp=0xc4202b3448 sp=0xc4202b3288
github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok.InteractiveStack(0x0, 0x0, 0x0)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok/stack.go:211 +0x3ac fp=0xc4202b38e8 sp=0xc4202b3448
github.com/leisurespecials/coins/coins-refactor/pricing.(*ValidatingPriceServer).validateResult(0xc420124ea0, 0xaeb0c6, 0x16, 0xde8040, 0xc4204329e0, 0xde8000, 0xc4202c6780, 0x0, 0x0, 0xde8000, ...)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/coins-refactor/pricing/validatingpricingserver.go:128 +0x38c fp=0xc4202b3a50 sp=0xc4202b38e8
github.com/leisurespecials/coins/coins-refactor/pricing.(*ValidatingPriceServer).PricelistPackageExport(0xc420124ea0, 0x7ff994009130, 0xc420586ab0, 0xc4204329e0, 0xc420124ea0, 0x42ae6e, 0x0)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/coins-refactor/pricing/validatingpricingserver.go:229 +0x253 fp=0xc4202b3b08 sp=0xc4202b3a50
github.com/leisurespecials/coins/coins._Pricing_PricelistPackageExport_Handler(0xa8c860, 0xc420124ea0, 0x7ff994009130, 0xc420586ab0, 0xc4204f01e0, 0x0, 0x0, 0x0, 0xc420022050, 0xc420022000)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/coins/pricing.pb.go:180 +0x28d fp=0xc4202b3b80 sp=0xc4202b3b08
github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc4201940c0, 0xded9e0, 0xc42021c630, 0xc4202c8000, 0xc42014d620, 0xe1faa8, 0xc420586a80, 0x0, 0x0)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:638 +0xb5c fp=0xc4202b3dd8 sp=0xc4202b3b80
github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).handleStream(0xc4201940c0, 0xded9e0, 0xc42021c630, 0xc4202c8000, 0xc420586a80)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:796 +0x1261 fp=0xc4202b3f80 sp=0xc4202b3dd8
github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc420266230, 0xc4201940c0, 0xded9e0, 0xc42021c630, 0xc4202c8000)
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:449 +0xa9 fp=0xc4202b3fb8 sp=0xc4202b3f80
runtime.goexit()
	/usr/lib/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc4202b3fc0 sp=0xc4202b3fb8
created by github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
	/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:450 +0xa1


If I uncomment one of the two lines, it does not crash.

This is not an issue for me, I intend to only use the Value dumper.

Make interactive feature for Value

As done with grok.InterativeStack() it would be nice to have an interactive version of the grok.Value() function where a user can inspect a complex data structure level by level without needing a complete dump of the entire value.

This would have the added benefit of halting all log output while the inspection is taking place (as it does with grok.InterativeStack() so there's no need to scroll back past possible countless lines of code.

Optional extra, be able to set/update values while grokking to see how it changes the behaviour of the application. This may be outside of the scope of this package so more feedback should be gathered before implementing this feature.

Should we annotate a nil slice?

I would like to use grok.Value() to inspect values for equality.

Consider this code:

var a []int
var b = make([]int, 0, 0)
fmt.Printf("%#v has type %T\n", a, a)
fmt.Printf("%#v has type %T\n", b, b)

it outputs:

[]int(nil) has type []int
[]int{} has type []int

Note that one slice is a nil-slice, and the other is a 0 element slice. They are printed identical in grok.

Although a nil-slice actually behaves like an empty slice, the DeepEqual makes a distinction:

Note that a non-nil empty slice and a nil slice (for example, []byte{} and []byte(nil)) are not deeply equal.

It might be nice to have the grok-output show that it's a nil-slice, for some purposes. For sometimes you may want to ignore this difference, so that you can do a deep-equal-like comparison that does consider them equal. Maybe an option can be added; I'm not sure if that would be bloat.

panic: reflect: call of reflect.Value.Type on zero Value

value *TestResult = {
Name string = "PricelistPackageExport" 22
Request PricelistPackageExportRequest as interface{}Message = {
PackageID uint64 = 340804
TargetCurrency Currency = EUR
DeprecatedTargetLabel Label = UNKNOWN_LABEL
}
Expect GRPCResult = {
Response PricelistPackageExportReply as interface{}Message = {
DeprecatedPriceExports []*PriceExport = []
DeprecatedPriceType PriceType = PRICE_UNKNOWN_TYPE
ChildPax uint64 = 0
ChildPrices []*ChildPrice = []
Prices []*Price = []
}
Error interface{}error =
}
Actual GRPCResult = {
panic: reflect: call of reflect.Value.Type on zero Value

goroutine 36 [running]:
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib/go/src/reflect/value.go:1682 +0x21f
github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok.dump(0x903d58, 0x8, 0x0, 0x0, 0x0, 0x2, 0xccb880, 0xc42000e018, 0x4, 0x1, ...)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok/value.go:72 +0x2736
github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok.dump(0x900f75, 0x6, 0x9a3980, 0xc420127420, 0x199, 0x2, 0xccb880, 0xc42000e018, 0x4, 0x1, ...)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok/value.go:234 +0x2064
github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok.dump(0xa1c53f, 0x5, 0x9cc460, 0xc4201273e0, 0x199, 0x1, 0xccb880, 0xc42000e018, 0x4, 0x1, ...)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok/value.go:234 +0x2064
github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok.Value(0x9d3b00, 0xc4201273e0, 0x0, 0x0, 0x0)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/github.com/bookerzzz/grok/value.go:48 +0x177
github.com/leisurespecials/coins/coins-refactor/pricing.(*ValidatingPriceServer).validateResult(0xc4200f9bd0, 0xa2ae94, 0x16, 0xcd0a40, 0xc4201ba420, 0xcd0a00, 0xc42016e300, 0x0, 0x0, 0xcd0a00, ...)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/coins-refactor/pricing/validatingpricingserver.go:126 +0x460
github.com/leisurespecials/coins/coins-refactor/pricing.(*ValidatingPriceServer).PricelistPackageExport(0xc4200f9bd0, 0x7f4320b4e108, 0xc4201aeae0, 0xc4201ba420, 0xc4200f9bd0, 0x4295ee, 0x0)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/coins-refactor/pricing/validatingpricingserver.go:226 +0x2a5
github.com/leisurespecials/coins/coins._Pricing_PricelistPackageExport_Handler(0x9c96a0, 0xc4200f9bd0, 0x7f4320b4e108, 0xc4201aeae0, 0xc420117450, 0x0, 0x0, 0x0, 0xc4200f61a0, 0xc42002e428)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/coins/pricing.pb.go:180 +0x28d
github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc42021e000, 0xcd5980, 0xc42023a090, 0xc4202bc000, 0xc420135ce0, 0xd043a8, 0xc4201aeab0, 0x0, 0x0)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:638 +0xb5c
github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).handleStream(0xc42021e000, 0xcd5980, 0xc42023a090, 0xc4202bc000, 0xc4201aeab0)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:796 +0x1261
github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc420234240, 0xc42021e000, 0xcd5980, 0xc42023a090, 0xc4202bc000)
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:449 +0xa9
created by github.com/leisurespecials/coins/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
/home/eric/workspaces/coins/src/github.com/leisurespecials/coins/vendor/google.golang.org/grpc/server.go:450 +0xa1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.