本文整理汇总了Golang中debug/proc.Word函数的典型用法代码### 示例。如果您正苦于以下问题:Golang Word函数的具体用法?Golang Word怎么用?Golang Word使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。

在下文中一共展示了Word函数的19个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: String

func (f *Frame) String() string {
    res := f.fn.Name
    if f.pc > proc.Word(f.fn.Value) {
        res += fmt.Sprintf("+%#x", f.pc-proc.Word(f.fn.Entry))
    }
    return res + fmt.Sprintf(" %s:%d", f.path, f.line)
}

开发者ID:rapgamer,项目名称:golang-china,代码行数:7,代码来源:frame.go

示例2: aOuter

func (f *Frame) aOuter(a aborter) *Frame {
    // Is there a cached outer frame
    if f.outer != nil {
        return f.outer
    }

    p := f.stk.r.p

    sp := f.fp
    if f.fn == p.sys.newproc && f.fn == p.sys.deferproc {
        // TODO(rsc) The compiler inserts two push/pop's
        // around calls to go and defer.  Russ says this
        // should get fixed in the compiler, but we account
        // for it for now.
        sp += proc.Word(2 * p.PtrSize())
    }

    pc := p.peekUintptr(a, f.fp-proc.Word(p.PtrSize()))
    if pc < 0x1000 {
        return nil
    }

    // TODO(austin) Register this frame for shoot-down.

    f.outer = prepareFrame(a, pc, sp, f.stk, f)
    return f.outer
}

开发者ID:rapgamer,项目名称:golang-china,代码行数:27,代码来源:frame.go

示例3: NewProcess

// NewProcess constructs a new remote process around a traced
// process, an architecture, and a symbol table.
func NewProcess(tproc proc.Process, arch Arch, syms *gosym.Table) (*Process, os.Error) {
    p := &Process{
        Arch:                arch,
        proc:                tproc,
        syms:                syms,
        types:               make(map[proc.Word]*remoteType),
        breakpointHooks:     make(map[proc.Word]*breakpointHook),
        goroutineCreateHook: new(goroutineCreateHook),
        goroutineExitHook:   new(goroutineExitHook),
        goroutines:          make(map[proc.Word]*Goroutine),
    }

    // Fill in remote runtime
    p.bootstrap()

    switch {
    case p.sys.allg.addr().base == 0:
        return nil, FormatError("failed to find runtime symbol 'allg'")
    case p.sys.g0.addr().base == 0:
        return nil, FormatError("failed to find runtime symbol 'g0'")
    case p.sys.newprocreadylocked == nil:
        return nil, FormatError("failed to find runtime symbol 'newprocreadylocked'")
    case p.sys.goexit == nil:
        return nil, FormatError("failed to find runtime symbol 'sys.goexit'")
    }

    // Get current goroutines
    p.goroutines[p.sys.g0.addr().base] = &Goroutine{p.sys.g0, nil, false}
    err := try(func(a aborter) {
        g := p.sys.allg.aGet(a)
        for g != nil {
            gs := g.(remoteStruct)
            fmt.Printf("*** Found goroutine at %#x\n", gs.addr().base)
            p.goroutines[gs.addr().base] = &Goroutine{gs, nil, false}
            g = gs.field(p.f.G.Alllink).(remotePtr).aGet(a)
        }
    })
    if err != nil {
        return nil, err
    }

    // Create internal breakpoints to catch new and exited goroutines
    p.OnBreakpoint(proc.Word(p.sys.newprocreadylocked.Entry)).(*breakpointHook).addHandler(readylockedBP, true)
    p.OnBreakpoint(proc.Word(p.sys.goexit.Entry)).(*breakpointHook).addHandler(goexitBP, true)

    // Select current frames
    for _, g := range p.goroutines {
        g.resetFrame()
    }

    p.selectSomeGoroutine()

    return p, nil
}

开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:56,代码来源:process.go

示例4: bootstrap

// bootstrap constructs the runtime structure of a remote process.
func (p *Process) bootstrap() {
    // Manually construct runtime types
    p.runtime.String = newManualType(eval.TypeOfNative(rt1String{}), p.Arch)
    p.runtime.Slice = newManualType(eval.TypeOfNative(rt1Slice{}), p.Arch)
    p.runtime.Eface = newManualType(eval.TypeOfNative(rt1Eface{}), p.Arch)

    p.runtime.Type = newManualType(eval.TypeOfNative(rt1Type{}), p.Arch)
    p.runtime.CommonType = newManualType(eval.TypeOfNative(rt1CommonType{}), p.Arch)
    p.runtime.UncommonType = newManualType(eval.TypeOfNative(rt1UncommonType{}), p.Arch)
    p.runtime.StructField = newManualType(eval.TypeOfNative(rt1StructField{}), p.Arch)
    p.runtime.StructType = newManualType(eval.TypeOfNative(rt1StructType{}), p.Arch)
    p.runtime.PtrType = newManualType(eval.TypeOfNative(rt1PtrType{}), p.Arch)
    p.runtime.ArrayType = newManualType(eval.TypeOfNative(rt1ArrayType{}), p.Arch)
    p.runtime.SliceType = newManualType(eval.TypeOfNative(rt1SliceType{}), p.Arch)

    p.runtime.Stktop = newManualType(eval.TypeOfNative(rt1Stktop{}), p.Arch)
    p.runtime.Gobuf = newManualType(eval.TypeOfNative(rt1Gobuf{}), p.Arch)
    p.runtime.G = newManualType(eval.TypeOfNative(rt1G{}), p.Arch)

    // Get addresses of type.*runtime.XType for discrimination.
    rtv := reflect.Indirect(reflect.NewValue(&p.runtime)).(*reflect.StructValue)
    rtvt := rtv.Type().(*reflect.StructType)
    for i := 0; i < rtv.NumField(); i++ {
        n := rtvt.Field(i).Name
        if n[0] != 'P' || n[1] < 'A' || n[1] > 'Z' {
            continue
        }
        sym := p.syms.LookupSym("type.*runtime." + n[1:])
        if sym == nil {
            continue
        }
        rtv.Field(i).(*reflect.UintValue).Set(sym.Value)
    }

    // Get runtime field indexes
    fillRuntimeIndexes(&p.runtime, &p.f)

    // Fill G status
    p.runtime.runtimeGStatus = rt1GStatus

    // Get globals
    p.sys.lessstack = p.syms.LookupFunc("sys.lessstack")
    p.sys.goexit = p.syms.LookupFunc("goexit")
    p.sys.newproc = p.syms.LookupFunc("sys.newproc")
    p.sys.deferproc = p.syms.LookupFunc("sys.deferproc")
    p.sys.newprocreadylocked = p.syms.LookupFunc("newprocreadylocked")
    if allg := p.syms.LookupSym("allg"); allg != nil {
        p.sys.allg = remotePtr{remote{proc.Word(allg.Value), p}, p.runtime.G}
    }
    if g0 := p.syms.LookupSym("g0"); g0 != nil {
        p.sys.g0 = p.runtime.G.mk(remote{proc.Word(g0.Value), p}).(remoteStruct)
    }
}

开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:54,代码来源:process.go

示例5: aNewFrame

func aNewFrame(a aborter, g remoteStruct) *Frame {
    p := g.r.p
    var pc, sp proc.Word

    // Is this G alive?
    switch g.field(p.f.G.Status).(remoteInt).aGet(a) {
    case p.runtime.Gidle, p.runtime.Gmoribund, p.runtime.Gdead:
        return nil
    }

    // Find the OS thread for this G

    // TODO(austin) Ideally, we could look at the G's state and
    // figure out if it's on an OS thread or not.  However, this
    // is difficult because the state isn't updated atomically
    // with scheduling changes.
    for _, t := range p.proc.Threads() {
        regs, err := t.Regs()
        if err != nil {
            // TODO(austin) What to do?
            continue
        }
        thisg := p.G(regs)
        if thisg == g.addr().base {
            // Found this G's OS thread
            pc = regs.PC()
            sp = regs.SP()

            // If this thread crashed, try to recover it
            if pc == 0 {
                pc = p.peekUintptr(a, pc)
                sp += 8
            }

            break
        }
    }

    if pc == 0 && sp == 0 {
        // G is not mapped to an OS thread.  Use the
        // scheduler's stored PC and SP.
        sched := g.field(p.f.G.Sched).(remoteStruct)
        pc = proc.Word(sched.field(p.f.Gobuf.Pc).(remoteUint).aGet(a))
        sp = proc.Word(sched.field(p.f.Gobuf.Sp).(remoteUint).aGet(a))
    }

    // Get Stktop
    stk := g.field(p.f.G.Stackbase).(remotePtr).aGet(a).(remoteStruct)

    return prepareFrame(a, pc, sp, stk, nil)
}

开发者ID:rapgamer,项目名称:golang-china,代码行数:51,代码来源:frame.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng