Magik Debugging Tips

System Type Debugging

What dynamics are set????

This is a good snippet of code to determine what dynamics are set when your code is executed…

How did I get here???

You can call a traceback in any method to figure out how you got there.

In 4.1 and above, when you load the developer application, the traceback will be shown with numbers. You can get a handle on the specific call by using the global !ts![x], where x is the traceback number you are interested in. Note !ts! is overwritten on every traceback, so do a !cts! « !ts!.copy() before doing anything.

When you get a handle on the traceback line you are interested the object to which the method was called upon can be retrieved using !cts![x].receiver. And, the arguments for that method is !cts![x].arguments.

Debugging Framework & Databus

Do you need to figure out what is going on within a framework or application?

Reporting Bad Performing Consumers

Compile the following in and set your time threshold in seconds. You can use -1 to report everything going on… Once you determine your bad performer, look at sw_databus_data_available() on that consumer.

Service Providers

Do you need to know what service providers exist? A service provider is a simple way of getting to common plug-ins like maps (aka map_plugin). To get the list you can do the following.

Method Table

The exemplar.method_table gives you the details behind the inheritance of exemplars that you can use.

Find all Children

Here is an example of finding all exemplars that inherit from vtk!qa_script who has type_of_input set to :geometries

System Resources & Messages

  • smallworld_product.report_resource_loading? « _true
  • message_handler.trace_level « 3

Threads & Thread Management

There is a thread manager in the 4.x core development tools application. However sometimes it cannot be brought up, so you need to access and kill a thread on the Magik prompt…

Getting List of Threads

!t << rope.new_from_iter(system,:known_threads|()|)

Sending Error to Thread

Using a thread from above, you can run this to send an error to the thread. This is good because it will throw a traceback so you can see where things are getting stuck…

!t[5].condition_interrupt(:error)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License