chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] Thoughts on gdb as a debugger for Chicken


From: Tony Sidaway
Subject: Re: [Chicken-hackers] Thoughts on gdb as a debugger for Chicken
Date: Fri, 23 Feb 2007 15:32:54 +0000

On 2/23/07, felix winkelmann <address@hidden> wrote:

Well, this would be pretty cool. Peter Keller thought about interfacing
to gdb a while ago. Perhaps he reads this and has some valuable
input.

Note that all mutations go through C_mutate() (for checking
destructive modifications of data) and that the "locative" mechanism
provides a GC-save way of handling subelements of data structures.

I can provide the necessary details, if you need them.



Any background details on tracking of mutations would be most welcome.

So far what I have is a proof-of-concept demo that forks a gdb
debugger process, loads an image file, sets a breakpoint at a
particular line in the C source file, and runs to that breakpoint,
conducting all debugging activities in Scheme through the GDB/MI
interface I discussed.

I've noticed Hans Bulfone's pipeline egg and it seems to be
tailor-made for this kind of work, so I'll probably cut my production
code using that egg.  When I've got that I'll commit my code to
subversion as an egg.

The code below uses the terminology "top" to refer to the end of a
Posix pipe that is attached to the producer, and "bottom" to refer to
the end of the pipe that is attached to the consumer.  The procedure
gdb would typically be invoked with "(call-with-values gdb (lambda
(pid, receive send) ...))".  In this primitive demo, all input/output
is blocking.  The gdb prompt is the character string "(gdb) " (that's
one trailing space after the closing parenthesis).

GDB/MI is documented here:

http://sourceware.org/gdb/current/onlinedocs/gdb_25.html

(define (gdb)
 (call-with-values create-pipe
   (lambda (bottom-pipe-from-scm-to-proc top-pipe-from-scm-to-proc)
     (call-with-values create-pipe
        (lambda (bottom-pipe-from-proc-to-scm top-pipe-from-proc-to-scm)
          (let ((pid (process-fork)))
            (if (= 0 pid)
                (begin ; STUFF TO DO IF WE'RE CHILD
                  (duplicate-fileno bottom-pipe-from-scm-to-proc 0)
                  (duplicate-fileno top-pipe-from-proc-to-scm 1)
                  (file-close bottom-pipe-from-proc-to-scm)
                  (file-close top-pipe-from-scm-to-proc)
                  ; Now we vanish off into another executable image.
                  (process-execute "/usr/bin/gdb" '("-interpreter=mi2"))))
        
            ;  THIS CODE IS EXECUTED ONLY BY THE PARENT
            (file-close bottom-pipe-from-scm-to-proc)
            (file-close top-pipe-from-proc-to-scm)
            (values pid
                    (open-input-file* bottom-pipe-from-proc-to-scm)
                    (open-output-file* top-pipe-from-scm-to-proc))))))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]