-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft: Add parameter to check if files are mapped in processes not pa…
…rt of the recording.
- Loading branch information
Showing
8 changed files
with
135 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "util.h" | ||
|
||
#include <assert.h> | ||
#include <fcntl.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <sys/stat.h> | ||
|
||
int main(__attribute__((unused)) int argc, char* argv[]) { | ||
size_t page_size = sysconf(_SC_PAGESIZE); | ||
char last = 0; | ||
char* p; | ||
int proc_num = argv[2][0] - '0'; | ||
|
||
if (argv[3][0] > '0') { | ||
char cmd[512]; | ||
sprintf(cmd, "%s %s %d %c &", argv[0], argv[1], proc_num+1, argv[3][0]-1); | ||
system(cmd); | ||
} | ||
|
||
int fd = open(argv[1], O_RDWR|O_CREAT, 0600); | ||
test_assert(fd >= 0); | ||
ftruncate(fd, page_size); | ||
p = (char*)mmap(0, page_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); | ||
assert(p != MAP_FAILED); | ||
|
||
while (1) { | ||
if ((*p % 2) == proc_num) { | ||
if ((*p)++ >= 6) { | ||
atomic_printf("%d %d exiting.\n", getpid(), proc_num); | ||
usleep(50000); /* first recorded process exiting kills all others, wait a little. */ | ||
return 0; | ||
} | ||
} | ||
if (last != *p) | ||
atomic_printf("%d\n", last = *p); | ||
usleep(50000); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
source `dirname $0`/util.sh | ||
|
||
rm -rf $workdir/map_file | ||
RECORD_ARGS="--lsof" | ||
record mmap_shared_extern$bitness $workdir/map_file 0 1 | ||
mv record.out record.out.1 | ||
mv record.err record.err.1 | ||
grep "might cause diversion" $workdir/record.out.1 > /dev/null | ||
if [[ $? != 1 ]]; then | ||
failed "\"might cause diversion\" was returned when all processes are inside the recording." | ||
exit | ||
fi | ||
|
||
rm -rf $workdir/map_file | ||
mmap_shared_extern$bitness $workdir/map_file 0 0 > /dev/null& | ||
RECORD_ARGS="--lsof" | ||
record mmap_shared_extern$bitness $workdir/map_file 1 0 | ||
mv record.out record.out.2 | ||
mv record.err record.err.2 | ||
grep "might cause diversion" $workdir/record.out.2 > /dev/null | ||
if [[ $? != 0 ]]; then | ||
failed "\"might cause diversion\" was not returned when some processes are outside the recording." | ||
fi |