Commit 1b8f29e5 authored by David Byers's avatar David Byers

Fix timing problems with automatic checking

parent c2256d3a
1999-07-03 David Byers <davby@ida.liu.se>
* src/server/handle-malloc-dump.el (trace-run-programs): Fixed
timing problems that caused lyskomd to run before gdb was prepared
for it.
1999-07-04 Per Cederqvist <ceder@gratia>
Prepare for improving access_perm().
......
;;;;
;;;; $Id: handle-malloc-dump.el,v 1.9 1999/07/02 14:50:36 byers Exp $
;;;; $Id: handle-malloc-dump.el,v 1.10 1999/07/04 18:20:17 byers Exp $
;;;; Copyright (C) 1991-1995, 1999 Lysator Academic Computer Association.
;;;;
;;;; This file is part of the LysKOM server.
......@@ -168,8 +168,7 @@ mallocs/reallocs/frees to *Result*."
(defvar trace-done nil)
(defun trace-collect-data (proc data)
(goto-char (point-max))
(insert data))
(princ data (process-mark proc)))
(defun trace-expect (re)
(goto-char trace-last-match)
......@@ -177,10 +176,10 @@ mallocs/reallocs/frees to *Result*."
(progn (set-marker trace-last-match (match-end 0))
(match-beginning 0))))
(defun trace-collect-filter (proc data)
(save-excursion
(set-buffer (process-buffer proc))
(trace-collect-data proc data)))
(defun trace-wait-for (proc regexp)
(while (null (save-excursion (set-buffer (process-buffer proc))
(trace-expect regexp)))
(accept-process-output proc 1)))
(defun trace-process-get-tty (proc data)
(save-excursion
......@@ -189,7 +188,7 @@ mallocs/reallocs/frees to *Result*."
(if (trace-expect "\\(/dev\\S-*\\)$")
(progn (setq gdb-tty (match-string 1))
(message "Tracing using gdb on tty %s" gdb-tty)
(set-process-filter proc 'trace-collect-filter)))))
(set-process-filter proc nil)))))
(defun trace-runtest-filter (proc data)
(save-excursion
......@@ -198,7 +197,7 @@ mallocs/reallocs/frees to *Result*."
(if (trace-expect "Please attach to lyskomd pid \\([0-9]+\\) and hit RETURN$")
(progn (setq lyskomd-pid (string-to-int (match-string 1)))
(message "Attaching to lyskomd pid %d" lyskomd-pid)
(set-process-filter proc 'trace-collect-filter)))))
(set-process-filter proc nil)))))
(defun trace-runtest-sentinel (proc state)
(setq trace-done t))
......@@ -263,8 +262,6 @@ Options:
output-file)))))))))
(defun trace-run-programs (tool-to-test test-to-run)
(setq lyskomd-pid nil)
(setq gdb-tty nil)
......@@ -272,12 +269,21 @@ Options:
(let ((gdb-buffer (trace-make-process-buffer "*gdb*"))
(runtest-buffer (trace-make-process-buffer "*runtest*")))
;; Start gdb, load the macros, THEN find out which tty we are on
;; If we don't do it in this order, we might end up starting
;; the test case before the breakpoints are in place. Strange,
;; but true.
(setq gdb-proc (start-process "gdb" gdb-buffer "gdb" "../lyskomd"))
(setq gdb-buffer (get-buffer-create "*gdb*"))
(set-process-filter gdb-proc 'trace-process-get-tty)
(process-send-string gdb-proc "source ../trace-mem.gdb\n")
(process-send-string gdb-proc "shell echo `tty`\n")
(while (null gdb-tty) (accept-process-output gdb-proc))
;; Start runtest with the selected test case. Wait until we see
;; the PID. Wait for gdb to attach to the process!
(setq runtest-proc (start-process "runtest"
runtest-buffer
"runtest"
......@@ -290,14 +296,23 @@ Options:
(set-process-sentinel runtest-proc 'trace-runtest-sentinel)
(while (null lyskomd-pid) (accept-process-output runtest-proc))
(process-send-string gdb-proc "source ../trace-mem.gdb\n")
(process-send-string gdb-proc (format "attach %s\n" lyskomd-pid))
(process-send-string gdb-proc "continue\n")
(message "Waiting for gdb to resume lyskomd")
(trace-wait-for gdb-proc "Continuing")
;; Start the test case, and wait for it to terminate.
(message "Running test case %s" test-to-run)
(process-send-string runtest-proc "\n")
(while (null trace-done) (accept-process-output))
(set-buffer gdb-buffer)
;; Wait for all the data to be printed in the gdb buffer
(trace-wait-for gdb-proc "Program exited")
;; Resolve the trace
(set-process-buffer gdb-proc nil)
(message "Resolving trace...")
(resolve-trace)
(set-buffer "*Result*")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment