(load "../msg.scm") (use-modules (ice-9 format)) (define hoststring "localhost:30000") (define test1-foo #x08048344) ;(define test1-i 10) (define test1-prog (string-append (getcwd) "/test1")) ;; read all messages and send acks until a break in one of ;; the passed list is hit for the given prog (define run-until-break (lambda (port progid bplist) (cont-prog port progid) (let ((r (readmsg port))) (while (not (and (eq? (car r) 'Abrk) (eq? (cadr r) progid) (member (caddr r) bplist))) (format #t "skipping message ~a, not in ~a" r bplist) (send-ack port (cadr r)) (set! r (readmsg port))) (send-ack port (cadr r)) (caddr r)))) ;; ack all messages until you get an obit (define run-until-end (lambda (port progid) (cont-prog port progid) (let ((r (readmsg port))) (while (not (and (eq? (car r) 'Aobit) (eq? (cadr r) progid))) (format #t "skipping message ~a" r) (send-ack port (cadr r)) (set! r (readmsg port))) (send-ack port (cadr r)) (cadr r)))) (define test0 (lambda () (let ((prctl-port (connect-ip hoststring)) (i 0)) (while (< i 10) (send-test prctl-port "this is a test") (readmsg prctl-port) (set! i (+ i 1))) (close-port prctl-port)))) (define test1-a (lambda () (let ((prctl-port (connect-ip hoststring))) (let ((progid (launch-prog prctl-port test1-prog))) (let ((foo-bpid (bpset prctl-port progid test1-foo))) (format #t "running until bp ~d\n" foo-bpid) (run-until-break prctl-port progid (list foo-bpid)) (display "hit foo() once\n") (run-until-break prctl-port progid (list foo-bpid)) (display "hit foo() twice\n") (run-until-break prctl-port progid (list foo-bpid)) (display "hit foo() three\n") (run-until-break prctl-port progid (list foo-bpid)) (display "hit foo() four\n") (bpclear prctl-port progid foo-bpid)) (run-until-end prctl-port progid) (format #t "end of ~s reached\n" test1-prog)) (close-port prctl-port)))) (define test-prctl (lambda () (test0) (test1-a) ) ) (test-prctl)