From df39c0c8dee65a10dfc339a970a3beb4d0e481f3 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 1 Oct 2018 11:15:45 -0700 Subject: 4635 Another sanity check. We don't really have a clear big picture yet. But I've now slapped on checks for all the issues I was worrying about. A more rigorous solution would be some sort of interval tree. We'd also need to track segments generated at translation time. We don't do that so far. --- subx/010---vm.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'subx') diff --git a/subx/010---vm.cc b/subx/010---vm.cc index e2fab9fa..57e29433 100644 --- a/subx/010---vm.cc +++ b/subx/010---vm.cc @@ -118,17 +118,34 @@ struct vma { } void grow_until(uint32_t new_end_address) { if (new_end_address < end) return; + // Ugly: vma knows about the global Memory list of vmas + void sanity_check(uint32_t start, uint32_t end); + sanity_check(start, new_end_address); end = new_end_address; _data.resize(new_end_address - start); } // End vma Methods }; +:(code) +void sanity_check(uint32_t start, uint32_t end) { + bool dup_found = false; + for (int i = 0; i < SIZE(Mem); ++i) { + const vma& curr = Mem.at(i); + if (curr.start == start) { + assert(!dup_found); + dup_found = true; + } + else if (curr.start > start) { + assert(curr.start > end); + } + else if (curr.start < start) { + assert(curr.end < start); + } + } +} :(before "End Globals") // RAM is made of VMAs. -// -// We currently have zero tests for overlapping VMAs. Particularly after -// growing segments. vector Mem; :(code) // The first 3 VMAs are special. When loading ELF binaries in later layers, -- cgit 1.4.1-2-gfad0 href='/akkartik/mu/diff/067random.cc?h=main&id=92d8ef6c3b401e16da6e6389819f3d6f41602ba8'>diff stats
blob: d80adb4d97a06f2b80fcd05383fd03a606d5d126 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34