提交 29a058ee 编写于 作者: A Alessandro Arzilli 提交者: Derek Parker

proc: flag variables that have a 'fake' address (#1619)

Add variables flag to mark variables that are allocated on a register
(and have no address) and variables that we read as result of a
function call (and are allocated on a stack that no longer exists when
we show them to the user).
上级 158fb7bf
...@@ -746,6 +746,9 @@ func funcCallStep(callScope *EvalScope, fncall *functionCallState) bool { ...@@ -746,6 +746,9 @@ func funcCallStep(callScope *EvalScope, fncall *functionCallState) bool {
} }
loadValues(fncall.retvars, callScope.callCtx.retLoadCfg) loadValues(fncall.retvars, callScope.callCtx.retLoadCfg)
for _, v := range fncall.retvars {
v.Flags |= VariableFakeAddress
}
case debugCallAXReadPanic: case debugCallAXReadPanic:
// read panic value from stack // read panic value from stack
...@@ -755,11 +758,6 @@ func funcCallStep(callScope *EvalScope, fncall *functionCallState) bool { ...@@ -755,11 +758,6 @@ func funcCallStep(callScope *EvalScope, fncall *functionCallState) bool {
break break
} }
fncall.panicvar.Name = "~panic" fncall.panicvar.Name = "~panic"
fncall.panicvar.loadValue(callScope.callCtx.retLoadCfg)
if fncall.panicvar.Unreadable != nil {
fncall.err = fmt.Errorf("could not get panic: %v", fncall.panicvar.Unreadable)
break
}
default: default:
// Got an unknown AX value, this is probably bad but the safest thing // Got an unknown AX value, this is probably bad but the safest thing
...@@ -785,6 +783,7 @@ func readTopstackVariable(thread Thread, regs Registers, typename string, loadCf ...@@ -785,6 +783,7 @@ func readTopstackVariable(thread Thread, regs Registers, typename string, loadCf
if v.Unreadable != nil { if v.Unreadable != nil {
return nil, v.Unreadable return nil, v.Unreadable
} }
v.Flags |= VariableFakeAddress
return v, nil return v, nil
} }
......
...@@ -71,6 +71,12 @@ const ( ...@@ -71,6 +71,12 @@ const (
VariableArgument VariableArgument
// VariableReturnArgument means this variable is a function return value // VariableReturnArgument means this variable is a function return value
VariableReturnArgument VariableReturnArgument
// VariableFakeAddress means the address of this variable is either fake
// (i.e. the variable is partially or completely stored in a CPU register
// and doesn't have a real address) or possibly no longer availabe (because
// the variable is the return value of a function call and allocated on a
// frame that no longer exists)
VariableFakeAddress
) )
// Variable represents a variable. It contains the address, name, // Variable represents a variable. It contains the address, name,
...@@ -1051,6 +1057,9 @@ func (scope *EvalScope) extractVarInfoFromEntry(varEntry *dwarf.Entry) (*Variabl ...@@ -1051,6 +1057,9 @@ func (scope *EvalScope) extractVarInfoFromEntry(varEntry *dwarf.Entry) (*Variabl
} }
v := scope.newVariable(n, uintptr(addr), t, mem) v := scope.newVariable(n, uintptr(addr), t, mem)
if pieces != nil {
v.Flags |= VariableFakeAddress
}
v.LocationExpr = descr v.LocationExpr = descr
v.DeclLine, _ = entry.Val(dwarf.AttrDeclLine).(int64) v.DeclLine, _ = entry.Val(dwarf.AttrDeclLine).(int64)
if err != nil { if err != nil {
......
...@@ -214,6 +214,13 @@ const ( ...@@ -214,6 +214,13 @@ const (
// VariableReturnArgument means this variable is a function return value // VariableReturnArgument means this variable is a function return value
VariableReturnArgument VariableReturnArgument
// VariableFakeAddress means the address of this variable is either fake
// (i.e. the variable is partially or completely stored in a CPU register
// and doesn't have a real address) or possibly no longer availabe (because
// the variable is the return value of a function call and allocated on a
// frame that no longer exists)
VariableFakeAddress
) )
// Variable describes a variable. // Variable describes a variable.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册