From a108a3bece6c8e9053859eb2303e4f473a96b21c Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 29 Jun 2017 17:38:42 -0400 Subject: [PATCH 1/6] let timer_create using signals through to be handled by rt_sigaction --- main.py | 1 + test/pandoc/test_pandoc_txt_convert.sh | 10 +++++----- time_handlers.py | 9 ++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 727af96..8ec76d7 100644 --- a/main.py +++ b/main.py @@ -224,6 +224,7 @@ def handle_syscall(syscall_id, syscall_object, entering, pid): (258, True): set_tid_address_entry_handler, (258, False): set_tid_address_exit_handler, (259, True): timer_create_entry_handler, + (259, False): timer_create_exit_handler, (260, True): timer_settime_entry_handler, (261, True): timer_gettime_entry_handler, (263, True): timer_delete_entry_handler, diff --git a/test/pandoc/test_pandoc_txt_convert.sh b/test/pandoc/test_pandoc_txt_convert.sh index 8ba28c6..fcf4671 100755 --- a/test/pandoc/test_pandoc_txt_convert.sh +++ b/test/pandoc/test_pandoc_txt_convert.sh @@ -2,13 +2,13 @@ touch empty.txt; -strace -f -s 9999 -vvvv -o pandoc_convert_txt.strace pandoc -t plain -o converted.txt empty.txt; -rm converted.txt; +#strace -f -s 9999 -vvvv -o pandoc_convert_txt.strace pandoc -t latex -o ../converted.txt empty.txt; +#rm ../converted.txt; cd ../../ > /dev/null; -python main.py -c "['pandoc', '-t', 'plain', '-o', 'converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace -l DEBUG; +python main.py -c "['pandoc', '-t', 'latex', '-o', '../converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace;# -l DEBUG; cd test/pandoc/; rm empty.txt; -#rm converted.txt; -rm pandoc_convert_txt.strace +#rm ../converted.txt; +#rm pandoc_convert_txt.strace diff --git a/time_handlers.py b/time_handlers.py index 6e1e5fc..ec065ff 100644 --- a/time_handlers.py +++ b/time_handlers.py @@ -12,7 +12,9 @@ def timer_create_entry_handler(syscall_id, syscall_object, pid): logging.debug("Sigevent type: " + str(sigev_type)) if sigev_type != 'SIGEV_NONE': - raise NotImplementedError("Sigevent type %s is not supported" % (sigev_type)) + logging.debug("Sigevent type %s is not supported" % (sigev_type)) + logging.debug("Letting system call through") + return addr = cint.peek_register(pid, cint.EDX) logging.debug('timerid address: %x', addr) @@ -26,6 +28,11 @@ def timer_create_entry_handler(syscall_id, syscall_object, pid): apply_return_conditions(pid, syscall_object) +def timer_create_exit_handler(syscall_id, syscall_object, pid): + logging.debug("Entering the timer_create exit handler") + logging.debug("Nothing to do here") + + def timer_extract_and_populate_itimerspec(syscall_object, pid, addr, start_index): logging.debug('Itimerspec Address: %x', addr) logging.debug('Extracting itimerspec') From d1e015e1d7a94cd4424c1c5a127aa68fc4cfc7ec Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 29 Jun 2017 17:41:07 -0400 Subject: [PATCH 2/6] changed pandoc test back to original (moving files revelaed nothing) --- test/pandoc/test_pandoc_txt_convert.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/pandoc/test_pandoc_txt_convert.sh b/test/pandoc/test_pandoc_txt_convert.sh index fcf4671..12a8969 100755 --- a/test/pandoc/test_pandoc_txt_convert.sh +++ b/test/pandoc/test_pandoc_txt_convert.sh @@ -2,13 +2,13 @@ touch empty.txt; -#strace -f -s 9999 -vvvv -o pandoc_convert_txt.strace pandoc -t latex -o ../converted.txt empty.txt; -#rm ../converted.txt; +strace -f -s 9999 -vvvv -o pandoc_convert_txt.strace pandoc -t latex -o converted.txt empty.txt; +rm converted.txt; cd ../../ > /dev/null; -python main.py -c "['pandoc', '-t', 'latex', '-o', '../converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace;# -l DEBUG; +python main.py -c "['pandoc', '-t', 'latex', '-o', 'converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace;# -l DEBUG; cd test/pandoc/; rm empty.txt; -#rm ../converted.txt; +#rm converted.txt; #rm pandoc_convert_txt.strace From edb039e485bc2889df2de37fe167d2e6716a0f42 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 29 Jun 2017 17:45:37 -0400 Subject: [PATCH 3/6] removed early return from timer_create entry handler --- test/pandoc/test_pandoc_txt_convert.sh | 4 ++-- time_handlers.py | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/test/pandoc/test_pandoc_txt_convert.sh b/test/pandoc/test_pandoc_txt_convert.sh index 12a8969..1cf623a 100755 --- a/test/pandoc/test_pandoc_txt_convert.sh +++ b/test/pandoc/test_pandoc_txt_convert.sh @@ -2,11 +2,11 @@ touch empty.txt; -strace -f -s 9999 -vvvv -o pandoc_convert_txt.strace pandoc -t latex -o converted.txt empty.txt; +strace -f -s 9999 -vvvv -o pandoc_convert_txt.strace pandoc -t plain -o converted.txt empty.txt; rm converted.txt; cd ../../ > /dev/null; -python main.py -c "['pandoc', '-t', 'latex', '-o', 'converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace;# -l DEBUG; +python main.py -c "['pandoc', '-t', 'plain', '-o', 'converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace;# -l DEBUG; cd test/pandoc/; rm empty.txt; diff --git a/time_handlers.py b/time_handlers.py index ec065ff..86652de 100644 --- a/time_handlers.py +++ b/time_handlers.py @@ -12,20 +12,21 @@ def timer_create_entry_handler(syscall_id, syscall_object, pid): logging.debug("Sigevent type: " + str(sigev_type)) if sigev_type != 'SIGEV_NONE': - logging.debug("Sigevent type %s is not supported" % (sigev_type)) - logging.debug("Letting system call through") - return - - addr = cint.peek_register(pid, cint.EDX) - logging.debug('timerid address: %x', addr) + logging.debug("Sigevent type %s cannot be replayed directly" % (sigev_type)) + logging.debug("Letting timer_create call through") + else: + # addr + addr = cint.peek_register(pid, cint.EDX) + logging.debug('timerid address: %x', addr) - timerid = int(syscall_object.args[-1].value.strip('{}')) - logging.debug(str(timerid)) + # timerid + timerid = int(syscall_object.args[-1].value.strip('{}')) + logging.debug(str(timerid)) - cint.populate_timer_t_structure(pid, addr, timerid); - - noop_current_syscall(pid) - apply_return_conditions(pid, syscall_object) + cint.populate_timer_t_structure(pid, addr, timerid); + + noop_current_syscall(pid) + apply_return_conditions(pid, syscall_object) def timer_create_exit_handler(syscall_id, syscall_object, pid): From 2d6b067992ef038c3509c5a2cc7c69299317360d Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 29 Jun 2017 17:49:05 -0400 Subject: [PATCH 4/6] return pandoc test to clean state --- test/pandoc/test_pandoc_txt_convert.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/pandoc/test_pandoc_txt_convert.sh b/test/pandoc/test_pandoc_txt_convert.sh index 1cf623a..c0ac94c 100755 --- a/test/pandoc/test_pandoc_txt_convert.sh +++ b/test/pandoc/test_pandoc_txt_convert.sh @@ -6,9 +6,8 @@ strace -f -s 9999 -vvvv -o pandoc_convert_txt.strace pandoc -t plain -o converte rm converted.txt; cd ../../ > /dev/null; -python main.py -c "['pandoc', '-t', 'plain', '-o', 'converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace;# -l DEBUG; +python main.py -c "['pandoc', '-t', 'plain', '-o', 'converted.txt', 'empty.txt']" -t test/pandoc/pandoc_convert_txt.strace; cd test/pandoc/; rm empty.txt; -#rm converted.txt; -#rm pandoc_convert_txt.strace +rm pandoc_convert_txt.strace From 85160966b84bcb275a71bf90fe3c701e0adb1f96 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 30 Jun 2017 11:16:09 -0400 Subject: [PATCH 5/6] added back test for signal attached timers for future use, made timer_create break again on trying to create such a timer --- sample_programs/timer_tests.c | 61 +++++++++++++++++++++++++++++++++-- test/test_timer_tests.sh | 2 +- time_handlers.py | 3 +- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/sample_programs/timer_tests.c b/sample_programs/timer_tests.c index 93a6fdc..f75d482 100644 --- a/sample_programs/timer_tests.c +++ b/sample_programs/timer_tests.c @@ -5,6 +5,60 @@ #include +void +timer_handler (int signum) +{ + static int count = 0; + printf ("timer expired %d times\n", ++count); +} + +static int +make_timer_signal(timer_t *timerid, int interval_s) { + // currently the feature this tests is not supported so don't use + struct sigevent sigev; + + struct itimerspec timerspec; + int sigNo = SIGRTMIN; + + /* Set up signal handler. */ + struct sigaction sa; + sa.sa_handler = &timer_handler; + sigemptyset(&sa.sa_mask); + if (sigaction(sigNo, &sa, NULL) == -1) { + fprintf(stderr," Failed to setup signal handling.\n"); + return(-1); + } + + /* Set and enable alarm */ + sigev.sigev_notify = SIGEV_SIGNAL; + sigev.sigev_signo = sigNo; + sigev.sigev_value.sival_ptr = timerid; + + timer_create(CLOCK_REALTIME, &sigev, timerid); + + timerspec.it_value.tv_sec = interval_s; + timerspec.it_interval.tv_sec = interval_s; + + timer_settime(*timerid, 0, &timerspec, NULL); + + return(0); +} + + +void test_use_attach_to_signal() { + timer_t timerid; + int interval = 1; + + printf("Starting timer test: attach to signal \n"); + + make_timer_signal(&timerid, interval); + int i; + for (i = 0; i < 2000000000; i++) {} + timer_delete(timerid); + + printf("Ending timer test: attach to signal \n"); +} + static int make_timer_simple(timer_t *timerid, int interval_s) { struct sigevent sigev; @@ -22,9 +76,9 @@ make_timer_simple(timer_t *timerid, int interval_s) { struct itimerspec old_value; timer_settime(*timerid, 0, &timerspec, &old_value); - printf("Old itimerspec value: it_interval: {%d, %d} \n", old_value.it_interval.tv_sec, old_value.it_interval.tv_nsec); + printf("Old itimerspec value: it_interval: {%d, %d} \n", (int) old_value.it_interval.tv_sec, (int) old_value.it_interval.tv_nsec); - printf("Old itimerspec value: it_value: {%d, %d} \n", old_value.it_value.tv_sec, old_value.it_value.tv_nsec); + printf("Old itimerspec value: it_value: {%d, %d} \n",(int) old_value.it_value.tv_sec,(int) old_value.it_value.tv_nsec); } void test_use_simple() { @@ -92,6 +146,9 @@ int main(void) { test_timer_create(); test_use_simple(); + + // signal attaching functionality is not yet supported + // test_use_attach_to_signal(); return 0; } diff --git a/test/test_timer_tests.sh b/test/test_timer_tests.sh index 061e9b9..9a91c81 100755 --- a/test/test_timer_tests.sh +++ b/test/test_timer_tests.sh @@ -4,4 +4,4 @@ cd ../sample_programs > /dev/null; strace -f -s 9999 -vvvvv -o ../sample_programs/timer_tests.strace ./timer_tests cd .. > /dev/null; - python main.py -c "['sample_programs/timer_tests']" -t sample_programs/timer_tests.strace;# -l DEBUG; + python main.py -c "['sample_programs/timer_tests']" -t sample_programs/timer_tests.strace -l DEBUG; diff --git a/time_handlers.py b/time_handlers.py index 86652de..66d15a7 100644 --- a/time_handlers.py +++ b/time_handlers.py @@ -12,8 +12,7 @@ def timer_create_entry_handler(syscall_id, syscall_object, pid): logging.debug("Sigevent type: " + str(sigev_type)) if sigev_type != 'SIGEV_NONE': - logging.debug("Sigevent type %s cannot be replayed directly" % (sigev_type)) - logging.debug("Letting timer_create call through") + raise NotImplementedError("Sigevent type %s is not supported for timer_create" % (sigev_type)) else: # addr addr = cint.peek_register(pid, cint.EDX) From dce9f28873ca7a71ac6369d72306605f06f446d5 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 30 Jun 2017 11:20:46 -0400 Subject: [PATCH 6/6] took timer tests out of debug mode for running with test.sh --- test/test_timer_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_timer_tests.sh b/test/test_timer_tests.sh index 9a91c81..061e9b9 100755 --- a/test/test_timer_tests.sh +++ b/test/test_timer_tests.sh @@ -4,4 +4,4 @@ cd ../sample_programs > /dev/null; strace -f -s 9999 -vvvvv -o ../sample_programs/timer_tests.strace ./timer_tests cd .. > /dev/null; - python main.py -c "['sample_programs/timer_tests']" -t sample_programs/timer_tests.strace -l DEBUG; + python main.py -c "['sample_programs/timer_tests']" -t sample_programs/timer_tests.strace;# -l DEBUG;