Re: A tcl command logger?

From: George Petasis (petasis_at_iit.demokritos.gr)
Date: 03/24/05


Date: Thu, 24 Mar 2005 22:54:28 +0200

Helmut Giese wrote:
> On Thu, 24 Mar 2005 17:56:26 +0200, "Georgios Petasis"
> <petasis@iit.demokritos.gr> wrote:
>
>
>>Hi all,
>>
>>As I am facing a problem of Tcl/Tk crashing without
>>having access to the machine of the crash or the possibility
>>of debugging it, I want to write a small script that will
>>log each command in the global namespace in a log file.
>>
>>I plan to move all commands from the :: namespace into
>>another namespace, and substitute each command with a
>>new one that will log the command & its arguments into a file,
>>and then call the original command. As this is very similar to
>>what a debugger does, I was wondering if such a facility is
>>already available that I can use, before I code it my self.
>>Any ideas?
>
> HI George,
> newer versions of Tcl allow you to set traces on command execution,
> and even fine-graining this whether you want to trace 'enter' or
> 'leave' - I forgot what I knew about them but the man pages should
> provide all necessary details.
> HTH
> Helmut Giese

Thank you both for your answers. However, as it has to run to
tcl 8.4, I finally write a small script to do the task. What was
surprising though was to find that the 'if' command calls
'expr' to make the evaluation. While it makes some sense,
I would have expected 'if' to call the C API that
'expr' uses directly. This means that:

a) 'expr' is a more important command than I have always thought. I
always regarded 'expr' as a tool for doing some math. But it turns out that
its efficency is vital for the efficiency of tcl in general.
(Well, I am a little biased from the long thread "So slow Tcl :(")

b) If anybody messes with 'expr', also 'if' (and possibly 'while',
'for', etc) will be affected. Is this something expected? I know
that tcl is such a dynamic language, but I always had the impression
that 'if', 'for', 'while', etc will continue to work as expected
as long as I don't touch them. But removing 'expr' will
also render useless all these functions. Is this a feature or a bug?

George



Relevant Pages

  • Re: Executing an expr from a C code --- Tcl_ParseCommand
    ... // the expression _exprStr should use a tcl double variable called ... // try to parse the expr ... that are freed when deleting the interp? ... tcl expr command to let my users compute some mathematical expression. ...
    (comp.lang.tcl)
  • Re: Why doesnt foreach return a value
    ... Every Tcl command is implemented as a C level function. ... What we want at the script level is the ... What changes occur is very specific to the context. ...
    (comp.lang.tcl)
  • Re: No argv, argc for worker thread
    ... I expected that a Tcl interpreter started in any manner would accept options ... This is how the interpreter works with command line options ... a "main" script processes command line ...
    (comp.lang.tcl)
  • Re: Executing an expr from a C code --- Tcl_ParseCommand
    ... tcl expr command to let my users compute some mathematical expression. ... I hence would need to "execute" expr from a C code. ... 2- create a variable in the interp, ...
    (comp.lang.tcl)
  • Re: how do you get a handle to the interpreter?
    ... > launch it from the tcl script via exec, rather than creating it as a tcl ... > made into a command ... Umm, if you are launching it via exec it is a complely different process, ...
    (comp.lang.tcl)