summaryrefslogtreecommitdiff
path: root/usr/austin/eval/bridge.go
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2009-09-18 09:11:19 -0700
committerAustin Clements <aclements@csail.mit.edu>2009-09-18 09:11:19 -0700
commitb00ece82d2ab5222f08207be94734884c846569c (patch)
tree8a33c02cf089dbf5dd542fcd2c22ae667b97416b /usr/austin/eval/bridge.go
parenta74787c2d1939be52dfc1d30c9dafbf2626f76ae (diff)
downloadgolang-b00ece82d2ab5222f08207be94734884c846569c.tar.gz
Rudimentary command shell for Ogle. Hack to prevent linker
from inlining newprocreadylocked. Fix type bridge's handling of basic types. Include interpreter's Thread in bridged native function calls. ; load . "6.out" Started 6.out ; BpSet("main·merge") ; ContWait() breakpoint at 0x400800 => 400800 main·merge /home/austin/src-go1/usr/austin/ptrace/test/sort.go:19 ; bt => 400800 main·merge /home/austin/src-go1/usr/austin/ptrace/test/sort.go:19 400b6a main·mergeSort+0x1be /home/austin/src-go1/usr/austin/ptrace/test/sort.go:34 448313 goexit /home/austin/src-go1/src/pkg/runtime/proc.c:133 ; main.merge.a {1} ; load . "pid:25753" Attached to 25753 ; bt => 479ddf syscall·Syscall+0x24 /home/austin/src-go1/src/pkg/syscall/asm_linux_amd64.s:24 47c011 syscall·Read+0x5d /home/austin/src-go1/src/pkg/syscall/zsyscall_linux_amd64.go:368 4119e5 os·*File·Read+0x5f /home/austin/src-go1/src/pkg/os/file.go:122 427bf3 bufio·*Reader·fill+0x116 /home/austin/src-go1/src/pkg/bufio/bufio.go:105 428361 bufio·*Reader·ReadSlice+0x195 /home/austin/src-go1/src/pkg/bufio/bufio.go:244 40204a ogle·Main+0x94 /home/austin/src-go1/usr/austin/ogle/cmd.go:226 40080f main·main+0xf /home/austin/src-go1/usr/austin/ogle/main.go:6 41c4b8 mainstart+0xf /home/austin/src-go1/src/pkg/runtime/amd64/asm.s:55 41531f goexit /home/austin/src-go1/src/pkg/runtime/proc.c:133 R=rsc APPROVED=rsc DELTA=433 (420 added, 2 deleted, 11 changed) OCL=34410 CL=34782
Diffstat (limited to 'usr/austin/eval/bridge.go')
-rw-r--r--usr/austin/eval/bridge.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr/austin/eval/bridge.go b/usr/austin/eval/bridge.go
index 41674860e..da2dd52a9 100644
--- a/usr/austin/eval/bridge.go
+++ b/usr/austin/eval/bridge.go
@@ -117,8 +117,10 @@ func TypeFromNative(t reflect.Type) Type {
}
if nt != nil {
- nt.Complete(et);
- et = nt;
+ if _, ok := et.(*NamedType); !ok {
+ nt.Complete(et);
+ et = nt;
+ }
}
nativeTypes[et] = t;
@@ -137,7 +139,7 @@ func TypeOfNative(v interface {}) Type {
*/
type nativeFunc struct {
- fn func([]Value, []Value);
+ fn func(*Thread, []Value, []Value);
in, out int;
}
@@ -147,14 +149,14 @@ func (f *nativeFunc) NewFrame() *Frame {
}
func (f *nativeFunc) Call(t *Thread) {
- f.fn(t.f.Vars[0:f.in], t.f.Vars[f.in:f.in+f.out]);
+ f.fn(t, t.f.Vars[0:f.in], t.f.Vars[f.in:f.in+f.out]);
}
// FuncFromNative creates an interpreter function from a native
// function that takes its in and out arguments as slices of
// interpreter Value's. While somewhat inconvenient, this avoids
// value marshalling.
-func FuncFromNative(fn func([]Value, []Value), t *FuncType) FuncValue {
+func FuncFromNative(fn func(*Thread, []Value, []Value), t *FuncType) FuncValue {
return &funcV{&nativeFunc{fn, len(t.In), len(t.Out)}};
}
@@ -162,7 +164,7 @@ func FuncFromNative(fn func([]Value, []Value), t *FuncType) FuncValue {
// function type from a function pointer using reflection. Typically,
// the type will be given as a nil pointer to a function with the
// desired signature.
-func FuncFromNativeTyped(fn func([]Value, []Value), t interface{}) (*FuncType, FuncValue) {
+func FuncFromNativeTyped(fn func(*Thread, []Value, []Value), t interface{}) (*FuncType, FuncValue) {
ft := TypeOfNative(t).(*FuncType);
return ft, FuncFromNative(fn, ft);
}