|
25 | 25 |
|
26 | 26 | package com.sun.btrace.runtime; |
27 | 27 |
|
| 28 | +import com.sun.btrace.AnyType; |
28 | 29 | import java.util.List; |
29 | 30 | import java.util.ArrayList; |
30 | 31 | import java.util.Set; |
@@ -257,7 +258,7 @@ private MethodVisitor instrumentorFor( |
257 | 258 |
|
258 | 259 | private MethodVisitor instrumentorFor( |
259 | 260 | final OnMethod om, MethodVisitor mv, final LocalVariablesSorter lvs, |
260 | | - final int[] tsIndex, int access, String name, String desc) { |
| 261 | + final int[] tsIndex, int access, String name, final String desc) { |
261 | 262 | final Location loc = om.getLocation(); |
262 | 263 | final Where where = loc.getWhere(); |
263 | 264 | final Type[] actionArgTypes = Type.getArgumentTypes(om.getTargetDescriptor()); |
@@ -415,13 +416,24 @@ protected void onAfterArrayStore(int opcode) { |
415 | 416 | private int returnVarIndex = -1; |
416 | 417 | int[] backupArgsIndexes; |
417 | 418 |
|
418 | | - private void injectBtrace(ValidationResult vr, final String method, final Type returnType) { |
| 419 | + private void injectBtrace(ValidationResult vr, final String method, final Type[] callArgTypes, final Type returnType) { |
419 | 420 | ArgumentProvider[] actionArgs = new ArgumentProvider[actionArgTypes.length + 6]; |
420 | 421 | for(int i=0;i<vr.getArgCnt();i++) { |
421 | 422 | int index = vr.getArgIdx(i); |
422 | 423 | Type t = actionArgTypes[index]; |
423 | 424 | if (TypeUtils.isAnyTypeArray(t)) { |
424 | | - actionArgs[i] = new AnyTypeArgProvider(i, backupArgsIndexes[i+1]); |
| 425 | + if (i < backupArgsIndexes.length - 1) { |
| 426 | + actionArgs[i] = new AnyTypeArgProvider(index, backupArgsIndexes[i+1], callArgTypes); |
| 427 | + } else { |
| 428 | + actionArgs[i] = new ArgumentProvider(index) { |
| 429 | + |
| 430 | + @Override |
| 431 | + protected void doProvide() { |
| 432 | + push(0); |
| 433 | + visitTypeInsn(ANEWARRAY, TypeUtils.objectType.getInternalName()); |
| 434 | + } |
| 435 | + }; |
| 436 | + } |
425 | 437 | } else { |
426 | 438 | actionArgs[i] = new LocalVarArgProvider(index, actionArgTypes[index], backupArgsIndexes[i+1]);; |
427 | 439 | } |
@@ -472,7 +484,7 @@ && typeMatches(loc.getType(), desc)) { |
472 | 484 | // will store the call args into local variables |
473 | 485 | backupArgsIndexes = backupStack(lvs, Type.getArgumentTypes(desc), isStaticCall); |
474 | 486 | if (where == Where.BEFORE) { |
475 | | - injectBtrace(vr, method, Type.getReturnType(desc)); |
| 487 | + injectBtrace(vr, method, Type.getArgumentTypes(desc), Type.getReturnType(desc)); |
476 | 488 | } |
477 | 489 | // put the call args back on stack so the method call can find them |
478 | 490 | restoreStack(backupArgsIndexes, Type.getArgumentTypes(desc), isStaticCall); |
@@ -509,7 +521,7 @@ && typeMatches(loc.getType(), desc)) { |
509 | 521 | returnVarIndex = index; |
510 | 522 | } |
511 | 523 | // will also retrieve the call args and the return value from the backup variables |
512 | | - injectBtrace(vr, method, returnType); |
| 524 | + injectBtrace(vr, method, calledMethodArgs, returnType); |
513 | 525 | if (withReturn) { |
514 | 526 | loadLocal(returnType, returnVarIndex); // restore the return value |
515 | 527 | } |
|
0 commit comments