summaryrefslogtreecommitdiff
path: root/src/pkg/exp/ogle/event.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/exp/ogle/event.go')
-rw-r--r--src/pkg/exp/ogle/event.go136
1 files changed, 68 insertions, 68 deletions
diff --git a/src/pkg/exp/ogle/event.go b/src/pkg/exp/ogle/event.go
index 18f547915..d7092ded3 100644
--- a/src/pkg/exp/ogle/event.go
+++ b/src/pkg/exp/ogle/event.go
@@ -5,9 +5,9 @@
package ogle
import (
- "debug/proc";
- "fmt";
- "os";
+ "debug/proc"
+ "fmt"
+ "os"
)
/*
@@ -32,19 +32,19 @@ type EventHandler func(e Event) (EventAction, os.Error)
type EventAction int
const (
- EARemoveSelf EventAction = 0x100;
- EADefault EventAction = iota;
- EAStop;
- EAContinue;
+ EARemoveSelf EventAction = 0x100
+ EADefault EventAction = iota
+ EAStop
+ EAContinue
)
// A EventHook allows event handlers to be added and removed.
type EventHook interface {
- AddHandler(EventHandler);
- RemoveHandler(EventHandler);
- NumHandler() int;
- handle(e Event) (EventAction, os.Error);
- String() string;
+ AddHandler(EventHandler)
+ RemoveHandler(EventHandler)
+ NumHandler() int
+ handle(e Event) (EventAction, os.Error)
+ String() string
}
// EventHook is almost, but not quite, suitable for user-defined
@@ -53,26 +53,26 @@ type EventHook interface {
// provide a public interface for posting events to hooks.
type Event interface {
- Process() *Process;
- Goroutine() *Goroutine;
- String() string;
+ Process() *Process
+ Goroutine() *Goroutine
+ String() string
}
type commonHook struct {
// Head of handler chain
- head *handler;
+ head *handler
// Number of non-internal handlers
- len int;
+ len int
}
type handler struct {
- eh EventHandler;
+ eh EventHandler
// True if this handler must be run before user-defined
// handlers in order to ensure correctness.
- internal bool;
+ internal bool
// True if this handler has been removed from the chain.
- removed bool;
- next *handler;
+ removed bool
+ next *handler
}
func (h *commonHook) AddHandler(eh EventHandler) {
@@ -81,56 +81,56 @@ func (h *commonHook) AddHandler(eh EventHandler) {
func (h *commonHook) addHandler(eh EventHandler, internal bool) {
// Ensure uniqueness of handlers
- h.RemoveHandler(eh);
+ h.RemoveHandler(eh)
if !internal {
h.len++
}
// Add internal handlers to the beginning
if internal || h.head == nil {
- h.head = &handler{eh, internal, false, h.head};
- return;
+ h.head = &handler{eh, internal, false, h.head}
+ return
}
// Add handler after internal handlers
// TODO(austin) This should probably go on the end instead
- prev := h.head;
+ prev := h.head
for prev.next != nil && prev.internal {
prev = prev.next
}
- prev.next = &handler{eh, internal, false, prev.next};
+ prev.next = &handler{eh, internal, false, prev.next}
}
func (h *commonHook) RemoveHandler(eh EventHandler) {
- plink := &h.head;
+ plink := &h.head
for l := *plink; l != nil; plink, l = &l.next, l.next {
if l.eh == eh {
if !l.internal {
h.len--
}
- l.removed = true;
- *plink = l.next;
- break;
+ l.removed = true
+ *plink = l.next
+ break
}
}
}
-func (h *commonHook) NumHandler() int { return h.len }
+func (h *commonHook) NumHandler() int { return h.len }
func (h *commonHook) handle(e Event) (EventAction, os.Error) {
- action := EADefault;
- plink := &h.head;
+ action := EADefault
+ plink := &h.head
for l := *plink; l != nil; plink, l = &l.next, l.next {
if l.removed {
continue
}
- a, err := l.eh(e);
+ a, err := l.eh(e)
if a&EARemoveSelf == EARemoveSelf {
if !l.internal {
h.len--
}
- l.removed = true;
- *plink = l.next;
- a &^= EARemoveSelf;
+ l.removed = true
+ *plink = l.next
+ a &^= EARemoveSelf
}
if err != nil {
return EAStop, err
@@ -139,19 +139,19 @@ func (h *commonHook) handle(e Event) (EventAction, os.Error) {
action = a
}
}
- return action, nil;
+ return action, nil
}
type commonEvent struct {
// The process of this event
- p *Process;
+ p *Process
// The goroutine of this event.
- t *Goroutine;
+ t *Goroutine
}
-func (e *commonEvent) Process() *Process { return e.p }
+func (e *commonEvent) Process() *Process { return e.p }
-func (e *commonEvent) Goroutine() *Goroutine { return e.t }
+func (e *commonEvent) Goroutine() *Goroutine { return e.t }
/*
* Standard event handlers
@@ -161,8 +161,8 @@ func (e *commonEvent) Goroutine() *Goroutine { return e.t }
// occur. It will not cause the process to stop.
func EventPrint(ev Event) (EventAction, os.Error) {
// TODO(austin) Include process name here?
- fmt.Fprintf(os.Stderr, "*** %v\n", ev.String());
- return EADefault, nil;
+ fmt.Fprintf(os.Stderr, "*** %v\n", ev.String())
+ return EADefault, nil
}
// EventStop is a standard event handler that causes the process to stop.
@@ -175,18 +175,18 @@ func EventStop(ev Event) (EventAction, os.Error) {
*/
type breakpointHook struct {
- commonHook;
- p *Process;
- pc proc.Word;
+ commonHook
+ p *Process
+ pc proc.Word
}
// A Breakpoint event occurs when a process reaches a particular
// program counter. When this event is handled, the current goroutine
// will be the goroutine that reached the program counter.
type Breakpoint struct {
- commonEvent;
- osThread proc.Thread;
- pc proc.Word;
+ commonEvent
+ osThread proc.Thread
+ pc proc.Word
}
func (h *breakpointHook) AddHandler(eh EventHandler) {
@@ -200,20 +200,20 @@ func (h *breakpointHook) addHandler(eh EventHandler, internal bool) {
if cur, ok := h.p.breakpointHooks[h.pc]; ok {
h = cur
}
- oldhead := h.head;
- h.commonHook.addHandler(eh, internal);
+ oldhead := h.head
+ h.commonHook.addHandler(eh, internal)
if oldhead == nil && h.head != nil {
- h.p.proc.AddBreakpoint(h.pc);
- h.p.breakpointHooks[h.pc] = h;
+ h.p.proc.AddBreakpoint(h.pc)
+ h.p.breakpointHooks[h.pc] = h
}
}
func (h *breakpointHook) RemoveHandler(eh EventHandler) {
- oldhead := h.head;
- h.commonHook.RemoveHandler(eh);
+ oldhead := h.head
+ h.commonHook.RemoveHandler(eh)
if oldhead != nil && h.head == nil {
- h.p.proc.RemoveBreakpoint(h.pc);
- h.p.breakpointHooks[h.pc] = nil, false;
+ h.p.proc.RemoveBreakpoint(h.pc)
+ h.p.breakpointHooks[h.pc] = nil, false
}
}
@@ -223,7 +223,7 @@ func (h *breakpointHook) String() string {
return fmt.Sprintf("breakpoint at %#x", h.pc)
}
-func (b *Breakpoint) PC() proc.Word { return b.pc }
+func (b *Breakpoint) PC() proc.Word { return b.pc }
func (b *Breakpoint) String() string {
// TODO(austin) Include process name and goroutine
@@ -236,40 +236,40 @@ func (b *Breakpoint) String() string {
*/
type goroutineCreateHook struct {
- commonHook;
+ commonHook
}
-func (h *goroutineCreateHook) String() string { return "goroutine create" }
+func (h *goroutineCreateHook) String() string { return "goroutine create" }
// A GoroutineCreate event occurs when a process creates a new
// goroutine. When this event is handled, the current goroutine will
// be the newly created goroutine.
type GoroutineCreate struct {
- commonEvent;
- parent *Goroutine;
+ commonEvent
+ parent *Goroutine
}
// Parent returns the goroutine that created this goroutine. May be
// nil if this event is the creation of the first goroutine.
-func (e *GoroutineCreate) Parent() *Goroutine { return e.parent }
+func (e *GoroutineCreate) Parent() *Goroutine { return e.parent }
func (e *GoroutineCreate) String() string {
// TODO(austin) Include process name
if e.parent == nil {
return fmt.Sprintf("%v created", e.t)
}
- return fmt.Sprintf("%v created by %v", e.t, e.parent);
+ return fmt.Sprintf("%v created by %v", e.t, e.parent)
}
type goroutineExitHook struct {
- commonHook;
+ commonHook
}
-func (h *goroutineExitHook) String() string { return "goroutine exit" }
+func (h *goroutineExitHook) String() string { return "goroutine exit" }
// A GoroutineExit event occurs when a Go goroutine exits.
type GoroutineExit struct {
- commonEvent;
+ commonEvent
}
func (e *GoroutineExit) String() string {