아래의 코드를 이용하면 매 커맨드마다 프롬프트가 뜨므로, tcl 커맨드로 변수의 값이나 기타 정보를 확인 할 수 있습니다.
debugger.tcl
# debugger.tcl
# break point - pause execution
proc bp {} {
interp alias {} tracecmd {} tracecmd1
}
# continue execution
proc cont {} {
interp alias {} tracecmd {} tracecmd2
}
# used after a bp command
proc tracecmd1 {cmd op} {
puts $cmd
puts -nonewline "[lindex [info level -1] 0]> "
gets stdin a
while {$a ne ""} {
if {[catch {uplevel 1 puts \[$a\]} err]} {puts $err}
gets stdin a
}
}
# used before a bp command or after a cont command
proc tracecmd2 {cmd op} {
if {$cmd eq "bp"} {
interp alias {} tracecmd {} tracecmd1
}
}
interp alias {} tracecmd {} tracecmd2
test.tcl
# test.tcl
source debugger.tcl
proc func1 {v} {
func2 10
foreach x {1 2 3 4 5} { }
for {set i 0} {$i < $v} {incr i} {
puts i=$i
}
}
proc func2 {a} {
puts {This is func2}
puts var=$a
}
trace add execution func1 enterstep tracecmd
bp
func1 10
startup
tclsh test.tcl
'Tcl & Tk > 팁 (Tip)' 카테고리의 다른 글
메인 프레임 크기 설정 (0) | 2025.03.12 |
---|---|
dict 패키지를 이용한 ini 파서 (0) | 2025.03.12 |
피아노 코드 도우미 v0.925 (0) | 2025.03.12 |
초 간단 웹 부라우저 (0) | 2025.03.12 |
시간에 따라 변화하는 결과를 plotting하기 (0) | 2025.03.12 |