strace

System call tracing tool for general Unix binaries.

This is a tool that comes with your operating system. If it is not called strace, it may be called truss instead. It is NOT written in Tcl - just a tool that often helps in tracking down problems.

RJ: Actually, strace is in fact also a debugging command in TCL. You can use the TCL exec to get the OS version of strace. - RS: Well, you can use any executable with exec that is on your $PATH...

See also: ktrace

AMG: A classmate of mine referred to strace as "the king of Unix commands."

EMJ 20160302
If you need to compare two strace output files (e.g. from running the same thing with two different Tcl versions), you can't because the files have different process IDs (in every line) and maybe different timestamps and different addresses, so you can use the following on each file first, so you should have significantly fewer differences to look at:
#!/usr/bin/tclsh
#----------------------------------------------------------------------
# Description : Simplify strace output to allow for easier diffing.
# Date        : 01 March 2016
#----------------------------------------------------------------------
# http://ifdeflinux.blogspot.fr/2012/07/simplified-strace-diffing.html
# didn't work properly, and I didn't want to mess about in Python, so
# here is the same only better, in Tcl.
#----------------------------------------------------------------------

if {[llength $::argv] != 1} {
    puts "usage $::argv0 <filename>"
    exit 1
} else {
    lassign $::argv file1
}

try {
    file stat $file1 fstat
    if { $fstat(type) ne "file" } {
        puts "ERROR: $file1 is not a regular file"
        exit 1
    }
} trap {} {err} {
    puts "ERROR: $err"
    exit 1
}

try {
    set f1 [open $file1]
} trap {} {err} {
    puts "ERROR: $err"
    exit 1
}

set pidcnt 1
while {[gets $f1 line] >= 0} {
    set pidmaybe [regexp -inline {^(\d{1,9}) +} $line]
    if { [llength $pidmaybe] == 2 } {
        lassign $pidmaybe str pid
        if { ![info exists pidlist($pid)] } {
            set pidlist($pid) "PID$pidcnt"
            incr pidcnt
        }
        set line [regsub "^$str" $line "$pidlist($pid) "]
    }
    set line [regsub {0x0{1,16}} $line "0xNULL"]
    set line [regsub {0x[0-9A-Fa-f]{1,16}} $line "0xADDR"]
    set line [regsub {\d{2}:\d{2}:\d{2}} $line "HH:MM:SS"]
    set line [regsub {\d{4}/\d{2}/\d{2}} $line "YYYY/MM/DD"]
    puts $line
}

close $f1