This is the mail archive of the insight@sourceware.cygnus.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Tk/Tcl problem in insight


Duane,

This is a longstanding "infelicitious design decision" that I have not 
yet fixed.  The code you type at the tk command is not being run
correctly - it is run inside a tcl proc rather than with "uplevel #0"
so when you make a variable you are making a LOCAL not a global
variable.  Similarly, if you try to do:

(gdb) tk set tcl_patchLevel

You would get a "variable not found" error.

There are two solutions to this:

1) Use :: on all the variables you want to be global, so in your case:

  tk set ::foobar "Hello World"
  tk set ::foobar

...

Actually, I have just been too busy to fix this, so I usually cheap
out and use TkCon to attach to the Tcl interpreter in Insight, and
send commands that way.  This is convenient, since TkCon understands
Tcl syntax, whereas the Console window does not (for instance the
Insight console can't continue lines of code in a way that Tcl
likes...)

2) Help fix it.  This is probably not that hard to just make sure all
the Tcl commands get evaluated in the global interpreter scope.  

What would be even better would be to put a switch in the console
window so that you can toggle it from being a gdb command line
interpreter (with the "tk" command as the out to the Tcl interpreter)
to being a tcl interpreter (with the "gdb_cmd" command to send
commands to the gdb interpreter.)  This would be REALLY useful, and if
you want to give it a whack, I will be glad to help out...

There are some other neat things that you could do as well.  Like it
would be really cool if the "source" menu item, or even the built-in
source command - would do the Unix trick of looking for a #!, and if
it saw "#!gdbtk" or some such would feed the rest of the code to the
Tcl interpreter.

Jim

 > I am trying to do something with insight & tcl/tk and cannot seem to
 > get anywhere.
 > 
 > Here's what I have done: 
 > 
 > a)  downloaded the insight-20000309 snapshot,
 > 
 > b)  unpacked, configured, unstalled etc, like this:
 >     [host: redhat linux 6.1, intel]
 > 
 > 	./configure -prefix=/home/duane/test
 > 
 > 	make
 > 
 > 	make install
 > 
 >   Builds fine.
 > 
 > d) cd to the 'bin' directory where it installed
 >    the 'gdb' executable so I can run it.
 > 
 >     cd /home/duane/test/bin
 > 
 >     ./gdb
 > 
 > e) Gdb starts up - no problem.
 > 
 >    Click on the "C:>" prompt
 > 
 > f) type the following:
 > 
 > 	tk set foobar "Hello, world"
 > 
 >    Responds with 'Hello, world'
 > 
 > g) type the following:
 > 
 > 	tk puts $foobar
 > 
 >    And it does not work, I get 
 > 
 > 	Error: can't read "foobar": no such variable
 > 
 > What am I doing wrong?
 > 
 > ... Now the [real] problem ....
 > 
 > I really have a tcl script that interacts with a custom simulator that
 > I wrote, and I cannot get it to work, I get the same basic errors and
 > problems.
 > 
 > I thought - ok - get the latest version in it's 'virgin' state - and
 > try a very simple little test with *JUST* two commands.
 > 
 > --Duane.
 > 

-- 
++==++==++==++==++==++==++==++==++==++==++==++==++==++==++==++==++==++==++
Jim Ingham                                              jingham@cygnus.com
Cygnus Solutions, a Red Hat Company                      

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]