diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-02-26 13:33:11 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-02-26 13:33:11 +0100 |
| commit | 41f6f2579b51e89b33bff9f02830510d2b74d7c3 (patch) | |
| tree | c7a4192ea5e7f779c440ac2da641204bca052e9f /prog/analysis.go | |
| parent | 17ad67b472fbd32c875480eaedf510f647b2807f (diff) | |
prog: fix address analysis
Even during mutation of a call we want to analyze whole program
to find all used addresses (rather then stop on the selected call).
Also update address during ANY mutation if size has increased.
Diffstat (limited to 'prog/analysis.go')
| -rw-r--r-- | prog/analysis.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/prog/analysis.go b/prog/analysis.go index 3454aed8d..626af7446 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -25,11 +25,12 @@ type state struct { // analyze analyzes the program p up to but not including call c. func analyze(ct *ChoiceTable, p *Prog, c *Call) *state { s := newState(p.Target, ct) + resources := true for _, c1 := range p.Calls { if c1 == c { - break + resources = false } - s.analyze(c1) + s.analyzeImpl(c1, resources) } return s } @@ -48,6 +49,10 @@ func newState(target *Target, ct *ChoiceTable) *state { } func (s *state) analyze(c *Call) { + s.analyzeImpl(c, true) +} + +func (s *state) analyzeImpl(c *Call, resources bool) { ForeachArg(c, func(arg Arg, _ *ArgCtx) { switch a := arg.(type) { case *PointerArg: @@ -61,7 +66,7 @@ func (s *state) analyze(c *Call) { } switch typ := arg.Type().(type) { case *ResourceType: - if typ.Dir() != DirIn { + if resources && typ.Dir() != DirIn { s.resources[typ.Desc.Name] = append(s.resources[typ.Desc.Name], arg) // TODO: negative PIDs and add them as well (that's process groups). } |
