############################################################################ # # File: minilocus.icn # # Subject: Program to trace execution locus # # Author: Ralph E. Griswold, modified by Clinton Jeffery # # Date: September 1, 1992 # ########################################################################### # # This program traces the locus of program execution. # ############################################################################ # # Links: evinit # ############################################################################ # # Requires: MT Icon and event monitoring # ############################################################################ $include "evdefs.icn" link evinit procedure main(args) local Width, Height, x, y, Context, value local progarray, Color local mask &window := open("win","g","canvas=hidden","width=20","height=20") EvInit(args) | stop("*** cannot load program to monitor") Height := WDefault("miniloc","Height") | 500 Width := WDefault("miniloc","Width") | 80 &window := open("locus", "g", "bg=white", "width=" || Width, "resize=on", "height=" || Height) | stop("*** cannot open X window") Color := [] every put(Color, Clone(&window, "fg="||("gray"|"blue"|"green"|"yellow"|"orange"|"red"))) progarray := table(0) mask := cset(E_Loc) while EvGet(mask) do { y := line(&eventvalue) x := column(&eventvalue) value := progarray[&eventvalue] +:= 1 value := integer(log(value, 6)) + 1 Context := Color[*Color >= value | *Color] FillRectangle(Context, x-1, y-1,2,2) if y > WAttrib("height") then FillRectangle(0, WAttrib("height")-4,80,4) } Event() end procedure line(loc) return iand(loc, 65535) end procedure column(loc) return ishift(loc, -21) end