[Home] [Help]
PACKAGE BODY: APPS.CZ_FCE_COMPILE_DEBUG
Source
1 PACKAGE BODY CZ_FCE_COMPILE_DEBUG AS
2 /* $Header: czfcedbb.pls 120.11 2008/04/09 20:23:43 asiaston ship $ */
3 ---------------------------------------------------------------------------------------
4 t_methoddescriptors cz_fce_compile.type_varchar4000_table;
5 v_message_id PLS_INTEGER;
6 ---------------------------------------------------------------------------------------
7 FUNCTION get_constant_value( ConstantPool IN BLOB, p_ptr IN PLS_INTEGER ) RETURN VARCHAR2 IS
8
9 i_ptr PLS_INTEGER := p_ptr + 1;
10 i_len PLS_INTEGER;
11 -------------------------------------------
12 FUNCTION get_byte ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
13 BEGIN
14
15 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(ConstantPool, 1, p_ptr));
16
17 END get_byte;
18 -------------------------------------------
19 FUNCTION get_word ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
20 BEGIN
21
22 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(ConstantPool, 2, p_ptr));
23
24 END get_word;
25 -------------------------------------------
26 FUNCTION get_integer ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
27 BEGIN
28
29 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(ConstantPool, 4, p_ptr));
30
31 END get_integer;
32 -------------------------------------------
33 BEGIN
34
35 CASE DBMS_LOB.SUBSTR (ConstantPool, 1, i_ptr)
36
37 WHEN cz_fce_compile.const_string_tag THEN
38
39 i_len := get_word (i_ptr + 1);
40
41 RETURN UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(ConstantPool, i_len, i_ptr + 3));
42
43 WHEN cz_fce_compile.const_integer_tag THEN
44
45 RETURN get_integer (i_ptr + 1);
46
47 WHEN cz_fce_compile.const_float_tag THEN
48
49 RETURN UTL_RAW.CAST_TO_BINARY_FLOAT(DBMS_LOB.SUBSTR(ConstantPool, 4, i_ptr + 1));
50
51 WHEN cz_fce_compile.const_long_tag THEN
52
53 RETURN get_integer (i_ptr + 1) || ':' || get_integer (i_ptr + 5);
54
55 WHEN cz_fce_compile.const_double_tag THEN
56
57 RETURN UTL_RAW.CAST_TO_BINARY_DOUBLE(DBMS_LOB.SUBSTR(ConstantPool, 8, i_ptr + 1));
58
59 WHEN cz_fce_compile.const_method_tag THEN
60
61 RETURN t_methoddescriptors ( get_byte (i_ptr + 1));
62
63 WHEN cz_fce_compile.const_date_tag THEN
64
65 RETURN get_integer (i_ptr + 1) || ':' || get_integer (i_ptr + 5);
66 END CASE;
67 END get_constant_value;
68 ---------------------------------------------------------------------------------------
69 PROCEDURE dump_code_memory( CodeMemory IN BLOB, ConstantPool IN BLOB, p_run_id IN NUMBER ) IS
70
71 i_ptr PLS_INTEGER := 1;
72
73 -------------------------------------------
74 PROCEDURE debug ( p_message IN VARCHAR2) IS
75 BEGIN
76
77 cz_fce_compile_utils.report_info (
78 p_message => p_message
79 , p_run_id => - p_run_id
80 , p_model_id => null
81 , p_ps_node_id => null
82 , p_rule_id => null
83 , p_error_stack => null
84 , p_message_id => v_message_id
85 );
86
87 v_message_id := v_message_id + 1;
88
89 END debug;
90 -------------------------------------------
91 FUNCTION get_byte ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
92 BEGIN
93
94 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(CodeMemory, 1, p_ptr));
95
96 END get_byte;
97 -------------------------------------------
98 FUNCTION get_word ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
99 BEGIN
100
101 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(CodeMemory, 2, p_ptr));
102
103 END get_word;
104 -------------------------------------------
105 BEGIN
106
107 debug('------------------------');
108 debug('Code Memory: ' || NVL ( DBMS_LOB.GETLENGTH (CodeMemory), 0) || ' bytes');
109 debug('------------------------');
110
111 WHILE (i_ptr <= DBMS_LOB.GETLENGTH (CodeMemory)) LOOP
112
113 CASE DBMS_LOB.SUBSTR (CodeMemory, 1, i_ptr)
114
115 WHEN cz_fce_compile.h_inst('nop') THEN
116
117 debug('nop');
118 i_ptr := i_ptr + 1;
119
120 WHEN cz_fce_compile.h_inst('iconst_m1') THEN
121
122 debug('iconst_m1 -- push -1');
123 i_ptr := i_ptr + 1;
124
125 WHEN cz_fce_compile.h_inst('iconst_0') THEN
126
127 debug('iconst_0 -- push 0');
128 i_ptr := i_ptr + 1;
129
130 WHEN cz_fce_compile.h_inst('iconst_1') THEN
131
132 debug('iconst_1 -- push 1');
133 i_ptr := i_ptr + 1;
134
135 WHEN cz_fce_compile.h_inst('iconst_2') THEN
136
137 debug('iconst_2 -- push 2');
138 i_ptr := i_ptr + 1;
139
140 WHEN cz_fce_compile.h_inst('iconst_3') THEN
141
142 debug('iconst_3 -- push 3');
143 i_ptr := i_ptr + 1;
144
145 WHEN cz_fce_compile.h_inst('iconst_4') THEN
146
147 debug('iconst_4 -- push 4');
148 i_ptr := i_ptr + 1;
149
150 WHEN cz_fce_compile.h_inst('iconst_5') THEN
151
152 debug('iconst_5 -- push 5');
153 i_ptr := i_ptr + 1;
154
155 WHEN cz_fce_compile.h_inst('bipush') THEN
156
157 debug('bipush ' || get_byte(i_ptr + 1) || ' -- push byte value');
158 i_ptr := i_ptr + 2;
159
160 WHEN cz_fce_compile.h_inst('sipush') THEN
161
162 debug('sipush ' || get_word(i_ptr + 1) || ' -- push word value');
163 i_ptr := i_ptr + 3;
164
165 WHEN cz_fce_compile.h_inst('ldc') THEN
166
167 debug('ldc ' || get_byte(i_ptr + 1) || ' -- push value ''' || get_constant_value(ConstantPool, get_byte(i_ptr + 1)) || '''');
168 i_ptr := i_ptr + 2;
169
170 WHEN cz_fce_compile.h_inst('ldc_w') THEN
171
172 debug('ldc_w ' || get_word(i_ptr + 1) || ' -- push value ''' || get_constant_value(ConstantPool, get_word(i_ptr + 1)) || '''');
173 i_ptr := i_ptr + 3;
174
175 WHEN cz_fce_compile.h_inst('aload') THEN
176
177 debug('aload ' || get_byte(i_ptr + 1) || ' -- push from local variable #' || get_byte(i_ptr + 1));
178 i_ptr := i_ptr + 2;
179
180 WHEN cz_fce_compile.h_inst('aload_0') THEN
181
182 debug('aload_0 -- push from local variable #0');
183 i_ptr := i_ptr + 1;
184
185 WHEN cz_fce_compile.h_inst('aload_1') THEN
186
187 debug('aload_1 -- push from local variable #1');
188 i_ptr := i_ptr + 1;
189
190 WHEN cz_fce_compile.h_inst('aload_2') THEN
191
192 debug('aload_2 -- push from local variable #2');
193 i_ptr := i_ptr + 1;
194
195 WHEN cz_fce_compile.h_inst('aload_3') THEN
196
197 debug('aload_3 -- push from local variable #3');
198 i_ptr := i_ptr + 1;
199
200 WHEN cz_fce_compile.h_inst('aaload') THEN
201
202 debug('aaload');
203 i_ptr := i_ptr + 1;
204
205 WHEN cz_fce_compile.h_inst('astore') THEN
206
207 debug('astore ' || get_byte(i_ptr + 1) || ' -- pop into local variable #' || get_byte(i_ptr + 1));
208 i_ptr := i_ptr + 2;
209
210 WHEN cz_fce_compile.h_inst('astore_0') THEN
211
212 debug('astore_0 -- pop into local variable #0');
213 i_ptr := i_ptr + 1;
214
215 WHEN cz_fce_compile.h_inst('astore_1') THEN
216
217 debug('astore_1 -- pop into local variable #1');
218 i_ptr := i_ptr + 1;
219
220 WHEN cz_fce_compile.h_inst('astore_2') THEN
221
222 debug('astore_2 -- pop into local variable #2');
223 i_ptr := i_ptr + 1;
224
225 WHEN cz_fce_compile.h_inst('astore_3') THEN
226
227 debug('astore_3 -- pop into local variable #3');
228 i_ptr := i_ptr + 1;
229
230 WHEN cz_fce_compile.h_inst('copyto') THEN
231
232 debug('copyto ' || get_byte(i_ptr + 1) || ' -- copy into local variable #' || get_byte(i_ptr + 1));
233 i_ptr := i_ptr + 2;
234
235 WHEN cz_fce_compile.h_inst('copyto_0') THEN
236
237 debug('copyto_0 -- copy into local variable #0');
238 i_ptr := i_ptr + 1;
239
240 WHEN cz_fce_compile.h_inst('copyto_1') THEN
241
242 debug('copyto_1 -- copy into local variable #1');
243 i_ptr := i_ptr + 1;
244
245 WHEN cz_fce_compile.h_inst('copyto_2') THEN
246
247 debug('copyto_2 -- copy into local variable #2');
248 i_ptr := i_ptr + 1;
249
250 WHEN cz_fce_compile.h_inst('copyto_3') THEN
251
252 debug('copyto_3 -- copy into local variable #3');
253 i_ptr := i_ptr + 1;
254
255 WHEN cz_fce_compile.h_inst('aastore') THEN
256
257 debug('aastore');
258 i_ptr := i_ptr + 1;
259
260 WHEN cz_fce_compile.h_inst('pop') THEN
261
262 debug('pop');
263 i_ptr := i_ptr + 1;
264
265 WHEN cz_fce_compile.h_inst('mpop') THEN
266
267 debug('mpop');
268 i_ptr := i_ptr + 1;
269
270 WHEN cz_fce_compile.h_inst('dup') THEN
271
272 debug('dup -- duplicate value at top of stack');
273 i_ptr := i_ptr + 1;
274
275 WHEN cz_fce_compile.h_inst('swap') THEN
276
277 debug('swap');
278 i_ptr := i_ptr + 1;
279
280 WHEN cz_fce_compile.h_inst('ret') THEN
281
282 debug('ret');
283 i_ptr := i_ptr + 1;
284
285 WHEN cz_fce_compile.h_inst('areturn') THEN
286
287 debug('areturn');
288 i_ptr := i_ptr + 1;
289
290 WHEN cz_fce_compile.h_inst('invokevirtual') THEN
291
292 debug('invokevirtual ' || get_word(i_ptr + 1) || ' -- call ' || get_constant_value(ConstantPool, get_word(i_ptr + 1)));
293 i_ptr := i_ptr + 3;
294
295 WHEN cz_fce_compile.h_inst('invokestatic') THEN
296
297 debug('invokestatic ' || get_word(i_ptr + 1) || ' -- call ' || get_constant_value(ConstantPool, get_word(i_ptr + 1)));
298 i_ptr := i_ptr + 3;
299
300 WHEN cz_fce_compile.h_inst('newarray') THEN
301
302 debug('newarray ' || get_byte(i_ptr + 1));
303 i_ptr := i_ptr + 2;
304
305 WHEN cz_fce_compile.h_inst('multinewarray') THEN
306
307 debug('multinewarray ' || get_byte(i_ptr + 1) || get_byte(i_ptr + 2));
308 i_ptr := i_ptr + 3;
309
310 WHEN cz_fce_compile.h_inst('haload_0') THEN
311
312 debug('haload_0 -- pop key, push value[key]');
313 i_ptr := i_ptr + 1;
314
315 WHEN cz_fce_compile.h_inst('hastore_0') THEN
316
317 debug('hastore_0 -- pop key, pop value, hash value by key');
318 i_ptr := i_ptr + 1;
319
320 WHEN cz_fce_compile.h_inst('haload_1') THEN
321
322 debug('haload_1 -- pop key, push value[key]');
323 i_ptr := i_ptr + 1;
324
325 WHEN cz_fce_compile.h_inst('hastore_1') THEN
326
327 debug('hastore_1 -- pop key, pop value, hash value by key');
328 i_ptr := i_ptr + 1;
329
330 WHEN cz_fce_compile.h_inst('haload_2') THEN
331
332 debug('haload_2 -- pop id2, pop id1, push from [DIO]');
333 i_ptr := i_ptr + 1;
334
335 WHEN cz_fce_compile.h_inst('bulkaastore') THEN
336
337 debug('bulkaastore');
338 i_ptr := i_ptr + 1;
339
340 WHEN cz_fce_compile.h_inst('comment') THEN
344
341
342 debug('// ' || get_constant_value ( ConstantPool, get_word ( i_ptr + 1 )));
343 i_ptr := i_ptr + 3;
345 WHEN cz_fce_compile.h_inst('pushtrue') THEN
346
347 debug('pushtrue');
348 i_ptr := i_ptr + 1;
349
350 WHEN cz_fce_compile.h_inst('pushfalse') THEN
351
352 debug('pushfalse');
353 i_ptr := i_ptr + 1;
354
355 WHEN cz_fce_compile.h_inst('pushmath') THEN
356
357 debug('pushmath ' || get_byte(i_ptr + 1));
358 i_ptr := i_ptr + 2;
359
360 WHEN cz_fce_compile.h_inst('aload_w') THEN
361
362 debug('aload_w ' || get_word(i_ptr + 1) || ' -- push (wide) from variable #' || get_word(i_ptr + 1));
363 i_ptr := i_ptr + 3;
364
365 WHEN cz_fce_compile.h_inst('astore_w') THEN
366
367 debug('astore_w ' || get_word(i_ptr + 1) || ' -- pop (wide) into variable #' || get_word(i_ptr + 1));
368 i_ptr := i_ptr + 3;
369
370 WHEN cz_fce_compile.h_inst('copyto_w') THEN
371
372 debug('copyto_w ' || get_word(i_ptr + 1) || ' -- copy (wide) into variable #' || get_word(i_ptr + 1));
373 i_ptr := i_ptr + 3;
374
375 END CASE;
376 END LOOP;
377 END dump_code_memory;
378 ---------------------------------------------------------------------------------------
379 PROCEDURE dump_constant_pool( ConstantPool IN BLOB, p_run_id IN NUMBER ) IS
380
381 i_ptr PLS_INTEGER := 1;
382 i_len PLS_INTEGER;
383
384 -------------------------------------------
385 PROCEDURE debug ( p_message IN VARCHAR2) IS
386 BEGIN
387
388 cz_fce_compile_utils.report_info (
389 p_message => p_message
390 , p_run_id => - p_run_id
391 , p_model_id => null
392 , p_ps_node_id => null
393 , p_rule_id => null
394 , p_error_stack => null
395 , p_message_id => v_message_id
396 );
397
398 v_message_id := v_message_id + 1;
399
400 END debug;
401 -------------------------------------------
402 FUNCTION get_byte ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
403 BEGIN
404
405 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(ConstantPool, 1, p_ptr));
406
407 END get_byte;
408 -------------------------------------------
409 FUNCTION get_word ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
410 BEGIN
411
412 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(ConstantPool, 2, p_ptr));
413
414 END get_word;
415 -------------------------------------------
416 FUNCTION get_integer ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
417 BEGIN
418
419 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR(ConstantPool, 4, p_ptr));
420
421 END get_integer;
422 -------------------------------------------
423 BEGIN
424
425 debug('--------------------------');
426 debug('Constant Pool: ' || NVL ( DBMS_LOB.GETLENGTH (ConstantPool), 0) || ' bytes');
427 debug('--------------------------');
428
429 WHILE (i_ptr <= DBMS_LOB.GETLENGTH (ConstantPool)) LOOP
430
431 CASE DBMS_LOB.SUBSTR (ConstantPool, 1, i_ptr)
432
433 WHEN cz_fce_compile.const_string_tag THEN
434
435 i_len := get_word (i_ptr + 1);
436 debug('string ' || TO_CHAR(i_ptr - 1 , 'FM09999999') || ': ' ||
437 UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(ConstantPool, i_len, i_ptr + 3)));
438 i_ptr := i_ptr + i_len + 3;
439
440 WHEN cz_fce_compile.const_integer_tag THEN
441
442 debug('integer ' || TO_CHAR(i_ptr - 1, 'FM09999999') || ': ' || get_integer (i_ptr + 1));
443 i_ptr := i_ptr + 5;
444
445 WHEN cz_fce_compile.const_float_tag THEN
446
447 debug('float ' || TO_CHAR(i_ptr - 1, 'FM09999999') || ': ' ||
448 UTL_RAW.CAST_TO_BINARY_FLOAT(DBMS_LOB.SUBSTR(ConstantPool, 4, i_ptr + 1)));
449 i_ptr := i_ptr + 5;
450
451 WHEN cz_fce_compile.const_long_tag THEN
452
453 debug('long ' || TO_CHAR(i_ptr - 1, 'FM09999999') || ': ' ||
454 get_integer (i_ptr + 1) || ':' || get_integer (i_ptr + 5));
455 i_ptr := i_ptr + 9;
456
457 WHEN cz_fce_compile.const_double_tag THEN
458
459 debug('double ' || TO_CHAR(i_ptr - 1, 'FM09999999') || ': ' ||
460 UTL_RAW.CAST_TO_BINARY_DOUBLE(DBMS_LOB.SUBSTR(ConstantPool, 8, i_ptr + 1)));
461 i_ptr := i_ptr + 9;
462
463 WHEN cz_fce_compile.const_method_tag THEN
464
465 debug('method ' || TO_CHAR(i_ptr - 1, 'FM09999999') || ': ' || t_methoddescriptors ( get_byte (i_ptr + 1)));
466 i_ptr := i_ptr + 2;
467
468 WHEN cz_fce_compile.const_date_tag THEN
469
470 debug('date ' || TO_CHAR(i_ptr - 1, 'FM09999999') || ': ' ||
471 get_integer (i_ptr + 1) || ':' || get_integer (i_ptr + 5));
472 i_ptr := i_ptr + 9;
473
474 END CASE;
475 END LOOP;
476 END dump_constant_pool;
477 ---------------------------------------------------------------------------------------
478 PROCEDURE dump_logic ( p_fce_file IN BLOB, p_run_id IN NUMBER ) IS
479
480 l_constant_pool BLOB;
481 l_code_memory BLOB;
482
483 l_size PLS_INTEGER;
484 l_tail PLS_INTEGER;
485
489 RETURN UTL_RAW.CAST_TO_BINARY_INTEGER(DBMS_LOB.SUBSTR( p_fce_file, 4, p_ptr));
486 FUNCTION get_integer ( p_ptr IN PLS_INTEGER ) RETURN BINARY_INTEGER IS
487 BEGIN
488
490
491 END get_integer;
492
493 BEGIN
494
495 l_size := get_integer ( DBMS_LOB.GETLENGTH ( p_fce_file ) - 7 );
496 l_tail := DBMS_LOB.GETLENGTH ( p_fce_file ) - 8 - l_size;
497
498 IF ( l_size > 0 ) THEN l_constant_pool := DBMS_LOB.SUBSTR ( p_fce_file, l_size, 1 ); END IF;
499 IF ( l_tail > 0 ) THEN l_code_memory := DBMS_LOB.SUBSTR ( p_fce_file, l_tail, l_size + 1); END IF;
500
501 dump_constant_pool( l_constant_pool, p_run_id );
502 dump_code_memory( l_code_memory, l_constant_pool, p_run_id);
503
504 END dump_logic;
505 ---------------------------------------------------------------------------------------
506 PROCEDURE dump_logic ( p_model_id IN NUMBER, p_run_id IN NUMBER ) IS
507
508 PROCEDURE debug ( p_message IN VARCHAR2) IS
509 BEGIN
510
511 cz_fce_compile_utils.report_info (
512 p_message => p_message
513 , p_run_id => - p_run_id
514 , p_model_id => null
515 , p_ps_node_id => null
516 , p_rule_id => null
517 , p_error_stack => null
518 , p_message_id => v_message_id
519 );
520
521 v_message_id := v_message_id + 1;
522
523 END debug;
524
525 BEGIN
526
527 v_message_id := 1;
528
529 FOR file IN (SELECT component_id, fce_file_type, segment_nbr, fce_file FROM cz_fce_files
530 WHERE deleted_flag = '0'
531 AND component_id IN
532 (SELECT component_id FROM cz_model_ref_expls WHERE deleted_flag = '0'
533 AND model_id = p_model_id)
534 ORDER BY component_id, fce_file_type, segment_nbr ) LOOP
535
536 debug ( '>');
537 debug ('Component: ' || file.component_id || ', Phase: ' || file.fce_file_type || ', Segment: ' || file.segment_nbr );
538 dump_logic ( file.fce_file, p_run_id );
539
540 END LOOP;
541 END dump_logic;
542 ---------------------------------------------------------------------------------------
543 --Populate the method descriptor table from the seed data table.
544
545 PROCEDURE populate_display_data IS
546
547 l_key VARCHAR2(4000);
548
549 BEGIN
550
551 l_key := cz_fce_compile.h_methoddescriptors.FIRST;
552
553 WHILE ( l_key IS NOT NULL ) LOOP
554
555 t_methoddescriptors ( cz_fce_compile.h_methoddescriptors ( l_key )) := l_key;
556 l_key := cz_fce_compile.h_methoddescriptors.NEXT ( l_key );
557
558 END LOOP;
559 END populate_display_data;
560 ---------------------------------------------------------------------------------------
561 BEGIN
562
563 populate_display_data;
564
565 END;