diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-09-14 19:25:01 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-09-15 16:02:37 +0200 |
| commit | 52a33fd516102a98d3753bf69417235b655a68dc (patch) | |
| tree | 351ab73db934d3b4e4babbe27e8801c659f2631b /prog/analysis.go | |
| parent | 25f4fe0662f7f3b390d16b2e786f2ba0aa0293f1 (diff) | |
prog: remove default target and all global state
Now each prog function accepts the desired target explicitly.
No global, implicit state involved.
This is much cleaner and allows cross-OS/arch testing, etc.
Diffstat (limited to 'prog/analysis.go')
| -rw-r--r-- | prog/analysis.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/prog/analysis.go b/prog/analysis.go index 009a15a21..80a127108 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -17,6 +17,7 @@ const ( ) type state struct { + target *Target ct *ChoiceTable files map[string]bool resources map[string][]Arg @@ -26,7 +27,7 @@ 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(ct) + s := newState(p.Target, ct) for _, c1 := range p.Calls { if c1 == c { break @@ -36,8 +37,9 @@ func analyze(ct *ChoiceTable, p *Prog, c *Call) *state { return s } -func newState(ct *ChoiceTable) *state { +func newState(target *Target, ct *ChoiceTable) *state { s := &state{ + target: target, ct: ct, files: make(map[string]bool), resources: make(map[string][]Arg), @@ -66,7 +68,7 @@ func (s *state) analyze(c *Call) { } } }) - start, npages, mapped := analyzeMmap(c) + start, npages, mapped := s.target.AnalyzeMmap(c) if npages != 0 { if start+npages > uint64(len(s.pages)) { panic(fmt.Sprintf("address is out of bounds: page=%v len=%v bound=%v", |
