1 ! Copyright (C) 2008, 2010 Slava Pestov, Jorge Acereda Macia.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors io io.encodings.ascii io.files io.files.temp
4 io.launcher locals make math math.parser namespaces
5 tools.disassembler.private ;
6 IN: tools.disassembler.gdb
8 SINGLETON: gdb-disassembler
12 TR: tabs>spaces "\t" "\s" ;
14 : in-file ( -- path ) "gdb-in.txt" temp-file ;
16 : out-file ( -- path ) "gdb-out.txt" temp-file ;
18 :: make-disassemble-cmd ( from to -- )
21 (current-process) number>string print
22 "x/" write to from - 4 / number>string write
23 "i" write bl from number>string write
26 : run-gdb ( -- lines )
30 [ "gdb" , "-x" , in-file , "-batch" , ] { } make >>command
32 out-file ascii file-lines ;
36 M: gdb-disassembler disassemble*
37 make-disassemble-cmd run-gdb [ tabs>spaces print ] each ;
39 gdb-disassembler disassembler-backend set-global