/* find statement number, given address, for PL/I symbolic debugger returns 0 if address is lower than first statement of module, returns -max if address is past last statement of module, where max is number of last statement of module */ stmtnumber: procedure(code_address, module_prolog) returns(fixed bin(15)); dcl code_address fixed bin(15), /*address in user task*/ module_prolog fixed bin(15); /*address in user task of external procedure the statement is in*/ %include 'knldef.pli'; %include 'rundef.pli'; dcl unsigned entry(fixed bin(15)) returns(fixed bin(31)); dcl dostmn pointer external, (ostmno, ostmnp, ostmnt, ostmnw) fixed bin(15) external; /*defined in debasm*/ dcl stmt_number fixed bin(15), stmt_table_address fixed bin(15), module_end fixed bin(15); /**************************************************************************************************************/ if unsigned(code_address) < unsigned(module_prolog) then return(0); stmt_table_address = getword(module_prolog+prolog_static) + getword(module_prolog+prolog_stmtoffset); /*must get before fill - getword uses packet*/ call fillpacket(dostmn); packet(ostmnt) = stmt_table_address; packet(ostmno) = code_address - module_prolog; call sendknl; call rcvknl; stmt_number = (packet(ostmnp) - stmt_table_address)/2; /*ostmnp has addr of statement number table entry*/ if packet(ostmnw) ^= -1 then return(stmt_number); /*ostmnw has contents of statement number table entry (offset)*/ /*hit end of table - see if in last statement or beyond. last statement is always an END, thus at most 4 bytes long (JSR .EXIT or JSR .STOP)*/ module_end = module_prolog + getword(packet(ostmnp)-2) + 4; /*address of word past last statement*/ if unsigned(code_address) <= unsigned(module_end) then return(stmt_number); else return(-stmt_number); end;