How can be find the location of procedure (function) in TCL. Under location I mean the source file in which it is declared.
I’m trying to read foreign source-code and can not find the declaration of a single procedure, example:
set MSISDNElement [regexp -all -inline {ISDN +[0-9]+} $Command]
if { $MSISDNElement != "" } {
foreach elm $MSISDNElement {
set MSISDNValue [list ISDN [getInternationalFormat [lindex $elm 1]]]
}
}
set EptData [list [lindex $Command 1]]
InitEptData 3
foreach Element $EptData {
SetEptData [lindex $Element 0] [lindex $Element 1]
}
For the functions InitEptData & SetEptData I can’t find any declaration. Could someone familiar much more in deep with TCL, to explain how to solve that issue which I’m facing? Thanks in advance!
There is no generic answer to this, as Tcl allows you to declare procedures on the fly, so they could have no actual file reference.
There are some attempts to improve the situation for procs that have a defining file, for example TIP280, which is actually available as
info framein recent 8.5 versions, and TIP 86, which is only in discussion.But if a simple
grepdoes not work, you could track the moment a procedure or command gets created.This happens in various places (Tcl OO might add a few more, not sure):
loadcommand when a binary extension registers its command handler functions with Tcl_CreateCommand or the more modern Tcl_CreateObjCommand.sourcecommand when a file with proc definitions is loadedproccommand itself to define a new procedureUsing the commands
info commandsandnamespace childrenyou can walk the whole namespace tree to get a list of defined commands before and after the executed command. So you can create a wrapper that tracks any new commands. See http://wiki.tcl.tk/1489 for some hints how to do it.Or, simply use a debugger like RamDebugger http://www.compassis.com/ramdebugger/Intro, or ActiveStates commercial debugger.