[go-nuts] [RFC] Dynamically instrumentation Go binaries

2018-11-15 Thread julio
robes, which is linux-specific. And at the opposite, there are user-space binary code instrumentation libraries such as dyninst that modify the code at run time... So I am wondering if anyone here has any thoughts on this subject, that doesn't seem to be solved for Go programs. Than

[go-nuts] How to safely convert a pointer to *unsafe.Pointer

2019-07-19 Thread julio
use atomic.Value which performs two atomic operations and possible disable preemption ( https://golang.org/src/sync/atomic/value.go?s=1233:1269#L35). Thanks for your help, Julio -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe f

[go-nuts] Distributing Go bindings: Go plugin vs Go archive vs Go shared package

2019-09-10 Thread julio
nclude the resulting Go package archive in the repo, and simply use some go CLI option in order to use the correct archive for the target GOOS/GOARCH? I couldn't find out how to pass such option to the go compiler so far, so I was hoping for some help. Thanks for your help, Julio -- You receiv

[go-nuts] Assigning a value to a function pointer

2019-12-23 Thread julio
using instead `*interface{}` (that I can atomically load + type-assert + call). Thanks for your help, Julio -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email

Re: [go-nuts] Assigning a value to a function pointer

2019-12-23 Thread julio
> > But I cannot find any way of assigning a value to the function pointer > `f` even using the `unsafe` package. > > https://play.golang.org/p/qP5kuSCW6dO > Thanks, unfortunately the asm shows that what gets into `f` is the stack address of `f0` and not the address of the function: LEAQ

[go-nuts] Enforcing a type name rather than a variable name

2020-01-03 Thread julio
Hello, Is there any way to avoid the compilation error "*error is not a type" of this example https://play.golang.org/p/gWNStGSCfTm ? I understand the variable named `error` hides the type named `error` but is there some other syntax to specify the error type? I am facing this issue while writi

[go-nuts] Re: Enforcing a type name rather than a variable name

2020-01-03 Thread julio
By the way, here is the function having this in package `net`: https://golang.org/src/net/lookup.go#L81 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nu

[go-nuts] How to print an AST without formatting?

2020-01-09 Thread julio
Hello, I am looking for a way to keep to original token positioning but I cannot find how to avoid it when using `go/printer` or `go/format`. Basically, how to make this example print the same string that was parsed: https://play.golang.org/p/dI7WcevQJAZ Thanks for your help! Julio -- You

Re: [go-nuts] Re: [RFC] Dynamically instrumentation Go binaries

2018-11-19 Thread Julio Guerra
y the best option for performance and to avoid code relocation at run time... Unfortunately, the go toolchain currently doesn't have any "plugin" interface to add extra compilation stages. -- Julio Guerra -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] [RFC] Dynamically instrumentation Go binaries

2018-11-19 Thread Julio Guerra
and it doesn't use any plugin interface :( -- Julio Guerra -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups

Re: [go-nuts] [RFC] Dynamically instrumentation Go binaries

2018-11-19 Thread Julio Guerra
is twice slower. So it may be a very good solution for a first linux-only version, as I don't need return probes (uretprobes seem to be a problem with Go's dynamic stack management). -- Julio Guerra -- You received this message because you are subscribed to the Google Groups "go

[go-nuts] Getting a function's linked address?

2019-10-29 Thread julio . nemesis
Hello, I am wondering if it is possible to get the address of a function but at link-time. Kind of the equivalent to the C keyword `extern`. Maybe using the link name directive? But it is not super clear to me. I would like to get them instead at link time instead of using the gosymtab. Thank

Re: [go-nuts] Getting a function's linked address?

2019-10-29 Thread julio . nemesis
I was meaning an equivalent to declaring an extern function using the same name as the symbol we want. The function address will be the linked symbol address. I indeed use the reflect package today, but this happen at run time while I would like to get those values at link time. I'd like to crea

Re: [go-nuts] Getting a function's linked address?

2019-10-31 Thread julio . nemesis
> > You can create a lookup table at run time. What would change if you > could do it at link time? Can you show us the code you want to write? > This is actually linked to my remark on build-time source instrumentation on https://github.com/golang/go/issues/35204 : I insert hooks into func

[go-nuts] Re: reading from file that is closed after starting the read

2016-06-14 Thread julio . nemesis
I am having the same trouble with a tty too. I ended up with pthread_kill to signal the specific goroutines blocked in read: https://play.golang.org/p/VZhm2-dX0B The two goroutines share their ids and wait for each other's completion with a signal. I am not sure how safe it is. But it does the

Re: [go-nuts] Is it safe to invoke len(channel) on multi-gorountine

2017-06-17 Thread julio . nemesis
I almost got into the trap with this, trying to prioritize selected channel... https://play.golang.org/p/VOrPwx7HC_ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email

[go-nuts] Re: How to print an AST without formatting?

2020-01-09 Thread Julio Guerra
I saw `go tool cover` does it, but I don't see anything else but a simple call to printer.Fprint(w, f.fset, f.astFile) at https://github.com/golang/tools/blob/master/cmd/cover/cover.go#L384 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To uns

Re: [go-nuts] Getting a function's linked address?

2020-01-15 Thread Julio Guerra
For the record, I could do what I needed using the `//go:linkname` directive. My instrumentation tool injects statements that need features from another package that I cannot import. So I forward declare functions using a given link name that is implemented in another package - similarly to wha