Tcl Source Code

Artifact [20a2cd0d09]
Login

Artifact 20a2cd0d09ccd34bdec24e57dc4b25e98b609ff9:

Attachment "crash.tcl" to ticket [1462248fff] added by matzek 2006-04-03 20:37:52.
# Blocksize for [read]
set bs 4096
# Filename
set fn crashme3

set size [file size $fn] 
set offset [expr {$size - ($bs * 33)}]

# Print file offset to stdout.
fconfigure stdout -buffering none
while {$offset > 0} {
    puts -nonewline "[expr {$offset / $bs}]/$offset >>> " ;# print start position (block/byte offset)
    set fc 0 ;# reset block read count
    set fh [open $fn]
    seek $fh $offset ;# go to start position
    while {![eof $fh]} {
	#puts -nonewline "[tell $fh] "
	puts -nonewline "$fc " ;# print block read count
	read $fh $bs ;# read one block
	incr fc ;# increment block read count
    }
    close $fh
    incr offset -$bs ;# decrement start position by one block
    puts "" ;# print newline
}