|
Here is an MI subroutine that dereferences ILE pointers. This is useful because 'MATPTR' on a procedure or suspend pointer will return the module and procedure numbers, but not the module and procedure names. Here is how to convert 'MATPTR' module and procedure numbers into module and procedure names. The subroutine input is '?ILEptr'. The subroutine output is 'ModName' and 'ProcName'. You could use this after MATINVS returns an array of suspend pointers, to get the names of procedures on the call stack. dcl ptr ?ILEptr auto; dcl dd ModName auto char(10); dcl dd ProcName auto char(256); dcl spcptr ?Mat1 auto init(Mat1); dcl dd Mat1 auto char(48); dcl dd MatSize1 def(Mat1) bin(4); dcl dd PtrType def(Mat1) pos(9); dcl dd ModuleNo def(Mat1) pos(17) bin(4); dcl dd ProcNo def(Mat1) pos(21) bin(4); dcl sysptr ?Program def(Mat1) pos(33); dcl spcptr ?Mat2 auto init(Mat2); dcl dd Mat2 auto char(64); dcl dd MatSize2 def(Mat2) bin(4); dcl dd TotalReqs def(Mat2) pos(9) bin(4); dcl spcptr ?Component def(Mat2) pos(17); dcl dd PgmOptions def(Mat2) pos(33) char(4); dcl dd ModOptions def(Mat2) pos(37) char(4); dcl dd TargetMod def(Mat2) pos(41) bin(4); dcl dd Estimate def(Mat2) pos(49) bin(4); dcl dd Estimate2 def(Mat2) pos(53) bin(4); dcl dd Provided bas(?Component) bin(4); dcl mspptr ?M; dcl dd Msize bas(?M) bin(4); dcl dd M bas(?M) char(32767); dcl dd List(32767) bas(?M) pos(17) char(80); dcl dd Name(32767) def(List) pos(31) char(10) aeo(80); dcl mspptr ?StringDir; dcl dd Next bas(?StringDir) bin(4); dcl mspptr ?ProcDefn; dcl dd Defn(32767) bas(?ProcDefn) pos(49) char(64); dcl dd Proc(32767) def(Defn) pos(5) bin(4) aeo(64); dcl insptr ?Return auto; entry GetNames int; -- start subroutine here cpybrep ModName, " "; -- clear previous stuff cpybrep ProcName, " "; -- clear previous stuff cpynv MatSize1, 48; -- prepare receiver size matptr ?Mat1, ?ILEptr; -- get pointer info cmpbla(b) PtrType, X"06" / lo(?Return); -- ignore if not ILE cmpbla(b) PtrType, X"08" / hi(?Return); -- ignore if not ILE cpybrep Mat2, X"00"; -- clear previous stuff cpynv MatSize2, 48; -- prepare receiver size cpynv TotalReqs, 1; -- only get one request setspp ?Component, Estimate; -- point to receiver cpybla PgmOptions, X"08000000"; -- request list of modules cpynv Estimate, 8; -- prepare receiver size matbpgm ?Mat2, ?Program; -- get storage estimate modasa ?Component, Estimate2; -- get some work space cpynv Provided, Estimate2; -- prepare receiver size matbpgm ?Mat2, ?Program; -- get list of modules addspp ?M, ?Component, 48; -- point to module list cpybla ModName, Name(ModuleNo); -- extract module name neg(s) Estimate2; -- make it negative modasa ?Component, Estimate2; -- free the work space cpybrep Mat2, X"00"; -- clear previous stuff cpynv MatSize2, 48; -- prepare receiver size cpynv TotalReqs, 1; -- only get one request setspp ?Component, Estimate; -- point to receiver cpybla ModOptions, X"20200000"; -- string dir & procedures cpynv TargetMod, ModuleNo; -- request this module cpynv Estimate, 8; -- prepare receiver size matbpgm ?Mat2, ?Program; -- get storage estimate modasa ?Component, Estimate2; -- get some work space cpynv Provided, Estimate2; -- prepare receiver size matbpgm ?Mat2, ?Program; -- get string dir & procs addspp ?StringDir, ?Component, 16; -- point to first component addspp ?ProcDefn, ?StringDir, Next; -- point to second component addspp ?StringDir, ?StringDir, 32; -- point to string directory addspp ?ProcDefn, ?ProcDefn, 32; -- point to procedure defns addspp ?M, ?StringDir, Proc(ProcNo); -- point to string dir item cpybla ProcName, M(5:ZL,Msize); -- copy procedure name neg(s) Estimate2; -- make it negative modasa ?Component, Estimate2; -- free the work space b ?Return; -- return to caller +--- | This is the MI Programmers Mailing List! | To submit a new message, send your mail to MI400@midrange.com. | To subscribe to this list send email to MI400-SUB@midrange.com. | To unsubscribe from this list send email to MI400-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: dr2@cssas400.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.