1 /* Simple little program that just generates a core dump from inside some
2 nested function calls. */
16 #define MAPSIZE (8 * 1024)
18 /* Don't make these automatic vars or we will have to walk back up the
19 stack to access them. */
24 int coremaker_data
= 1; /* In Data section */
25 int coremaker_bss
; /* In BSS section */
27 const int coremaker_ro
= 201; /* In Read-Only Data section */
29 /* Note that if the mapping fails for any reason, we set buf2
30 to -1 and the testsuite notices this and reports it as
31 a failure due to a mapping error. This way we don't have
32 to test for specific errors when running the core maker. */
39 /* Allocate and initialize a buffer that will be used to write
40 the file that is later mapped in. */
42 buf1
= (char *) malloc (MAPSIZE
);
43 for (j
= 0; j
< MAPSIZE
; ++j
)
48 /* Write the file to map in */
50 fd
= open ("coremmap.data", O_CREAT
| O_RDWR
, 0666);
53 perror ("coremmap.data open failed");
57 write (fd
, buf1
, MAPSIZE
);
59 /* Now map the file into our address space as buf2 */
61 buf2
= (char *) mmap (0, MAPSIZE
, PROT_READ
| PROT_WRITE
, MAP_PRIVATE
, fd
, 0);
62 if (buf2
== (char *) -1)
64 perror ("mmap failed");
68 /* Verify that the original data and the mapped data are identical.
69 If not, we'd rather fail now than when trying to access the mapped
70 data from the core file. */
72 for (j
= 0; j
< MAPSIZE
; ++j
)
74 if (buf1
[j
] != buf2
[j
])
76 fprintf (stderr
, "mapped data is incorrect");
86 int coremaker_local
[5];
90 /* Force a corefile that includes the data section for AIX. */
94 sigaction (SIGABRT
, (struct sigaction
*)0, &sa
);
95 sa
.sa_flags
|= SA_FULLDUMP
;
96 sigaction (SIGABRT
, &sa
, (struct sigaction
*)0);
100 /* Make sure that coremaker_local doesn't get optimized away. */
101 for (i
= 0; i
< 5; i
++)
102 coremaker_local
[i
] = i
;
104 for (i
= 0; i
< 5; i
++)
105 coremaker_bss
+= coremaker_local
[i
];
106 coremaker_data
= coremaker_ro
+ 1;
This page took 0.032663 seconds and 4 git commands to generate.