remove math.blas.syntax and merge parsing words into math.blas.vectors/matrices
[factor/jcg.git] / basis / tools / disassembler / gdb / gdb.factor
blob9076b67606399d0e6a4939268d364ff128f36f81
1 ! Copyright (C) 2008 Slava Pestov, Jorge Acereda Macia.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io.files io.files.temp io words alien kernel math.parser
4 alien.syntax io.launcher system assocs arrays sequences
5 namespaces make system math io.encodings.ascii
6 accessors tools.disassembler ;
7 IN: tools.disassembler.gdb
9 SINGLETON: gdb-disassembler
11 : in-file ( -- path ) "gdb-in.txt" temp-file ;
13 : out-file ( -- path ) "gdb-out.txt" temp-file ;
15 : make-disassemble-cmd ( from to -- )
16     in-file ascii [
17         "attach " write
18         current-process-handle number>string print
19         "disassemble " write
20         [ number>string write bl ] bi@
21     ] with-file-writer ;
23 : gdb-binary ( -- string ) "gdb" ;
25 : run-gdb ( -- lines )
26     <process>
27         +closed+ >>stdin
28         out-file >>stdout
29         [ gdb-binary , "-x" , in-file , "-batch" , ] { } make >>command
30     try-process
31     out-file ascii file-lines ;
33 M: gdb-disassembler disassemble*
34     make-disassemble-cmd run-gdb ;
36 gdb-disassembler disassembler-backend set-global