2 # Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 from gdb_test import AssertEquals
12 gdb.Command('break mmap_breakpoint')
13 gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
14 gdb.ResumeAndExpectStop('finish', 'function-finished')
15 # Check that we can read from memory mapped files.
16 AssertEquals(gdb_test.ParseNumber(gdb.Eval('*file_mapping')), 123)
17 gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
18 gdb.ResumeAndExpectStop('finish', 'function-finished')
19 file_mapping_str = gdb.Eval('file_mapping')
20 file_mapping = gdb_test.ParseNumber(file_mapping_str)
21 gdb.Command('break *' + file_mapping_str)
22 gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
23 # Check that breakpoint in memory mapped code is working.
24 AssertEquals(gdb.GetPC(), file_mapping)
25 gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
26 gdb.ResumeAndExpectStop('finish', 'function-finished')
27 file_mapping_str = gdb.Eval('file_mapping')
28 file_mapping = gdb_test.ParseNumber(file_mapping_str)
29 gdb.Command('break *' + file_mapping_str)
30 gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
31 # Check that breakpoint in memory mapped code is working.
32 AssertEquals(gdb.GetPC(), file_mapping)
35 if __name__ == '__main__':
36 os.environ['NACL_FAULT_INJECTION'] = (
37 'MMAP_BYPASS_DESCRIPTOR_SAFETY_CHECK=GF/@')
38 gdb_test.RunTest(test, 'mmap')