===== Debugging =====

Wherein we give away trade secrets of the [|] guild.

Sometimes you want to know why a particular message occurred in the JAS instrumentation or log. 

For this example, let us assume that we want to know what method (code) writes this string to the Air Plan Target Weapon Failures instrument: 
'No platform SCLs are effective against remaining resources in target BLUE_AIRPLANE in weather band 6'

There are two ways to find strings of text in JAS -- brute force and finesse.

==== Brute Force ====

The brute force approach simply searches all the code in the current image for a string, and then shows a list of the methods that contain that string. 

{{:jas:findstring.jpg|}}

Some search tips:
  * search for a string that does not occur too often
  * strings such as 'type' or 'value' will return large results
  * check the Case Sensitive box if you are sure of the capitalization
  * search for as small as string as possible; longer string take longer
  * search for parts of a word or phrase 

Here we searched for 'emaining resourc'; the search ran in under 3 minutes on my standalone JAS installation, but it could run two or three times as long if your ENVY library is on a server machine. The search returned three methods. If we cannot tell which method wrote the message, the next step would be to set a [[jas:breakPoints|break point]] in all three methods and run the sim.

==== Finesse ====

The finesse approach works because we know that the string we are looking for is in the instrument Air Plan Target Weapon Failures, so what we will do is find all the methods that reference the class of that instrument, JwiAirPlanTgtWpnFailuresV01. 

In the Application Manager, find JwiAirPlanTgtWpnFailuresV01, click it once to highlight it, the select 'Browse -> References' to see all the methods that reference (call) that instrument class.

{{:jas:browsereferences.jpg|}}

We get nine results for this query -- more than the brute force approach, but here we know that all these methods call the Air Plan Target Weapon Failures instrument. Now it is a matter of examining each of these nine methods, browsing senders and such, until we find where the string was written.