From 0e11797f8b9d7798fc0965b8b7f1161adfe69c15 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Thu, 14 Aug 2014 17:59:55 -0500 Subject: [PATCH] Reduce nesting --- proctl/proctl_linux_amd64.go | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/proctl/proctl_linux_amd64.go b/proctl/proctl_linux_amd64.go index 07aae35f..2a45d9c9 100644 --- a/proctl/proctl_linux_amd64.go +++ b/proctl/proctl_linux_amd64.go @@ -147,36 +147,36 @@ func (dbp *DebuggedProcess) EvalSymbol(name string) (*Variable, error) { return nil, err } - if entry.Tag == dwarf.TagVariable { - n, ok := entry.Val(dwarf.AttrName).(string) - if !ok { - continue - } - - if n == name { - offset, ok := entry.Val(dwarf.AttrType).(dwarf.Offset) - if !ok { - continue - } - - t, err := data.Type(offset) - if err != nil { - return nil, err - } - - instructions, ok := entry.Val(dwarf.AttrLocation).([]byte) - if !ok { - continue - } - - val, err := dbp.extractValue(instructions, t) - if err != nil { - return nil, err - } - - return &Variable{Name: n, Type: t.String(), Value: val}, nil - } + if entry.Tag != dwarf.TagVariable { + continue } + + n, ok := entry.Val(dwarf.AttrName).(string) + if !ok || n != name { + continue + } + + offset, ok := entry.Val(dwarf.AttrType).(dwarf.Offset) + if !ok { + continue + } + + t, err := data.Type(offset) + if err != nil { + return nil, err + } + + instructions, ok := entry.Val(dwarf.AttrLocation).([]byte) + if !ok { + continue + } + + val, err := dbp.extractValue(instructions, t) + if err != nil { + return nil, err + } + + return &Variable{Name: n, Type: t.String(), Value: val}, nil } return nil, fmt.Errorf("could not find symbol value for %s", name)