Comment cleanup. Added info vars reference to docs

This commit is contained in:
epipho
2015-02-03 23:20:25 -05:00
committed by Derek Parker
parent c7fe4e3e88
commit 46b5348455
4 changed files with 44 additions and 43 deletions

View File

@ -361,6 +361,38 @@ func (thread *ThreadContext) EvalSymbol(name string) (*Variable, error) {
return nil, fmt.Errorf("could not find symbol value for %s", name)
}
// LocalVariables returns all local variables from the current function scope.
func (thread *ThreadContext) LocalVariables() ([]*Variable, error) {
return thread.variablesByTag(dwarf.TagVariable)
}
// FunctionArguments returns the name, value, and type of all current function arguments.
func (thread *ThreadContext) FunctionArguments() ([]*Variable, error) {
return thread.variablesByTag(dwarf.TagFormalParameter)
}
// PackageVariables returns the name, value, and type of all package variables in the application.
func (thread *ThreadContext) PackageVariables() ([]*Variable, error) {
reader := thread.Process.DwarfReader()
vars := make([]*Variable, 0)
for entry, err := reader.NextPackageVariable(); entry != nil; entry, err = reader.NextPackageVariable() {
if err != nil {
return nil, err
}
// Ignore errors trying to extract values
val, err := thread.extractVariableFromEntry(entry)
if err != nil {
continue
}
vars = append(vars, val)
}
return vars, nil
}
func findDwarfEntry(name string, reader *dwarf.Reader, member bool) (*dwarf.Entry, error) {
depth := 1
for entry, err := reader.Next(); entry != nil; entry, err = reader.Next() {
@ -924,38 +956,6 @@ func (thread *ThreadContext) variablesByTag(tag dwarf.Tag) ([]*Variable, error)
return vars, nil
}
// LocalVariables returns all local variables from the current function scope
func (thread *ThreadContext) LocalVariables() ([]*Variable, error) {
return thread.variablesByTag(dwarf.TagVariable)
}
// FunctionArguments returns the name, value, and type of all current function arguments
func (thread *ThreadContext) FunctionArguments() ([]*Variable, error) {
return thread.variablesByTag(dwarf.TagFormalParameter)
}
// PackageVariables returns the name, value, and type of all package variables in the application
func (thread *ThreadContext) PackageVariables() ([]*Variable, error) {
reader := thread.Process.DwarfReader()
vars := make([]*Variable, 0)
for entry, err := reader.NextPackageVariable(); entry != nil; entry, err = reader.NextPackageVariable() {
if err != nil {
return nil, err
}
// Ignore errors trying to extract values
val, err := thread.extractVariableFromEntry(entry)
if err != nil {
continue
}
vars = append(vars, val)
}
return vars, nil
}
// Sets the length of a slice.
func setSliceLength(ptr unsafe.Pointer, l int) {
lptr := (*int)(unsafe.Pointer(uintptr(ptr) + ptrsize))