c_func logfile include
- Posted by Brent Hugh <bhugh at CSTP.UMKC.EDU> Aug 04, 1999
- 528 views
Expanding on David's idea he posted earlier, I hacked this little thing together, to log c_func and c_proc calls. If some ambitious soul would translate the windows message declarations into a nice sequence (ie, instead of WM_ACTIVATEAPP=#1C we would have msg[#1C]="WM_ACTIVATEAPP") we could print those out in the logfile, too, and then this would be a nice way to track windows messages. In the case of windows functions, the first parameter is usually the window handle and the second is iMsg--the message number. The rest are parameters for that particular message. --Brent --cfunclog.e -- --logs all c_func and c_proc calls to "trace.txt" -- --to use this: -- 1. replace all calls to "c_func" with "log_c_func" -- 2. replace all calls to "c_proc" with "log_c_proc" -- 3. right after your call to define_c_func: -- handle = define_c_func(dll, name, args, result) -- insert this line -- log_funcname(dll, name, handle) -- 4. right after your call to define_c_proc: -- handle = define_c_proc(dll, name, args, result) -- insert that same line again -- log_funcname(dll, name, handle) -- 5. include cfunclog.e in your program -- 6. turn logging on/off with variable logC (or just set it here on or off) -- 7. numeric variables are printed twice in a row: once decimal, once hex --First you get a list of all functions/procedures defined, then a list of all --function/procedure calls and the parameters passed. --A new logfile is created for each program run (ie, the previous logfile is deleted) --Brent Hugh atom traceFile global atom logC logC=1 --logging on=1, off=0 sequence functionname functionname=repeat("",2000) --handles up to 2000 functions traceFile = open("trace.txt", "w")--make a new file each session close(traceFile) global function log_c_func( atom i, sequence s ) if logC then traceFile = open("trace.txt", "a") printf( traceFile, "function %s %d %x, params ", {functionname[i],i,i} ) for x =1 to length(s) do printf(traceFile, "%d %x ", {s[x], s[x]}) end for puts(traceFile, "\n") close(traceFile) --open & close file each time so as to not lose data on gpf end if return c_func( i, s ) end function global procedure log_c_proc( atom i, sequence s ) if logC then traceFile = open("trace.txt", "a") printf( traceFile, "function %d %x, params ", {i,i} ) for x =1 to length(s) do printf(traceFile, "%d %x ", {s[x], s[x]}) end for puts(traceFile, "\n") close(traceFile) end if c_proc( i, s ) end procedure global procedure log_funcname( atom dll, sequence name, atom handle ) if logC then if handle> 0 then functionname[handle]=name end if traceFile = open("trace.txt", "a") printf( traceFile, "%d %x %s %d %x\n", {dll, dll, name, handle, handle} ) close(traceFile) --open & close each time so as to not lose data on gpf end if end procedure ++++++++++++++++++++ Brent Hugh / bhugh at cstp.umkc.edu ++++++++++++++++++++ ++++++++ University of Missouri-Kansas City, Conservatory of Music +++++++ ++ Sheet Music/Recordings: http://www.sunflower.org/~bhugh/pathetic.spm ++ + Internet Piano Concert: http://cctr.umkc.edu/userx/bhugh/recital.html + ++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++