#!/usr/bin/tclsh proc readfile {fname} { set f [open $fname r]; set s [read $f]; close $f return $s } # (find-k22file "fs/proc/array.c" "static int get_stat(") proc ancestorpid {progname} { for {set dirid self} {$dirid!="0"} {set dirid $ppid} { scan [readfile /proc/$dirid/stat] "%d %s %c %d" pid comm state ppid if {$comm=="($progname)"} { return $pid } } errot "Process not found" } proc gnudoit {lispcode} { puts $lispcode puts [exec gnudoit $lispcode] } set path [lindex $argv 0] set pid [ancestorpid [file tail $path]] # set elisp0 {(gdb "gdb --silent %path %pid")} set elisp0 {(gdb "gdb %path %pid")} regsub -all %path $elisp0 $path elisp regsub -all %pid $elisp $pid elisp gnudoit $elisp gnudoit {(buffer-substring (point-min) (point-max))} exit