OpenROAD icon indicating copy to clipboard operation
OpenROAD copied to clipboard

openroad -exit foo.tcl should print out a stacktrace & error message, like tclsh would have

Open oharboe opened this issue 1 year ago • 9 comments

Description

Today openroad -exit foo.tcl doesn't print out a stack trace and there are some surprises w.r.t. the tcl source command being overriden by OpenSTA

See also https://github.com/The-OpenROAD-Project/OpenROAD/issues/5415

Suggested Solution

Fewer surprises for the batch(automated) case. OpenSTA should not modify standard tcl behavior.

For the GUI(including console mode REPL), it doesn't matter so much, because there is a user to interpret what is happening and invervene.

Additional Context

No response

oharboe avatar Jul 23 '24 19:07 oharboe

Are you referring to a stack trace on segv or some tcl stack trace on error?

maliberty avatar Jul 23 '24 19:07 maliberty

tcl stack trace

oharboe avatar Jul 23 '24 19:07 oharboe

@tspyrou Tried to investigate some more by moving STA's implementation of "source" into it's own namespace. There are still differences:

$ openroad -exit -no_init blah.tcl 
OpenROAD v2.0-14788-g11331a82c 
Features included (+) or not (-): +Charts +GPU +GUI +Python
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
blah.tcl
invalid command name "asdf"
    while executing
"::unknown {*}$args"
    (procedure "sta_unknown" line 28)
    invoked from within
"asdf"
    (file "blah.tcl" line 4)
    invoked from within
"source blah.tcl"
$ tclsh blah.tcl 
blah.tcl
invalid command name "asdf"
    while executing
"asdf"
    (file "blah.tcl" line 4)
$ cat blah.tcl 
puts [info script]


asdf

oharboe avatar Jul 26 '24 09:07 oharboe

@tspyrou @maliberty With https://github.com/Pinata-Consulting/OpenSTA/tree/sta-source-namespace and https://github.com/Pinata-Consulting/OpenROAD/tree/sta-source-namespace, I get the expected output:

$ cat blah.tcl 
puts [info script]


asdf
$ openroad -exit -no_init blah.tcl 
OpenROAD v2.0-14788-g6c6b363ad 
Features included (+) or not (-): +Charts +GPU +GUI +Python
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
blah.tcl
invalid command name "asdf"
    while executing
"asdf"
    (file "blah.tcl" line 4)
$ echo $?
1
$ tclsh blah.tcl 
blah.tcl
invalid command name "asdf"
    while executing
"asdf"
    (file "blah.tcl" line 4)
$ echo $?
1

oharboe avatar Jul 26 '24 09:07 oharboe

Does this also work in you start OR and then do source blah.tcl or source -echo blah.tcl?

maliberty avatar Jul 26 '24 13:07 maliberty

Does this also work in you start OR and then do source blah.tcl or source -echo blah.tcl?

I haven't done that much testing to be honest, I just wanted to get a better sense of the scope of effects, which is when I discovered another part of tcl that has been modified the "uknown" proc.

If we decide that this is an interesting direction to take things in, we can do more testing and try to polish it up.

oharboe avatar Jul 26 '24 13:07 oharboe

Unknown is intended as an extension point in TCL. Virtually every EDA does uses it to avoid the problem :

# Bus signal names like foo[2] or bar[31:0] use brackets that
# look like "eval" to TCL. Catch the numeric "function" with the
# namespace's unknown handler and return the value instead of an error.

I don't see that as an issue.

maliberty avatar Jul 26 '24 14:07 maliberty

Unknown is intended as an extension point in TCL. Virtually every EDA does uses it to avoid the problem :

# Bus signal names like foo[2] or bar[31:0] use brackets that
# look like "eval" to TCL. Catch the numeric "function" with the
# namespace's unknown handler and return the value instead of an error.

I don't see that as an issue.

Not as such, but I had to disable it to avoid some sort of crash. Didn't investigate more at the time, just trying to get a better sense of scope of niggling little differences between stock Tcl and OpenSTA Tcl tweaks...

oharboe avatar Jul 26 '24 14:07 oharboe

Cherry looked at this for a bit but couldn't find a solution that keep the regression script working. There will not be a quick solution to this one.

tspyrou avatar Aug 06 '24 13:08 tspyrou