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

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

示例1: SeekToType

// SeekToType moves the reader to the type specified by the entry,
// optionally resolving typedefs and pointer types. If the reader is set
// to a struct type the NextMemberVariable call can be used to walk all member data.
func (reader *Reader) SeekToType(entry *dwarf.Entry, resolveTypedefs bool, resolvePointerTypes bool) (*dwarf.Entry, error) {
    offset, ok := entry.Val(dwarf.AttrType).(dwarf.Offset)
    if !ok {
        return nil, fmt.Errorf("entry does not have a type attribute")
    }

    // Seek to the first type offset
    reader.Seek(offset)

    // Walk the types to the base
    for typeEntry, err := reader.Next(); typeEntry != nil; typeEntry, err = reader.Next() {
        if err != nil {
            return nil, err
        }

        if typeEntry.Tag == dwarf.TagTypedef && !resolveTypedefs {
            return typeEntry, nil
        }

        if typeEntry.Tag == dwarf.TagPointerType && !resolvePointerTypes {
            return typeEntry, nil
        }

        offset, ok = typeEntry.Val(dwarf.AttrType).(dwarf.Offset)
        if !ok {
            return typeEntry, nil
        }

        reader.Seek(offset)
    }

    return nil, fmt.Errorf("no type entry found")
}

开发者ID:no2key,项目名称:delve,代码行数:36,代码来源:reader.go

示例2: toContentMethod

func (d *DWARFHelper) toContentMethod(e *dwarf.Entry) (m content.Method, err error) {
    if v, ok := e.Val(dwarf.AttrName).(string); ok {
        m.Name.Relative = v
    }
    if v, ok := e.Val(dwarf.AttrType).(dwarf.Offset); ok {
        if t, err := d.GetType(v); err != nil {
            return m, err
        } else {
            m.Returns = append(m.Returns, content.Variable{Type: t})
        }
    } else {
        m.Returns = append(m.Returns, content.Variable{Type: content.Type{Name: content.FullyQualifiedName{Relative: "void"}}})
    }
    m.Flags = d.Flags(e)
    if !e.Children {
        return
    }
    r := d.df.Reader()
    r.Seek(e.Offset)
    for {
        e, err := r.Next()
        if err != nil {
            return m, err
        } else if e == nil || e.Tag == 0 {
            break
        }
        if e.Tag != dwarf.TagFormalParameter {
            continue
        }
        var p content.Variable
        if v, ok := e.Val(dwarf.AttrType).(dwarf.Offset); ok {
            if t, err := d.GetType(v); err != nil {
                return m, err
            } else {
                p.Type = t
            }
        }
        if v, ok := e.Val(dwarf.AttrName).(string); ok {
            p.Name.Relative = v
        }
        if v, ok := e.Val(dwarf.AttrArtificial).(bool); ok && v {
            if p.Type.Flags&content.FLAG_TYPE_MASK != content.FLAG_TYPE_POINTER {
                m.Parameters = append(m.Parameters, p)
                continue
            }
            // C++ "this" pointer
            t := p.Type.Specialization[0]
            if t.Flags&content.FLAG_CONST != 0 {
                m.Flags |= content.FLAG_CONST
            }
            //m.Name.Absolute = t.Name.Relative + "::" + m.Name.Relative
        } else {
            m.Parameters = append(m.Parameters, p)
        }
    }
    return
}

开发者ID:NeoTse,项目名称:completion,代码行数:57,代码来源:dwarf.go

示例3: processCompileUnit

//============================================================================
//      processCompileUnit : Process a compile unit.
//----------------------------------------------------------------------------
func processCompileUnit(theReader *dwarf.Reader, depth int, theEntry *dwarf.Entry) {

    // Process the entry
    gCurrentFile = theEntry.Val(dwarf.AttrName).(string)

    if theEntry.Children {
        processChildren(theReader, depth+1, false)
    }

    gCurrentFile = ""

}

开发者ID:refnum,项目名称:gatos,代码行数:15,代码来源:gatos.go

示例4: Flags

func (d *DWARFHelper) Flags(e *dwarf.Entry) (ret content.Flags) {
    if v, ok := e.Val(dwarf.AttrAccessibility).(int64); ok {
        switch v {
        case 1:
            ret |= content.FLAG_ACC_PUBLIC
        case 2:
            ret |= content.FLAG_ACC_PROTECTED
        case 3:
            ret |= content.FLAG_ACC_PRIVATE
        }
    }
    return
}

开发者ID:berkus,项目名称:completion,代码行数:13,代码来源:dwarf.go

示例5: processSubprogram

//============================================================================
//      processSubprogram : Process a subprogram.
//----------------------------------------------------------------------------
func processSubprogram(theReader *dwarf.Reader, depth int, theEntry *dwarf.Entry) {

    var lowAddr uint64
    var highAddr uint64

    // Get the state we need
    lowVal := theEntry.Val(dwarf.AttrLowpc)
    highVal := theEntry.Val(dwarf.AttrHighpc)

    if lowVal != nil && highVal != nil {
        lowAddr = lowVal.(uint64)
        highAddr = highVal.(uint64)
    }

    // Check for a match
    if gTargetAddress >= lowAddr && gTargetAddress < highAddr {
        name := theEntry.Val(dwarf.AttrName)
        line := theEntry.Val(dwarf.AttrDeclLine)

        fmt.Printf("%v (%v:%v)\n", name, path.Base(gCurrentFile), line)
    }

    // Process the entry
    if theEntry.Children {
        processChildren(theReader, depth+1, false)
    }
}

开发者ID:refnum,项目名称:gatos,代码行数:30,代码来源:gatos.go

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