What do you exactly want to do with the pipe to gdb? If you want to do non-blocking io and want some mechanism of synchronization, you can always use a thread to check data and signalize to other threads of presence of some data in the pipe. Or use a thread, which calls some hook on data arrival. (define (on-data-income port hook) (thread-start! (make-thread (lambda () (hook (read-line port))))) If you want to check gdb started and ready, use: (let loop ((rd (read-line port #\space #f))) (if (and (>= (string-length rd) 5) (string-equal? (substring rd 0 5) "(gdb)")) (pp "gdb ready") (loop (read-line port #\space #f))))
Log:
~/vis/test:$ gsi test.scm "~\"GNU gdb 6.8-debian\\n\"" "~\"Copyright (C) 2008 Free Software Foundation, Inc.\\n\"" "~\"License GPLv3+: GNU GPL version 3 or later < http://gnu.org/licenses/gpl.html>\\n\"" "~\"This is free software: you are free to change and redistribute it.\\n\"" "~\"There is NO WARRANTY, to the extent permitted by law. Type \\\"show copying\\\"\\n\"" "~\"and \\\"show warranty\\\" for details.\\n\"" "~\"This GDB was configured as \\\"x86_64-linux-gnu\\\".\\n\"" "(gdb) " ~/vis/test:$ gsi test.scm ~/vis/test:$ gsi test.scm ~/vis/test:$ gsi test.scm "~\"GNU gdb 6.8-debian\\n\"" "~\"Copyright (C) 2008 Free Software Foundation, Inc.\\n\"" "~\"License GPLv3+: GNU GPL version 3 or later < http://gnu.org/licenses/gpl.html>\\n\"" "~\"This is free software: you are free to change and redistribute it.\\n\"" "~\"There is NO WARRANTY, to the extent permitted by law. Type \\\"show copying\\\"\\n\"" "~\"and \\\"show warranty\\\" for details.\\n\"" "~\"This GDB was configured as \\\"x86_64-linux-gnu\\\".\\n\"" "(gdb) " ~/vis/test:$ gsi test.scm "~\"GNU gdb 6.8-debian\\n\"" "~\"Copyright (C) 2008 Free Software Foundation, Inc.\\n\"" "~\"License GPLv3+: GNU GPL version 3 or later < http://gnu.org/licenses/gpl.html>\\n\"" "~\"This is free software: you are free to change and redistribute it.\\n\"" "~\"There is NO WARRANTY, to the extent permitted by law. Type \\\"show copying\\\"\\n\"" "~\"and \\\"show warranty\\\" for details.\\n\"" "~\"This GDB was configured as \\\"x86_64-linux-gnu\\\".\\n\"" "(gdb) " ~/vis/test:$ gsi test.scm ~/vis/test:$
Code:
~/vis/test:$ cat test.scm (define p (open-process (list path: "gdb" arguments: '("--interpreter=mi2")))) (define (rr) (if (char-ready? p) (pp (read-line p))))
(rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr) (rr)
Questions:
1) Why is this non-deterministic? (subject to how fast gdb prints out its data?)
2) How can I make it deterministic? (I'd prefer something better than "sleep for 0.5 seconds")
Thanks!
------------------------------------------------------------------------
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list