retrieving line number in case of error - "simple debugger"
- From: Nicolas Castagne <castagne@xxxxxxx>
- Date: Thu, 29 Sep 2005 17:30:51 +0200
Hi all,
I will use tcl within a C/C++ application in order to execute scripts writen by users. The app starts a Tcl_Interp, and execute the file.
I would need to display basic information to the user in case an error occurs. Among these, the error line on which the error occured.
My two question are :
1/ Given a script, how can I retrieve the exact line on which the error occured ?
2/ Do you know a nice HOWTO or code sample for building basic debug features ?
In order to explain which point I have reached so far, here is a rather simple example then.
Suppose the script is :
1 if 1 {
2 set a 2
3 set a 2 3
4 }The error is on line 3.
When evaluating this script, however, the error line registered by Tcl is "1" (ie : error of the 'first level' command called).
If, in the C master application, I write something like :
result = Tcl_EvalEx(tclInterp, script, length, TCL_EVAL_GLOBAL);
if (result != TCL_OK ) {
Tcl_Obj *options = Tcl_GetReturnOptions(tclInterp, result);
Tcl_Obj *key = Tcl_NewStringObj("-errorline", -1);
Tcl_Obj *errorline;
Tcl_DictObjGet(NULL, options, key, &errorline);
printf(" ERROR line %s\n", Tcl_GetString(errorline));
}the output will be "ERROR line 1".
Basically, I am unable to retrieve the error line within the nested script of the "if" command.
Thanks for reading, and waiting for answer !
Dr Nicolas Castagne http://acroe.imag.fr .
- Follow-Ups:
- Prev by Date: Re: TIP #257: Object Orientation for Tcl
- Next by Date: Re: Tk Unicode is slow
- Previous by thread: tk_chooseDirectory -mustexist 1
- Next by thread: Re: retrieving line number in case of error - "simple debugger"
- Index(es):
Relevant Pages
|