[PD-dev] broken msgs cause Tcl traces, how to debug it?

Hans-Christoph Steiner hans at at.or.at
Mon Jan 23 20:00:32 CET 2012


On Jan 23, 2012, at 12:54 AM, Miller Puckette wrote:
> 
> On Mon, Jan 23, 2012 at 12:45:09AM -0500, Mathieu Bouchard wrote:
>> Le 2012-01-22 à 21:16:00, Miller Puckette a écrit :
>> 
>>> There's not much way around this.  One possibility (if indeed this
>>> is a serious efficiency issue) would be for Pd to append a "done"
>>> message to each batch up tcl to up-send.
>> 
>> That's called a newline... not preceded by a backslash. The thing
>> with fconfigure -buffering line is that it doesn't care about
>> backslashes, whereas eval does, and if you use both together, you
>> need to account for that difference.
> 
> As it stands right now, there are new-lines in the middle of certain tcl
> commands sent from Pd, so if newline were it, I'd have to go chase down all 
> the pretty-printing newlines in the Pd code and delete them.  That might
> actually might work; I'd only be worried taht some extern was throwing up tcl
> code with intra-tcl-statement newlines that would occasionally throw false
> positives at the tcl completeness checker, if indeed all it did was check
> that the tcl buffer ended in a newline.
> 
> cheers
> Miller

Ok, so I tried an implementation based on [gets] that is line-by-line, so it gets a line, then executes it.  This version is ridiculously slow, like barely usable.  I'm now trying a version of this that uses [gets] to read everything in the buffer, then executes it in blocks, it seems faster, let's see if it fixes the problem!

Here's the line-by-line execution version:

proc ::pd_connect::pd_readsocket {cmd_from_pd} {
    variable pd_socket
    if {[eof $pd_socket]} {
        # if we lose the socket connection, that means pd quit, so we quit
        close $pd_socket
        exit
    } 
    if {[gets $pd_socket line] < 0} {return}
    append cmd_from_pd $line\n
    if {[string index $cmd_from_pd end] eq "\\"} {
        ::pd_connect::pd_readsocket $cmd_from_pd
    }
    if {[catch {uplevel #0 $cmd_from_pd} errorname]} {
        global errorInfo
        switch -regexp -- $errorname { 
            "missing close-brace" {
                pd_readsocket $cmd_from_pd
            } "^invalid command name" {
                ::pdwindow::fatal [concat [_ "(Tcl) INVALID COMMAND NAME: "] $errorInfo "\n"]
            } default {
                ::pdwindow::fatal [concat [_ "(Tcl) UNHANDLED ERROR: "] $errorInfo "\n"]
            }
        }
    }
}


.hc


----------------------------------------------------------------------------

If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of everyone, and the receiver cannot dispossess himself of it.            - Thomas Jefferson





More information about the Pd-dev mailing list