1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2012-2019 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 void *first_mapped_page
;
26 void *last_mapped_page
;
41 /* Map 6 contiguous pages, and then unmap all second first, and
44 From GDB we will disassemble each of the _mapped_ pages, with a
45 code-cache (dcache) line size bigger than the page size (twice
46 bigger). This makes GDB try to read one page before the mapped
47 page once, and the page after another time. GDB should give no
50 That is, depending on where the kernel aligns the pages, we get
53 .---.---.---.---.---.---.
54 | U | M | U | U | M | U |
55 '---'---'---'---'---'---.
56 | | | | <- line alignment
63 .---.---.---.---.---.---.
64 | U | M | U | U | M | U |
65 '---'---'---'---'---'---.
66 | | | <- line alignment
71 Note we really want to test that dcache behaves correctly when
72 reading a cache line fails. We're just using unmapped memory as
73 proxy for any kind of error. */
75 pg_size
= getpagesize ();
78 p
= mmap (0, pg_count
* pg_size
, PROT_READ
|PROT_WRITE
,
79 MAP_ANONYMOUS
|MAP_PRIVATE
, -1, 0);
86 /* Leave memory zero-initialized. Disassembling 0s should behave on
89 for (i
= 0; i
< pg_count
; i
++)
94 if (munmap (p
+ (i
* pg_size
), pg_size
) == -1)
101 first_mapped_page
= p
+ 1 * pg_size
;;
102 last_mapped_page
= p
+ 4 * pg_size
;