1 12 package org.eclipse.jdi.internal.spy; 13 14 15 import java.io.ByteArrayInputStream ; 16 import java.io.DataInputStream ; 17 import java.io.IOException ; 18 import java.io.OutputStream ; 19 import java.io.PrintStream ; 20 import java.io.UTFDataFormatException ; 21 import com.ibm.icu.text.MessageFormat; 22 import java.util.Arrays ; 23 24 28 public class VerbosePacketStream extends PrintStream { 29 30 public static final byte ARRAY_TAG = 91; public static final byte BYTE_TAG = 66; public static final byte CHAR_TAG = 67; public static final byte OBJECT_TAG = 76; public static final byte FLOAT_TAG = 70; public static final byte DOUBLE_TAG = 68; public static final byte INT_TAG = 73; public static final byte LONG_TAG = 74; public static final byte SHORT_TAG = 83; public static final byte VOID_TAG = 86; public static final byte BOOLEAN_TAG = 90; public static final byte STRING_TAG = 115; public static final byte THREAD_TAG = 116; public static final byte THREAD_GROUP_TAG = 103; public static final byte CLASS_LOADER_TAG = 108; public static final byte CLASS_OBJECT_TAG = 99; 48 49 public static final byte TYPE_TAG_CLASS = 1; public static final byte TYPE_TAG_INTERFACE = 2; public static final byte TYPE_TAG_ARRAY = 3; 53 54 public static final int JDWP_CLASS_STATUS_VERIFIED = 1; 55 public static final int JDWP_CLASS_STATUS_PREPARED = 2; 56 public static final int JDWP_CLASS_STATUS_INITIALIZED = 4; 57 public static final int JDWP_CLASS_STATUS_ERROR = 8; 58 59 60 public static final int ACC_PUBLIC= 0x0001; 61 public static final int ACC_PRIVATE= 0x0002; 62 public static final int ACC_PROTECTED= 0x0004; 63 public static final int ACC_STATIC= 0x0008; 64 public static final int ACC_FINAL= 0x0010; 65 public static final int ACC_SUPER= 0x0020; 66 public static final int ACC_VOLATILE= 0x0040; 67 public static final int ACC_TRANSIENT= 0x0080; 68 public static final int ACC_NATIVE= 0x0100; 69 public static final int ACC_INTERFACE= 0x0200; 70 public static final int ACC_ABSTRACT= 0x0400; 71 public static final int ACC_STRICT= 0x0800; 72 public static final int ACC_ENUM= 0x0100; 73 public static final int ACC_VARARGS= 0x0080; 74 public static final int ACC_BRIDGE= 0x0040; 75 public static final int ACC_SYNTHETIC= 0x1000; 76 public static final int ACC_SYNCHRONIZED=0x0020; 77 78 public static final int ACC_EXT_SYNTHETIC= 0xf0000000; 79 80 81 public static final int INVOKE_SINGLE_THREADED= 0x01; 82 public static final int INVOKE_NONVIRTUAL= 0x02; 83 84 85 public static final int THREAD_STATUS_ZOMBIE= 0; 86 public static final int THREAD_STATUS_RUNNING= 1; 87 public static final int THREAD_STATUS_SLEEPING= 2; 88 public static final int THREAD_STATUS_MONITOR= 3; 89 public static final int THREAD_STATUS_WAIT= 4; 90 91 92 public static final int EVENTKIND_SINGLE_STEP= 1; 93 public static final int EVENTKIND_BREAKPOINT= 2; 94 public static final int EVENTKIND_FRAME_POP= 3; 95 public static final int EVENTKIND_EXCEPTION= 4; 96 public static final int EVENTKIND_USER_DEFINED= 5; 97 public static final int EVENTKIND_THREAD_START= 6; 98 public static final int EVENTKIND_THREAD_END= 7; 99 public static final int EVENTKIND_THREAD_DEATH= EVENTKIND_THREAD_END; 100 public static final int EVENTKIND_CLASS_PREPARE= 8; 101 public static final int EVENTKIND_CLASS_UNLOAD= 9; 102 public static final int EVENTKIND_CLASS_LOAD= 10; 103 public static final int EVENTKIND_FIELD_ACCESS= 20; 104 public static final int EVENTKIND_FIELD_MODIFICATION= 21; 105 public static final int EVENTKIND_EXCEPTION_CATCH= 30; 106 public static final int EVENTKIND_METHOD_ENTRY= 40; 107 public static final int EVENTKIND_METHOD_EXIT= 41; 108 public static final int EVENTKIND_VM_INIT= 90; 109 public static final int EVENTKIND_VM_START= EVENTKIND_VM_INIT; 110 public static final int EVENTKIND_VM_DEATH= 99; 111 public static final int EVENTKIND_VM_DISCONNECTED= 100; 112 113 114 public static final int SUSPEND_STATUS_SUSPENDED= 0x01; 115 116 117 public static final int SUSPENDPOLICY_NONE= 0; 118 public static final int SUSPENDPOLICY_EVENT_THREAD= 1; 119 public static final int SUSPENDPOLICY_ALL= 2; 120 121 122 public static final int STEPDEPTH_INTO= 0; 123 public static final int STEPDEPTH_OVER= 1; 124 public static final int STEPDEPTH_OUT= 2; 125 126 127 public static final int STEPSIZE_MIN= 0; 128 public static final int STEPSIZE_LINE= 1; 129 130 private static final byte[] padding; 131 static { 132 padding= new byte[256]; 133 Arrays.fill(padding, (byte)' '); 134 } 135 136 private static final String shift= new String (padding, 0, 32); 137 138 public VerbosePacketStream(OutputStream out) { 139 super(out); 140 } 141 142 private static final byte[] zeros; 143 static { 144 zeros= new byte[16]; 145 Arrays.fill(zeros, (byte)'0'); 146 } 147 148 public synchronized void print(JdwpPacket packet, boolean fromVM) throws IOException { 149 try { 150 printHeader(packet, fromVM); 151 printData(packet); 152 println(); 153 } catch (UnableToParseDataException e) { 154 println("\n" + e.getMessage() + ':'); printDescription("Remaining data:"); byte[] data= e.getRemainingData(); 157 if (data == null) { 158 printHex(packet.data()); 159 } else { 160 printHex(e.getRemainingData()); 161 } 162 println(); 163 } 164 } 165 166 protected void printHeader(JdwpPacket packet, boolean fromVM) throws UnableToParseDataException { 167 if (fromVM) { 168 println("From VM"); } else { 170 println("From Debugger"); } 172 173 printDescription("Packet ID:"); printHex(packet.getId()); 175 println(); 176 177 printDescription("Length:"); print(packet.getLength()); 179 println(); 180 181 printDescription("Flags:"); byte flags= packet.getFlags(); 183 printHex(flags); 184 if ((flags & JdwpPacket.FLAG_REPLY_PACKET) != 0) { 185 print(MessageFormat.format(" (REPLY to {0})", new String [] {(String ) JdwpCommandPacket.commandMap().get(new Integer (TcpipSpy.getCommand(packet)))})); } else { 187 print(" (COMMAND)"); } 189 println(); 190 191 printSpecificHeaderFields(packet); 192 } 193 194 protected void printSpecificHeaderFields(JdwpPacket packet) { 195 if (packet instanceof JdwpReplyPacket) { 196 printError((JdwpReplyPacket) packet); 197 } else if (packet instanceof JdwpCommandPacket) { 198 printCommand((JdwpCommandPacket) packet); 199 } 200 } 201 202 protected void printCommand(JdwpCommandPacket commandPacket) { 203 printDescription("Command set:"); int commandAndSet= commandPacket.getCommand(); 205 byte set= (byte)(commandAndSet >> 8); 206 byte command= (byte)commandAndSet; 207 printHex(set); 208 printParanthetical(set); 209 println(); 210 printDescription("Command:"); printHex(command); 212 printParanthetical(command); 213 print(" ("); print(JdwpCommandPacket.commandMap().get(new Integer (commandAndSet))); 215 println(')'); 216 } 217 218 protected void printError(JdwpReplyPacket reply) { 219 int error= reply.errorCode(); 220 221 printDescription("Error:"); printHex(error); 223 if (error != 0) { 224 print(" ("); print(JdwpReplyPacket.errorMap().get(new Integer (error))); 226 print(')'); 227 } 228 println(); 229 } 230 231 protected void printData(JdwpPacket packet) throws IOException , UnableToParseDataException { 232 if ((packet.getFlags() & JdwpPacket.FLAG_REPLY_PACKET) != 0) { 233 printReplyData((JdwpReplyPacket) packet); 234 } else { 235 printCommandData((JdwpCommandPacket) packet); 236 } 237 } 238 239 private void printCommandData(JdwpCommandPacket command) throws IOException , UnableToParseDataException { 240 byte[] data= command.data(); 241 if (data == null) 242 return; 243 DataInputStream in= new DataInputStream (new ByteArrayInputStream (data)); 244 int commandId= command.getCommand(); 245 switch (commandId) { 246 247 case JdwpCommandPacket.VM_VERSION: 248 break; 250 case JdwpCommandPacket.VM_CLASSES_BY_SIGNATURE: 251 printVmClassesBySignatureCommand(in); 252 break; 253 case JdwpCommandPacket.VM_ALL_CLASSES: 254 break; 256 case JdwpCommandPacket.VM_ALL_THREADS: 257 break; 259 case JdwpCommandPacket.VM_TOP_LEVEL_THREAD_GROUPS: 260 break; 262 case JdwpCommandPacket.VM_DISPOSE: 263 break; 265 case JdwpCommandPacket.VM_ID_SIZES: 266 break; 268 case JdwpCommandPacket.VM_SUSPEND: 269 break; 271 case JdwpCommandPacket.VM_RESUME: 272 break; 274 case JdwpCommandPacket.VM_EXIT: 275 printVmExitCommand(in); 276 break; 277 case JdwpCommandPacket.VM_CREATE_STRING: 278 printVmCreateStringCommand(in); 279 break; 280 case JdwpCommandPacket.VM_CAPABILITIES: 281 break; 283 case JdwpCommandPacket.VM_CLASS_PATHS: 284 break; 286 case JdwpCommandPacket.VM_DISPOSE_OBJECTS: 287 printVmDisposeObjectsCommand(in); 288 break; 289 case JdwpCommandPacket.VM_HOLD_EVENTS: 290 break; 292 case JdwpCommandPacket.VM_RELEASE_EVENTS: 293 break; 295 case JdwpCommandPacket.VM_CAPABILITIES_NEW: 296 break; 298 case JdwpCommandPacket.VM_REDEFINE_CLASSES: 299 printVmRedefineClassCommand(in); 300 break; 301 case JdwpCommandPacket.VM_SET_DEFAULT_STRATUM: 302 printVmSetDefaultStratumCommand(in); 303 break; 304 case JdwpCommandPacket.VM_ALL_CLASSES_WITH_GENERIC: 305 break; 307 308 309 case JdwpCommandPacket.RT_SIGNATURE: 310 printRtDefaultCommand(in); 311 break; 312 case JdwpCommandPacket.RT_CLASS_LOADER: 313 printRtDefaultCommand(in); 314 break; 315 case JdwpCommandPacket.RT_MODIFIERS: 316 printRtDefaultCommand(in); 317 break; 318 case JdwpCommandPacket.RT_FIELDS: 319 printRtDefaultCommand(in); 320 break; 321 case JdwpCommandPacket.RT_METHODS: 322 printRtDefaultCommand(in); 323 break; 324 case JdwpCommandPacket.RT_GET_VALUES: 325 printRtGetValuesCommand(in); 326 break; 327 case JdwpCommandPacket.RT_SOURCE_FILE: 328 printRtDefaultCommand(in); 329 break; 330 case JdwpCommandPacket.RT_NESTED_TYPES: 331 printRtDefaultCommand(in); 332 break; 333 case JdwpCommandPacket.RT_STATUS: 334 printRtDefaultCommand(in); 335 break; 336 case JdwpCommandPacket.RT_INTERFACES: 337 printRtDefaultCommand(in); 338 break; 339 case JdwpCommandPacket.RT_CLASS_OBJECT: 340 printRtDefaultCommand(in); 341 break; 342 case JdwpCommandPacket.RT_SOURCE_DEBUG_EXTENSION: 343 printRtDefaultCommand(in); 344 break; 345 case JdwpCommandPacket.RT_SIGNATURE_WITH_GENERIC: 346 printRtDefaultCommand(in); 347 break; 348 case JdwpCommandPacket.RT_FIELDS_WITH_GENERIC: 349 printRtDefaultCommand(in); 350 break; 351 case JdwpCommandPacket.RT_METHODS_WITH_GENERIC: 352 printRtDefaultCommand(in); 353 break; 354 355 356 case JdwpCommandPacket.CT_SUPERCLASS: 357 printCtSuperclassCommand(in); 358 break; 359 case JdwpCommandPacket.CT_SET_VALUES: 360 printCtSetValuesCommand(in); 361 break; 362 case JdwpCommandPacket.CT_INVOKE_METHOD: 363 printCtInvokeMethodCommand(in); 364 break; 365 case JdwpCommandPacket.CT_NEW_INSTANCE: 366 printCtNewInstanceCommand(in); 367 break; 368 369 370 case JdwpCommandPacket.AT_NEW_INSTANCE: 371 printAtNewInstanceCommand(in); 372 break; 373 374 375 case JdwpCommandPacket.M_LINE_TABLE: 376 printMDefaultCommand(in); 377 break; 378 case JdwpCommandPacket.M_VARIABLE_TABLE: 379 printMDefaultCommand(in); 380 break; 381 case JdwpCommandPacket.M_BYTECODES: 382 printMDefaultCommand(in); 383 break; 384 case JdwpCommandPacket.M_IS_OBSOLETE: 385 printMDefaultCommand(in); 386 break; 387 case JdwpCommandPacket.M_VARIABLE_TABLE_WITH_GENERIC: 388 printMDefaultCommand(in); 389 break; 390 391 392 case JdwpCommandPacket.OR_REFERENCE_TYPE: 393 printOrDefaultCommand(in); 394 break; 395 case JdwpCommandPacket.OR_GET_VALUES: 396 printOrGetValuesCommand(in); 397 break; 398 case JdwpCommandPacket.OR_SET_VALUES: 399 printOrSetValuesCommand(in); 400 break; 401 case JdwpCommandPacket.OR_MONITOR_INFO: 402 printOrDefaultCommand(in); 403 break; 404 case JdwpCommandPacket.OR_INVOKE_METHOD: 405 printOrInvokeMethodCommand(in); 406 break; 407 case JdwpCommandPacket.OR_DISABLE_COLLECTION: 408 printOrDefaultCommand(in); 409 break; 410 case JdwpCommandPacket.OR_ENABLE_COLLECTION: 411 printOrDefaultCommand(in); 412 break; 413 case JdwpCommandPacket.OR_IS_COLLECTED: 414 printOrDefaultCommand(in); 415 break; 416 417 418 case JdwpCommandPacket.SR_VALUE: 419 printSrValueCommand(in); 420 break; 421 422 423 case JdwpCommandPacket.TR_NAME: 424 printTrDefaultCommand(in); 425 break; 426 case JdwpCommandPacket.TR_SUSPEND: 427 printTrDefaultCommand(in); 428 break; 429 case JdwpCommandPacket.TR_RESUME: 430 printTrDefaultCommand(in); 431 break; 432 case JdwpCommandPacket.TR_STATUS: 433 printTrDefaultCommand(in); 434 break; 435 case JdwpCommandPacket.TR_THREAD_GROUP: 436 printTrDefaultCommand(in); 437 break; 438 case JdwpCommandPacket.TR_FRAMES: 439 printTrFramesCommand(in); 440 break; 441 case JdwpCommandPacket.TR_FRAME_COUNT: 442 printTrDefaultCommand(in); 443 break; 444 case JdwpCommandPacket.TR_OWNED_MONITORS: 445 printTrDefaultCommand(in); 446 break; 447 case JdwpCommandPacket.TR_CURRENT_CONTENDED_MONITOR: 448 printTrDefaultCommand(in); 449 break; 450 case JdwpCommandPacket.TR_STOP: 451 printTrStopCommand(in); 452 break; 453 case JdwpCommandPacket.TR_INTERRUPT: 454 printTrDefaultCommand(in); 455 break; 456 case JdwpCommandPacket.TR_SUSPEND_COUNT: 457 printTrDefaultCommand(in); 458 break; 459 463 464 465 case JdwpCommandPacket.TGR_NAME: 466 printTgrDefaultCommand(in); 467 break; 468 case JdwpCommandPacket.TGR_PARENT: 469 printTgrDefaultCommand(in); 470 break; 471 case JdwpCommandPacket.TGR_CHILDREN: 472 printTgrDefaultCommand(in); 473 break; 474 475 476 case JdwpCommandPacket.AR_LENGTH: 477 printArLengthCommand(in); 478 break; 479 case JdwpCommandPacket.AR_GET_VALUES: 480 printArGetValuesCommand(in); 481 break; 482 case JdwpCommandPacket.AR_SET_VALUES: 483 printArSetValuesCommand(in); 484 break; 485 486 487 case JdwpCommandPacket.CLR_VISIBLE_CLASSES: 488 printClrVisibleClassesCommand(in); 489 break; 490 491 492 case JdwpCommandPacket.ER_SET: 493 printErSetCommand(in); 494 break; 495 case JdwpCommandPacket.ER_CLEAR: 496 printErClearCommand(in); 497 break; 498 case JdwpCommandPacket.ER_CLEAR_ALL_BREAKPOINTS: 499 break; 501 502 503 case JdwpCommandPacket.SF_GET_VALUES: 504 printSfGetValuesCommand(in); 505 break; 506 case JdwpCommandPacket.SF_SET_VALUES: 507 printSfSetValuesCommand(in); 508 break; 509 case JdwpCommandPacket.SF_THIS_OBJECT: 510 printSfDefaultCommand(in); 511 break; 512 case JdwpCommandPacket.SF_POP_FRAME: 513 printSfDefaultCommand(in); 514 break; 515 516 517 case JdwpCommandPacket.COR_REFLECTED_TYPE: 518 printCorReflectedTypeCommand(in); 519 break; 520 521 522 case JdwpCommandPacket.E_COMPOSITE: 523 printECompositeCommand(in); 524 break; 525 526 527 case JdwpCommandPacket.HCR_CLASSES_HAVE_CHANGED: 528 case JdwpCommandPacket.HCR_GET_CLASS_VERSION: 529 case JdwpCommandPacket.HCR_DO_RETURN: 530 case JdwpCommandPacket.HCR_REENTER_ON_EXIT: 531 case JdwpCommandPacket.HCR_CAPABILITIES: 532 throw new UnableToParseDataException("NOT MANAGED COMMAND", remainderData(in)); 534 default: 535 int cset= commandId >> 8; 536 int cmd= commandId & 0xFF; 537 println(MessageFormat.format("Unknown command : {0} {1}", new String [] {"" + cset, "" + cmd})); break; 539 } 540 } 541 542 543 private void printReplyData(JdwpReplyPacket reply) throws IOException , UnableToParseDataException { 544 byte[] data= reply.data(); 545 if (data == null) 546 return; 547 DataInputStream in= new DataInputStream (new ByteArrayInputStream (data)); 548 JdwpCommandPacket command= TcpipSpy.getCommand(reply.getId()); 549 int commandId= command.getCommand(); 550 switch (commandId) { 551 552 case JdwpCommandPacket.VM_VERSION: 553 printVmVersionReply(in); 554 break; 555 case JdwpCommandPacket.VM_CLASSES_BY_SIGNATURE: 556 printVmClassesBySignatureReply(in); 557 break; 558 case JdwpCommandPacket.VM_ALL_CLASSES: 559 printVmAllClassesReply(in); 560 break; 561 case JdwpCommandPacket.VM_ALL_THREADS: 562 printVmAllThreadsReply(in); 563 break; 564 case JdwpCommandPacket.VM_TOP_LEVEL_THREAD_GROUPS: 565 printVmTopLevelThreadGroupReply(in); 566 break; 567 case JdwpCommandPacket.VM_DISPOSE: 568 break; 570 case JdwpCommandPacket.VM_ID_SIZES: 571 printVmIdSizesReply(in); 572 break; 573 case JdwpCommandPacket.VM_SUSPEND: 574 break; 576 case JdwpCommandPacket.VM_RESUME: 577 break; 579 case JdwpCommandPacket.VM_EXIT: 580 break; 582 case JdwpCommandPacket.VM_CREATE_STRING: 583 printVmCreateStringReply(in); 584 break; 585 case JdwpCommandPacket.VM_CAPABILITIES: 586 printVmCapabilitiesReply(in); 587 break; 588 case JdwpCommandPacket.VM_CLASS_PATHS: 589 printVmClassPathsReply(in); 590 break; 591 case JdwpCommandPacket.VM_DISPOSE_OBJECTS: 592 break; 594 case JdwpCommandPacket.VM_HOLD_EVENTS: 595 break; 597 case JdwpCommandPacket.VM_RELEASE_EVENTS: 598 break; 600 case JdwpCommandPacket.VM_CAPABILITIES_NEW: 601 printVmCapabilitiesNewReply(in); 602 break; 603 case JdwpCommandPacket.VM_REDEFINE_CLASSES: 604 break; 606 case JdwpCommandPacket.VM_SET_DEFAULT_STRATUM: 607 break; 609 case JdwpCommandPacket.VM_ALL_CLASSES_WITH_GENERIC: 610 printVmAllClassesWithGenericReply(in); 611 break; 612 613 614 case JdwpCommandPacket.RT_SIGNATURE: 615 printRtSignatureReply(in); 616 break; 617 case JdwpCommandPacket.RT_CLASS_LOADER: 618 printRtClassLoaderReply(in); 619 break; 620 case JdwpCommandPacket.RT_MODIFIERS: 621 printRtModifiersReply(in); 622 break; 623 case JdwpCommandPacket.RT_FIELDS: 624 printRtFieldsReply(in); 625 break; 626 case JdwpCommandPacket.RT_METHODS: 627 printRtMethodsReply(in); 628 break; 629 case JdwpCommandPacket.RT_GET_VALUES: 630 printRtGetValuesReply(in); 631 break; 632 case JdwpCommandPacket.RT_SOURCE_FILE: 633 printRtSourceFileReply(in); 634 break; 635 case JdwpCommandPacket.RT_NESTED_TYPES: 636 printRtNestedTypesReply(in); 637 break; 638 case JdwpCommandPacket.RT_STATUS: 639 printRtStatusReply(in); 640 break; 641 case JdwpCommandPacket.RT_INTERFACES: 642 printRtInterfacesReply(in); 643 break; 644 case JdwpCommandPacket.RT_CLASS_OBJECT: 645 printRtClassObjectReply(in); 646 break; 647 case JdwpCommandPacket.RT_SOURCE_DEBUG_EXTENSION: 648 printRtSourceDebugExtensionReply(in); 649 break; 650 case JdwpCommandPacket.RT_SIGNATURE_WITH_GENERIC: 651 printRtSignatureWithGenericReply(in); 652 break; 653 case JdwpCommandPacket.RT_FIELDS_WITH_GENERIC: 654 printRtFieldsWithGenericReply(in); 655 break; 656 case JdwpCommandPacket.RT_METHODS_WITH_GENERIC: 657 printRtMethodsWithGenericReply(in); 658 break; 659 660 661 case JdwpCommandPacket.CT_SUPERCLASS: 662 printCtSuperclassReply(in); 663 break; 664 case JdwpCommandPacket.CT_SET_VALUES: 665 break; 667 case JdwpCommandPacket.CT_INVOKE_METHOD: 668 printCtInvokeMethodReply(in); 669 break; 670 case JdwpCommandPacket.CT_NEW_INSTANCE: 671 printCtNewInstanceReply(in); 672 break; 673 674 675 case JdwpCommandPacket.AT_NEW_INSTANCE: 676 printAtNewInstanceReply(in); 677 break; 678 679 680 case JdwpCommandPacket.M_LINE_TABLE: 681 printMLineTableReply(in); 682 break; 683 case JdwpCommandPacket.M_VARIABLE_TABLE: 684 printMVariableTableReply(in); 685 break; 686 case JdwpCommandPacket.M_BYTECODES: 687 printMBytecodesReply(in); 688 break; 689 case JdwpCommandPacket.M_IS_OBSOLETE: 690 printMIsObsoleteReply(in); 691 break; 692 case JdwpCommandPacket.M_VARIABLE_TABLE_WITH_GENERIC: 693 printMVariableTableWithGenericReply(in); 694 break; 695 696 697 case JdwpCommandPacket.OR_REFERENCE_TYPE: 698 printOrReferenceTypeReply(in); 699 break; 700 case JdwpCommandPacket.OR_GET_VALUES: 701 printOrGetValuesReply(in); 702 break; 703 case JdwpCommandPacket.OR_SET_VALUES: 704 break; 706 case JdwpCommandPacket.OR_MONITOR_INFO: 707 printOrMonitorInfoReply(in); 708 break; 709 case JdwpCommandPacket.OR_INVOKE_METHOD: 710 printOrInvokeMethodReply(in); 711 break; 712 case JdwpCommandPacket.OR_DISABLE_COLLECTION: 713 break; 715 case JdwpCommandPacket.OR_ENABLE_COLLECTION: 716 break; 718 case JdwpCommandPacket.OR_IS_COLLECTED: 719 printOrIsCollectedReply(in); 720 break; 721 722 723 case JdwpCommandPacket.SR_VALUE: 724 printSrValueReply(in); 725 break; 726 727 728 case JdwpCommandPacket.TR_NAME: 729 printTrNameReply(in); 730 break; 731 case JdwpCommandPacket.TR_SUSPEND: 732 break; 734 case JdwpCommandPacket.TR_RESUME: 735 break; 737 case JdwpCommandPacket.TR_STATUS: 738 printTrStatusReply(in); 739 break; 740 case JdwpCommandPacket.TR_THREAD_GROUP: 741 printTrThreadGroupReply(in); 742 break; 743 case JdwpCommandPacket.TR_FRAMES: 744 printTrFramesReply(in); 745 break; 746 case JdwpCommandPacket.TR_FRAME_COUNT: 747 printTrFrameCountReply(in); 748 break; 749 case JdwpCommandPacket.TR_OWNED_MONITORS: 750 printTrOwnedMonitorsReply(in); 751 break; 752 case JdwpCommandPacket.TR_CURRENT_CONTENDED_MONITOR: 753 printTrCurrentContendedMonitorReply(in); 754 break; 755 case JdwpCommandPacket.TR_STOP: 756 break; 758 case JdwpCommandPacket.TR_INTERRUPT: 759 break; 761 case JdwpCommandPacket.TR_SUSPEND_COUNT: 762 printTrSuspendCountReply(in); 763 break; 764 768 769 case JdwpCommandPacket.TGR_NAME: 770 printTgrNameReply(in); 771 break; 772 case JdwpCommandPacket.TGR_PARENT: 773 printTgrParentReply(in); 774 break; 775 case JdwpCommandPacket.TGR_CHILDREN: 776 printTgrChildrenReply(in); 777 break; 778 779 780 case JdwpCommandPacket.AR_LENGTH: 781 printArLengthReply(in); 782 break; 783 case JdwpCommandPacket.AR_GET_VALUES: 784 printArGetValuesReply(in); 785 break; 786 case JdwpCommandPacket.AR_SET_VALUES: 787 break; 789 790 791 case JdwpCommandPacket.CLR_VISIBLE_CLASSES: 792 printClrVisibleClassesReply(in); 793 break; 794 795 796 case JdwpCommandPacket.ER_SET: 797 printErSetReply(in); 798 break; 799 case JdwpCommandPacket.ER_CLEAR: 800 break; 802 case JdwpCommandPacket.ER_CLEAR_ALL_BREAKPOINTS: 803 break; 805 806 807 case JdwpCommandPacket.SF_GET_VALUES: 808 printSfGetValuesReply(in); 809 break; 810 case JdwpCommandPacket.SF_SET_VALUES: 811 break; 813 case JdwpCommandPacket.SF_THIS_OBJECT: 814 printSfThisObjectReply(in); 815 break; 816 case JdwpCommandPacket.SF_POP_FRAME: 817 break; 819 820 821 case JdwpCommandPacket.COR_REFLECTED_TYPE: 822 printCorReflectedTypeReply(in); 823 break; 824 825 826 829 830 831 case JdwpCommandPacket.HCR_CLASSES_HAVE_CHANGED: 832 case JdwpCommandPacket.HCR_GET_CLASS_VERSION: 833 case JdwpCommandPacket.HCR_DO_RETURN: 834 case JdwpCommandPacket.HCR_REENTER_ON_EXIT: 835 case JdwpCommandPacket.HCR_CAPABILITIES: 836 throw new UnableToParseDataException("NOT MANAGED COMMAND", remainderData(in)); 838 default: 839 int cset= commandId >> 8; 840 int cmd= commandId & 0xFF; 841 println(MessageFormat.format("Unknown command : {0} {1}", new String [] {"" + cset, "" + cmd})); break; 843 } 844 } 845 846 private void printRefTypeTag(byte refTypeTag) { 847 printDescription("Type tag:"); printRefTypeTagValue(refTypeTag); 849 println(); 850 } 851 852 private void printRefTypeTagValue(byte refTypeTag) { 853 printHex(refTypeTag); 854 print(" ("); switch (refTypeTag) { 856 case TYPE_TAG_CLASS: 857 print("CLASS"); break; 859 case TYPE_TAG_INTERFACE: 860 print("INTERFACE"); break; 862 case TYPE_TAG_ARRAY: 863 print("ARRAY"); break; 865 default: 866 print("unknown"); } 868 print(')'); 869 } 870 871 private void printClassStatus(int status) { 872 printDescription("Status:"); printHex(status); 874 print(" ("); boolean spaceNeeded= false; 876 if ((status & JDWP_CLASS_STATUS_VERIFIED) != 0) { 877 print("VERIFIED"); spaceNeeded= true; 879 } 880 if ((status & JDWP_CLASS_STATUS_PREPARED) != 0) { 881 if (spaceNeeded) { 882 print(' '); 883 } else { 884 spaceNeeded= true; 885 } 886 print("PREPARED"); } 888 if ((status & JDWP_CLASS_STATUS_INITIALIZED) != 0) { 889 if (spaceNeeded) { 890 print(' '); 891 } else { 892 spaceNeeded= true; 893 } 894 print("INITIALIZED"); } 896 if ((status & JDWP_CLASS_STATUS_ERROR) != 0) { 897 if (spaceNeeded) { 898 print(' '); 899 } 900 print("unknown"); } 902 println(')'); 903 } 904 905 private void printClassModifiers(int modifiers) { 906 printDescription("Modifiers:"); printHex(modifiers); 908 print(" ("); boolean spaceNeeded= false; 910 if ((modifiers & ACC_PUBLIC) != 0) { 911 print("PUBLIC"); spaceNeeded= true; 913 } 914 if ((modifiers & ACC_PRIVATE) != 0) { 915 if (spaceNeeded) { 916 print(' '); 917 } else { 918 spaceNeeded= true; 919 } 920 print("PRIVATE"); } 922 if ((modifiers & ACC_PROTECTED) != 0) { 923 if (spaceNeeded) { 924 print(' '); 925 } else { 926 spaceNeeded= true; 927 } 928 print("PROTECTED"); } 930 if ((modifiers & ACC_STATIC) != 0) { 931 if (spaceNeeded) { 932 print(' '); 933 } else { 934 spaceNeeded= true; 935 } 936 print("STATIC"); } 938 if ((modifiers & ACC_FINAL) != 0) { 939 if (spaceNeeded) { 940 print(' '); 941 } else { 942 spaceNeeded= true; 943 } 944 print("FINAL"); } 946 if ((modifiers & ACC_SUPER) != 0) { 947 if (spaceNeeded) { 948 print(' '); 949 } else { 950 spaceNeeded= true; 951 } 952 print("SUPER"); } 954 if ((modifiers & ACC_INTERFACE) != 0) { 955 if (spaceNeeded) { 956 print(' '); 957 } else { 958 spaceNeeded= true; 959 } 960 print("INTERFACE"); } 962 if ((modifiers & ACC_ABSTRACT) != 0) { 963 if (spaceNeeded) { 964 print(' '); 965 } else { 966 spaceNeeded= true; 967 } 968 print("ABSTRACT"); } 970 if ((modifiers & (ACC_EXT_SYNTHETIC | ACC_SYNTHETIC)) != 0) { 971 if (spaceNeeded) { 972 print(' '); 973 } else { 974 spaceNeeded= true; 975 } 976 print("SYNTHETIC"); } 978 println(')'); 979 } 980 981 private void printMethodModifiers(int modifiers) { 982 printDescription("Modifiers:"); printHex(modifiers); 984 print(" ("); boolean spaceNeeded= false; 986 if ((modifiers & ACC_PUBLIC) != 0) { 987 print("PUBLIC"); spaceNeeded= true; 989 } 990 if ((modifiers & ACC_PRIVATE) != 0) { 991 if (spaceNeeded) { 992 print(' '); 993 } else { 994 spaceNeeded= true; 995 } 996 print("PRIVATE"); } 998 if ((modifiers & ACC_PROTECTED) != 0) { 999 if (spaceNeeded) { 1000 print(' '); 1001 } else { 1002 spaceNeeded= true; 1003 } 1004 print("PROTECTED"); } 1006 if ((modifiers & ACC_STATIC) != 0) { 1007 if (spaceNeeded) { 1008 print(' '); 1009 } else { 1010 spaceNeeded= true; 1011 } 1012 print("STATIC"); } 1014 if ((modifiers & ACC_FINAL) != 0) { 1015 if (spaceNeeded) { 1016 print(' '); 1017 } else { 1018 spaceNeeded= true; 1019 } 1020 print("FINAL"); } 1022 if ((modifiers & ACC_SYNCHRONIZED) != 0) { 1023 if (spaceNeeded) { 1024 print(' '); 1025 } else { 1026 spaceNeeded= true; 1027 } 1028 print("SYNCHRONIZED"); } 1030 if ((modifiers & ACC_BRIDGE) != 0) { 1031 if (spaceNeeded) { 1032 print(' '); 1033 } else { 1034 spaceNeeded= true; 1035 } 1036 print("BRIDGE"); } 1038 if ((modifiers & ACC_VARARGS) != 0) { 1039 if (spaceNeeded) { 1040 print(' '); 1041 } else { 1042 spaceNeeded= true; 1043 } 1044 print("VARARGS"); } 1046 if ((modifiers & ACC_NATIVE) != 0) { 1047 if (spaceNeeded) { 1048 print(' '); 1049 } else { 1050 spaceNeeded= true; 1051 } 1052 print("NATIVE"); } 1054 if ((modifiers & ACC_ABSTRACT) != 0) { 1055 if (spaceNeeded) { 1056 print(' '); 1057 } else { 1058 spaceNeeded= true; 1059 } 1060 print("ABSTRACT"); } 1062 if ((modifiers & ACC_STRICT) != 0) { 1063 if (spaceNeeded) { 1064 print(' '); 1065 } else { 1066 spaceNeeded= true; 1067 } 1068 print("STRICT"); } 1070 if ((modifiers & (ACC_EXT_SYNTHETIC | ACC_SYNTHETIC )) != 0) { 1071 if (spaceNeeded) { 1072 print(' '); 1073 } else { 1074 spaceNeeded= true; 1075 } 1076 print("SYNTHETIC"); } 1078 println(')'); 1079 } 1080 1081 private void printFieldModifiers(int modifiers) { 1082 printDescription("Modifiers:"); printHex(modifiers); 1084 print(" ("); boolean spaceNeeded= false; 1086 if ((modifiers & ACC_PUBLIC) != 0) { 1087 print("PUBLIC"); spaceNeeded= true; 1089 } 1090 if ((modifiers & ACC_PRIVATE) != 0) { 1091 if (spaceNeeded) { 1092 print(' '); 1093 } else { 1094 spaceNeeded= true; 1095 } 1096 print("PRIVATE"); } 1098 if ((modifiers & ACC_PROTECTED) != 0) { 1099 if (spaceNeeded) { 1100 print(' '); 1101 } else { 1102 spaceNeeded= true; 1103 } 1104 print("PROTECTED"); } 1106 if ((modifiers & ACC_STATIC) != 0) { 1107 if (spaceNeeded) { 1108 print(' '); 1109 } else { 1110 spaceNeeded= true; 1111 } 1112 print("STATIC"); } 1114 if ((modifiers & ACC_FINAL) != 0) { 1115 if (spaceNeeded) { 1116 print(' '); 1117 } else { 1118 spaceNeeded= true; 1119 } 1120 print("FINAL"); } 1122 if ((modifiers & ACC_VOLATILE) != 0) { 1123 if (spaceNeeded) { 1124 print(' '); 1125 } else { 1126 spaceNeeded= true; 1127 } 1128 print("VOLATILE"); } 1130 if ((modifiers & ACC_TRANSIENT) != 0) { 1131 if (spaceNeeded) { 1132 print(' '); 1133 } else { 1134 spaceNeeded= true; 1135 } 1136 print("TRANSIENT"); } 1138 if ((modifiers & ACC_ENUM) != 0) { 1139 if (spaceNeeded) { 1140 print(' '); 1141 } else { 1142 spaceNeeded= true; 1143 } 1144 print("ENUM"); } 1146 if ((modifiers & (ACC_EXT_SYNTHETIC | ACC_SYNTHETIC)) != 0) { 1147 if (spaceNeeded) { 1148 print(' '); 1149 } else { 1150 spaceNeeded= true; 1151 } 1152 print("SYNTHETIC"); } 1154 println(')'); 1155 } 1156 1157 private void printInvocationOptions(int invocationOptions) { 1158 printDescription("Invocation Options:"); printHex(invocationOptions); 1160 print(" ("); boolean spaceNeeded= false; 1162 if ((invocationOptions & INVOKE_SINGLE_THREADED) != 0) { 1163 print("SINGLE_THREADED"); spaceNeeded= true; 1165 } 1166 if ((invocationOptions & INVOKE_NONVIRTUAL) != 0) { 1167 if (spaceNeeded) { 1168 print(' '); 1169 } 1170 print("NONVIRTUAL"); } 1172 println(')'); 1173 } 1174 1175 private void printThreadStatus(int threadStatus) { 1176 printDescription("Thread status:"); printHex(threadStatus); 1178 print(" ("); switch (threadStatus) { 1180 case THREAD_STATUS_ZOMBIE: 1181 print("ZOMBIE"); break; 1183 case THREAD_STATUS_RUNNING: 1184 print("RUNNING"); break; 1186 case THREAD_STATUS_SLEEPING: 1187 print("SLEEPING"); break; 1189 case THREAD_STATUS_MONITOR: 1190 print("MONITOR"); break; 1192 case THREAD_STATUS_WAIT: 1193 print("WAIT"); break; 1195 default: 1196 print("unknown"); break; 1198 } 1199 println(')'); 1200 } 1201 1202 private void printSuspendStatus(int suspendStatus) { 1203 printDescription("Suspend status:"); printHex(suspendStatus); 1205 print(" ("); if ((suspendStatus & SUSPEND_STATUS_SUSPENDED) != 0) { 1207 print("SUSPENDED"); } 1209 println(')'); 1210 } 1211 1212 private void printEventKind(byte eventKind) { 1213 printDescription("Event kind:"); printHex(eventKind); 1215 print(" ("); switch (eventKind) { 1217 case EVENTKIND_SINGLE_STEP: 1218 print("SINGLE_STEP"); break; 1220 case EVENTKIND_BREAKPOINT: 1221 print("BREAKPOINT"); break; 1223 case EVENTKIND_FRAME_POP: 1224 print("FRAME_POP"); break; 1226 case EVENTKIND_EXCEPTION: 1227 print("EXCEPTION"); break; 1229 case EVENTKIND_USER_DEFINED: 1230 print("USER_DEFINED"); break; 1232 case EVENTKIND_THREAD_START: 1233 print("THREAD_START"); break; 1235 case EVENTKIND_THREAD_END: 1236 print("THREAD_END"); break; 1238 case EVENTKIND_CLASS_PREPARE: 1239 print("CLASS_PREPARE"); break; 1241 case EVENTKIND_CLASS_UNLOAD: 1242 print("CLASS_UNLOAD"); break; 1244 case EVENTKIND_CLASS_LOAD: 1245 print("CLASS_LOAD"); break; 1247 case EVENTKIND_FIELD_ACCESS: 1248 print("FIELD_ACCESS"); break; 1250 case EVENTKIND_FIELD_MODIFICATION: 1251 print("FIELD_MODIFICATION"); break; 1253 case EVENTKIND_EXCEPTION_CATCH: 1254 print("EXCEPTION_CATCH"); break; 1256 case EVENTKIND_METHOD_ENTRY: 1257 print("METHOD_ENTRY"); break; 1259 case EVENTKIND_METHOD_EXIT: 1260 print("METHOD_EXIT"); break; 1262 case EVENTKIND_VM_INIT: 1263 print("VM_INIT"); break; 1265 case EVENTKIND_VM_DEATH: 1266 print("VM_DEATH"); break; 1268 case EVENTKIND_VM_DISCONNECTED: 1269 print("VM_DISCONNECTED"); break; 1271 default: 1272 print("unknown"); break; 1274 } 1275 println(')'); 1276 } 1277 1278 private void printSuspendPolicy(byte suspendPolicy) { 1279 printDescription("Suspend policy:"); printHex(suspendPolicy); 1281 print(" ("); switch (suspendPolicy) { 1283 case SUSPENDPOLICY_NONE: 1284 print("NONE"); break; 1286 case SUSPENDPOLICY_EVENT_THREAD: 1287 print("EVENT_THREAD"); break; 1289 case SUSPENDPOLICY_ALL: 1290 print("ALL"); break; 1292 default: 1293 print("unknown"); break; 1295 } 1296 println(')'); 1297 } 1298 1299 private void printStepDepth(int setDepth) { 1300 printDescription("Step depth:"); printHex(setDepth); 1302 print(" ("); switch (setDepth) { 1304 case STEPDEPTH_INTO: 1305 print("INTO"); break; 1307 case STEPDEPTH_OVER: 1308 print("OVER"); break; 1310 case STEPDEPTH_OUT: 1311 print("OUT"); break; 1313 default: 1314 print("unknown"); break; 1316 } 1317 println(')'); 1318 } 1319 1320 private void printStepSize(int setSize) { 1321 printDescription("Step size:"); printHex(setSize); 1323 print(" ("); switch (setSize) { 1325 case STEPSIZE_MIN: 1326 print("MIN"); break; 1328 case STEPSIZE_LINE: 1329 print("LINE"); break; 1331 default: 1332 print("unknown"); break; 1334 } 1335 println(')'); 1336 } 1337 1338 private void printVmVersionReply(DataInputStream in) throws IOException { 1339 String description= readString(in); 1340 int jdwpMajor= in.readInt(); 1341 int jdwpMinor= in.readInt(); 1342 String vmVersion= readString(in); 1343 String vmName= readString(in); 1344 1345 println("VM Description:", description); println("JDWP Major Version:", jdwpMajor); println("JDWP Minor Version:", jdwpMinor); println("VM Version:", vmVersion); println("VM Name:", vmName); } 1351 1352 private void printVmClassesBySignatureCommand(DataInputStream in) throws IOException { 1353 String signature= readString(in); 1354 println("Class signature:", signature); } 1356 1357 private void printVmClassesBySignatureReply(DataInputStream in) throws IOException , UnableToParseDataException { 1358 int classesCount= in.readInt(); 1359 println("Classes count:", classesCount); for(int i= 0; i < classesCount; i++) { 1361 byte refTypeTag= in.readByte(); 1362 long typeId= readReferenceTypeID(in); 1363 int status= in.readInt(); 1364 printRefTypeTag(refTypeTag); 1365 printlnReferenceTypeId("Type id:", typeId); printClassStatus(status); 1367 } 1368 } 1369 1370 private void printVmAllClassesReply(DataInputStream in) throws IOException , UnableToParseDataException { 1371 int classesCount= in.readInt(); 1372 println("Classes count:", classesCount); for(int i= 0; i < classesCount; i++) { 1374 byte refTypeTag= in.readByte(); 1375 long typeId= readReferenceTypeID(in); 1376 String signature= readString(in); 1377 int status= in.readInt(); 1378 printRefTypeTag(refTypeTag); 1379 printlnReferenceTypeId("Type id:", typeId); println("Class signature:", signature); printClassStatus(status); 1382 } 1383 } 1384 1385 private void printVmAllThreadsReply(DataInputStream in) throws IOException , UnableToParseDataException { 1386 int threadsCount= in.readInt(); 1387 println("Threads count:", threadsCount); for(int i= 0; i < threadsCount; i++) { 1389 long threadId= readObjectID(in); 1390 printlnObjectId("Thread id:", threadId); } 1392 } 1393 1394 private void printVmTopLevelThreadGroupReply(DataInputStream in) throws IOException , UnableToParseDataException { 1395 int groupsCount= in.readInt(); 1396 println("Threads count:", groupsCount); for(int i= 0; i < groupsCount; i++) { 1398 long threadGroupId= readObjectID(in); 1399 printlnObjectId("Thread id:", threadGroupId); } 1401 } 1402 1403 private void printVmIdSizesReply(DataInputStream in) throws IOException { 1404 int fieldIDSize= in.readInt(); 1405 int methodIDSize= in.readInt(); 1406 int objectIDSize= in.readInt(); 1407 int referenceTypeIDSize= in.readInt(); 1408 int frameIDSize= in.readInt(); 1409 println("Field ID size:", fieldIDSize); println("Method ID size:", methodIDSize); println("Object ID size:", objectIDSize); println("Reference type ID size:", referenceTypeIDSize); println("Frame ID size:", frameIDSize); TcpipSpy.setFieldIDSize(fieldIDSize); 1415 TcpipSpy.setMethodIDSize(methodIDSize); 1416 TcpipSpy.setObjectIDSize(objectIDSize); 1417 TcpipSpy.setReferenceTypeIDSize(referenceTypeIDSize); 1418 TcpipSpy.setFrameIDSize(frameIDSize); 1419 TcpipSpy.setHasSizes(true); 1420 } 1421 1422 private void printVmExitCommand(DataInputStream in) throws IOException { 1423 int exitCode= in.readInt(); 1424 println("Exit code:", exitCode); } 1426 1427 private void printVmCreateStringCommand(DataInputStream in) throws IOException { 1428 String string= readString(in); 1429 println("String:", string); } 1431 1432 private void printVmCreateStringReply(DataInputStream in) throws IOException , UnableToParseDataException { 1433 long stringId= readObjectID(in); 1434 printlnObjectId("String id:", stringId); } 1436 1437 private void printVmCapabilitiesReply(DataInputStream in) throws IOException { 1438 boolean canWatchFieldModification= in.readBoolean(); 1439 boolean canWatchFieldAccess= in.readBoolean(); 1440 boolean canGetBytecodes= in.readBoolean(); 1441 boolean canGetSyntheticAttribute= in.readBoolean(); 1442 boolean canGetOwnedMonitorInfo= in.readBoolean(); 1443 boolean canGetCurrentContendedMonitor= in.readBoolean(); 1444 boolean canGetMonitorInfo= in.readBoolean(); 1445 println("Can watch field modification:", canWatchFieldModification); println("can watch field access:", canWatchFieldAccess); println("Can get bytecodes:", canGetBytecodes); println("Can get synthetic attribute:", canGetSyntheticAttribute); println("Can get owned monitor info:", canGetOwnedMonitorInfo); println("Can get currently contended monitor:", canGetCurrentContendedMonitor); println("Can get monitor info:", canGetMonitorInfo); } 1453 1454 private void printVmClassPathsReply(DataInputStream in) throws IOException { 1455 String baseDir= readString(in); 1456 println("Base directory:", baseDir); int classpathCount= in.readInt(); 1458 println("Classpaths count:", classpathCount); for (int i= 0; i < classpathCount; i++) { 1460 String path= readString(in); 1461 println("Classpath:", path); } 1463 int bootclasspathCount= in.readInt(); 1464 println("Bootclasspaths count:", bootclasspathCount); for (int i= 0; i < bootclasspathCount; i++) { 1466 String path= readString(in); 1467 println("Bootclasspath:", path); } 1469 } 1470 1471 private void printVmDisposeObjectsCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1472 int requestsCount= in.readInt(); 1473 println("Requests Count:", requestsCount); for (int i=0; i < requestsCount; i++) { 1475 long objectId= readObjectID(in); 1476 int refsCounts= in.readInt(); 1477 printlnObjectId("Object id:", objectId); println("References count:", refsCounts); } 1480 } 1481 1482 private void printVmCapabilitiesNewReply(DataInputStream in) throws IOException { 1483 printVmCapabilitiesReply(in); 1484 boolean canRedefineClasses= in.readBoolean(); 1485 boolean canAddMethod= in.readBoolean(); 1486 boolean canUnrestrictedlyRedefineClasses= in.readBoolean(); 1487 boolean canPopFrames= in.readBoolean(); 1488 boolean canUseInstanceFilters= in.readBoolean(); 1489 boolean canGetSourceDebugExtension= in.readBoolean(); 1490 boolean canRequestVMDeathEvent= in.readBoolean(); 1491 boolean canSetDefaultStratum= in.readBoolean(); 1492 boolean reserved16= in.readBoolean(); 1493 boolean reserved17= in.readBoolean(); 1494 boolean reserved18= in.readBoolean(); 1495 boolean reserved19= in.readBoolean(); 1496 boolean reserved20= in.readBoolean(); 1497 boolean reserved21= in.readBoolean(); 1498 boolean reserved22= in.readBoolean(); 1499 boolean reserved23= in.readBoolean(); 1500 boolean reserved24= in.readBoolean(); 1501 boolean reserved25= in.readBoolean(); 1502 boolean reserved26= in.readBoolean(); 1503 boolean reserved27= in.readBoolean(); 1504 boolean reserved28= in.readBoolean(); 1505 boolean reserved29= in.readBoolean(); 1506 boolean reserved30= in.readBoolean(); 1507 boolean reserved31= in.readBoolean(); 1508 boolean reserved32= in.readBoolean(); 1509 println("Can redefine classes:", canRedefineClasses); println("Can add method:", canAddMethod); println("Can unrestrictedly rd. classes:", canUnrestrictedlyRedefineClasses); println("Can pop frames:", canPopFrames); println("Can use instance filters:", canUseInstanceFilters); println("Can get source debug extension:", canGetSourceDebugExtension); println("Can request VMDeath event:", canRequestVMDeathEvent); println("Can set default stratum:", canSetDefaultStratum); println("Reserved:", reserved16); println("Reserved:", reserved17); println("Reserved:", reserved18); println("Reserved:", reserved19); println("Reserved:", reserved20); println("Reserved:", reserved21); println("Reserved:", reserved22); println("Reserved:", reserved23); println("Reserved:", reserved24); println("Reserved:", reserved25); println("Reserved:", reserved26); println("Reserved:", reserved27); println("Reserved:", reserved28); println("Reserved:", reserved29); println("Reserved:", reserved30); println("Reserved:", reserved31); println("Reserved:", reserved32); } 1535 1536 private void printVmRedefineClassCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1537 int typesCount= in.readInt(); 1538 println("Types count:", typesCount); for (int i= 0; i < typesCount; i++) { 1540 long typeId= readReferenceTypeID(in); 1541 int classfileLength= in.readInt(); 1542 printlnReferenceTypeId("Type id:", typeId); println("Classfile length:", classfileLength); while((classfileLength -= in.skipBytes(classfileLength)) != 0) { 1545 } 1546 printDescription("Class bytes:"); println("skipped"); } 1549 } 1550 1551 private void printVmSetDefaultStratumCommand(DataInputStream in) throws IOException { 1552 String stratumId= readString(in); 1553 println("Stratum id:", stratumId); } 1555 1556 private void printVmAllClassesWithGenericReply(DataInputStream in) throws IOException , UnableToParseDataException { 1557 int classesCount= in.readInt(); 1558 println("Classes count:", classesCount); for(int i= 0; i < classesCount; i++) { 1560 byte refTypeTag= in.readByte(); 1561 long typeId= readReferenceTypeID(in); 1562 String signature= readString(in); 1563 String genericSignature= readString(in); 1564 int status= in.readInt(); 1565 printRefTypeTag(refTypeTag); 1566 printlnReferenceTypeId("Type id:", typeId); println("Class signature:", signature); println("Generic class signature:", genericSignature); printClassStatus(status); 1570 } 1571 } 1572 1573 private void printRtDefaultCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1574 long typeId= readReferenceTypeID(in); 1575 printlnReferenceTypeId("Type id:", typeId); } 1577 1578 private void printRtSignatureReply(DataInputStream in) throws IOException { 1579 String signature= readString(in); 1580 println("Signature:", signature); } 1582 1583 private void printRtClassLoaderReply(DataInputStream in) throws IOException , UnableToParseDataException { 1584 long classLoaderId= readObjectID(in); 1585 printlnObjectId("ClassLoader id:", classLoaderId); } 1587 1588 private void printRtModifiersReply(DataInputStream in) throws IOException { 1589 int modifiers= in.readInt(); 1590 printClassModifiers(modifiers); 1591 } 1592 1593 private void printRtFieldsReply(DataInputStream in) throws IOException , UnableToParseDataException { 1594 int fieldsCount= in.readInt(); 1595 println("Fields count:", fieldsCount); for (int i= 0; i < fieldsCount; i++) { 1597 long fieldId= readFieldID(in); 1598 String name= readString(in); 1599 String signature= readString(in); 1600 int modifiers= in.readInt(); 1601 printlnFieldId("Field id:", fieldId); println("Name:", name); println("Signature:", signature); printFieldModifiers(modifiers); 1605 } 1606 } 1607 1608 private void printRtMethodsReply(DataInputStream in) throws IOException , UnableToParseDataException { 1609 int methodsCount= in.readInt(); 1610 println("Methods count:", methodsCount); for (int i= 0; i < methodsCount; i++) { 1612 long methodId= readMethodID(in); 1613 String name= readString(in); 1614 String signature= readString(in); 1615 int modifiers= in.readInt(); 1616 printlnMethodId("Method id:", methodId); println("Name:", name); println("Signature:", signature); printMethodModifiers(modifiers); 1620 } 1621 } 1622 1623 private void printRtGetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1624 long typeId= readReferenceTypeID(in); 1625 int fieldsCount= in.readInt(); 1626 printlnReferenceTypeId("Type id:", typeId); println("Fields count:", fieldsCount); for (int i= 0; i < fieldsCount; i++) { 1629 long fieldId= readFieldID(in); 1630 printlnFieldId("Field id:", fieldId); } 1632 } 1633 1634 private void printRtGetValuesReply(DataInputStream in) throws IOException , UnableToParseDataException { 1635 int valuesCount= in.readInt(); 1636 println("Values count:", valuesCount); for (int i= 0; i < valuesCount; i++) { 1638 readAndPrintlnTaggedValue("Value:", in); } 1640 } 1641 1642 private void printRtSourceFileReply(DataInputStream in) throws IOException { 1643 String sourceFile= readString(in); 1644 println("Source file:", sourceFile); } 1646 1647 private void printRtNestedTypesReply(DataInputStream in) throws IOException , UnableToParseDataException { 1648 int typesCount= in.readInt(); 1649 println("Types count:", typesCount); for (int i= 0; i < typesCount; i++) { 1651 byte typeTag= in.readByte(); 1652 long typeId= readReferenceTypeID(in); 1653 printRefTypeTag(typeTag); 1654 printlnReferenceTypeId("Type id:", typeId); } 1656 } 1657 1658 private void printRtStatusReply(DataInputStream in) throws IOException { 1659 int status= in.readInt(); 1660 printClassStatus(status); 1661 } 1662 1663 private void printRtInterfacesReply(DataInputStream in) throws IOException , UnableToParseDataException { 1664 int interfacesCount= in.readInt(); 1665 println("Interfaces count:", interfacesCount); for (int i= 0; i < interfacesCount; i ++) { 1667 long interfaceId= readReferenceTypeID(in); 1668 printlnReferenceTypeId("Interface type id:", interfaceId); } 1670 } 1671 1672 private void printRtClassObjectReply(DataInputStream in) throws IOException , UnableToParseDataException { 1673 long classObjectId= readObjectID(in); 1674 printlnObjectId("Class object id:", classObjectId); } 1676 1677 private void printRtSourceDebugExtensionReply(DataInputStream in) throws IOException { 1678 String extension= readString(in); 1679 println("Extension:", extension); } 1681 1682 private void printRtSignatureWithGenericReply(DataInputStream in) throws IOException { 1683 String signature= readString(in); 1684 String genericSignature= readString(in); 1685 println("Signature:", signature); println("Generic signature:", genericSignature); } 1688 1689 private void printRtFieldsWithGenericReply(DataInputStream in) throws IOException , UnableToParseDataException { 1690 int fieldsCount= in.readInt(); 1691 println("Fields count:", fieldsCount); for (int i= 0; i < fieldsCount; i++) { 1693 long fieldId= readFieldID(in); 1694 String name= readString(in); 1695 String signature= readString(in); 1696 String genericSignature= readString(in); 1697 int modifiers= in.readInt(); 1698 printlnFieldId("Field id:", fieldId); println("Name:", name); println("Signature:", signature); println("Generic signature:", genericSignature); printFieldModifiers(modifiers); 1703 } 1704 } 1705 1706 private void printRtMethodsWithGenericReply(DataInputStream in) throws IOException , UnableToParseDataException { 1707 int methodsCount= in.readInt(); 1708 println("Methods count:", methodsCount); for (int i= 0; i < methodsCount; i++) { 1710 long methodId= readMethodID(in); 1711 String name= readString(in); 1712 String genericSignature= readString(in); 1713 int modifiers= in.readInt(); 1714 printlnMethodId("Method id:", methodId); println("Name:", name); println("Generic signature:", genericSignature); printMethodModifiers(modifiers); 1719 } 1720 } 1721 1722 private void printCtSuperclassCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1723 long classTypeId= readReferenceTypeID(in); 1724 printlnReferenceTypeId("Class type id:", classTypeId); } 1726 1727 private void printCtSuperclassReply(DataInputStream in) throws IOException , UnableToParseDataException { 1728 long superclassTypeId= readReferenceTypeID(in); 1729 printlnReferenceTypeId("Superclass type id:", superclassTypeId); } 1731 1732 private void printCtSetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1733 long classTypeId= readReferenceTypeID(in); 1734 int fieldsCount= in.readInt(); 1735 printlnReferenceTypeId("Class type id:", classTypeId); println("Fields count:", fieldsCount); throw new UnableToParseDataException("List of values: NOT MANAGED", remainderData(in)); } 1739 1740 private void printCtInvokeMethodCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1741 long classTypeId= readReferenceTypeID(in); 1742 long threadId= readObjectID(in); 1743 long methodId= readMethodID(in); 1744 int argumentsCount= in.readInt(); 1745 printlnReferenceTypeId("Class type id:", classTypeId); printlnObjectId("Thread id:", threadId); printlnMethodId("Method id:", methodId); println("Arguments count:", argumentsCount); for (int i= 0; i < argumentsCount; i++) { 1750 readAndPrintlnTaggedValue("Argument:", in); } 1752 int invocationOptions= in.readInt(); 1753 printInvocationOptions(invocationOptions); 1754 } 1755 1756 private void printCtInvokeMethodReply(DataInputStream in) throws IOException , UnableToParseDataException { 1757 readAndPrintlnTaggedValue("Return value:", in); byte signatureByte= in.readByte(); 1759 long exception= readObjectID(in); 1760 printlnTaggedObjectId("Exception object id:", exception, signatureByte); } 1762 1763 private void printCtNewInstanceCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1764 printCtInvokeMethodCommand(in); 1765 } 1766 1767 private void printCtNewInstanceReply(DataInputStream in) throws IOException , UnableToParseDataException { 1768 byte objectSignatureByte= in.readByte(); 1769 long newObjectId= readObjectID(in); 1770 byte exceptionSignatureByte= in.readByte(); 1771 long exception= readObjectID(in); 1772 printlnTaggedObjectId("New object id:", newObjectId, objectSignatureByte); printlnTaggedObjectId("Exception object id:", exception, exceptionSignatureByte); } 1775 1776 private void printAtNewInstanceCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1777 long arrayTypeId= readReferenceTypeID(in); 1778 int length= in.readInt(); 1779 printlnReferenceTypeId("Array type id:", arrayTypeId); println("Length:", length); } 1782 1783 private void printAtNewInstanceReply(DataInputStream in) throws IOException , UnableToParseDataException { 1784 byte signatureByte= in.readByte(); 1785 long newArrayId= readObjectID(in); 1786 printlnTaggedObjectId("New array id:", newArrayId, signatureByte); } 1788 1789 private void printMDefaultCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1790 long classTypeId= readReferenceTypeID(in); 1791 long methodId= readMethodID(in); 1792 printlnReferenceTypeId("Class type id:", classTypeId); printlnMethodId("Method id:", methodId); } 1795 1796 private void printMLineTableReply(DataInputStream in) throws IOException { 1797 long start= in.readLong(); 1798 long end= in.readLong(); 1799 int lines= in.readInt(); 1800 println("Lowest valid code index:", start); println("Highest valid code index:", end); println("Number of lines:", lines); for (int i= 0; i < lines; i++) { 1804 long lineCodeIndex= in.readLong(); 1805 int lineNumber= in.readInt(); 1806 println("Line code Index:", lineCodeIndex); println("Line number:", lineNumber); } 1809 } 1810 1811 private void printMVariableTableReply(DataInputStream in) throws IOException { 1812 int slotsUsedByArgs= in.readInt(); 1813 int variablesCount= in.readInt(); 1814 println("Nb of slots used by all args:", slotsUsedByArgs); println("Nb of variables:", variablesCount); for (int i= 0; i < variablesCount; i++) { 1817 long codeIndex= in.readLong(); 1818 String name= readString(in); 1819 String signature= readString(in); 1820 int length= in.readInt(); 1821 int slotId= in.readInt(); 1822 println("First code index:", codeIndex); println("Variable name:", name); println("Variable type signature:", signature); println("Code index length:", length); println("Slot id:", slotId); } 1828 } 1829 1830 private void printMBytecodesReply(DataInputStream in) throws IOException { 1831 int bytes= in.readInt(); 1832 println("Nb of bytes:", bytes); while((bytes -= in.skipBytes(bytes)) != 0) { 1834 } 1835 printDescription("Method bytes:"); println("skipped"); } 1838 1839 private void printMIsObsoleteReply(DataInputStream in) throws IOException { 1840 boolean isObsolete= in.readBoolean(); 1841 println("Is obsolete:", isObsolete); } 1843 1844 private void printMVariableTableWithGenericReply(DataInputStream in) throws IOException { 1845 int slotsUsedByArgs= in.readInt(); 1846 int variablesCount= in.readInt(); 1847 println("Nb of slots used by all args:", slotsUsedByArgs); println("Nb of variables:", variablesCount); for (int i= 0; i < variablesCount; i++) { 1850 long codeIndex= in.readLong(); 1851 String name= readString(in); 1852 String signature= readString(in); 1853 String genericSignature= readString(in); 1854 int length= in.readInt(); 1855 int slotId= in.readInt(); 1856 println("First code index:", codeIndex); println("Variable name:", name); println("Variable type signature:", signature); println("Var. type generic signature:", genericSignature); println("Code index length:", length); println("Slot id:", slotId); } 1863 } 1864 1865 private void printOrDefaultCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1866 long objectId= readObjectID(in); 1867 println("Object id:", objectId); } 1869 1870 private void printOrReferenceTypeReply(DataInputStream in) throws IOException , UnableToParseDataException { 1871 byte refTypeTag= in.readByte(); 1872 long typeId= readReferenceTypeID(in); 1873 printRefTypeTag(refTypeTag); 1874 printlnReferenceTypeId("Type id:", typeId); } 1876 1877 private void printOrGetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1878 long objectId= readObjectID(in); 1879 int fieldsCount= in.readInt(); 1880 println("Object id:", objectId); println("Fields count:", fieldsCount); for (int i= 0; i < fieldsCount; i++) { 1883 long fieldId= readFieldID(in); 1884 println("Field id:", fieldId); } 1886 } 1887 1888 private void printOrGetValuesReply(DataInputStream in) throws IOException , UnableToParseDataException { 1889 int valuesCount= in.readInt(); 1890 println("Values count:", valuesCount); for (int i= 0; i < valuesCount; i++) { 1892 readAndPrintlnTaggedValue("Value:", in); } 1894 } 1895 1896 private void printOrSetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1897 long objectId= readObjectID(in); 1898 int fieldsCount= in.readInt(); 1899 println("Object id:", objectId); println("Fields count:", fieldsCount); throw new UnableToParseDataException("List of values: NOT MANAGED", remainderData(in)); } 1903 1904 private void printOrMonitorInfoReply(DataInputStream in) throws IOException , UnableToParseDataException { 1905 long ownerThreadId= readObjectID(in); 1906 int entryCount= in.readInt(); 1907 int waiters= in.readInt(); 1908 printlnObjectId("Owner thread id:", ownerThreadId); println("Entry count:", entryCount); println("Nb of waiters:", waiters); long waiterThreadId; 1912 for (int i= 0; i < waiters; i++) { 1913 waiterThreadId= readObjectID(in); 1914 printlnObjectId("Waiting thread id:", waiterThreadId); } 1916 } 1917 1918 private void printOrInvokeMethodCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1919 long objectId= readObjectID(in); 1920 long threadId= readObjectID(in); 1921 long classTypeId= readReferenceTypeID(in); 1922 long methodId= readMethodID(in); 1923 int argsCount= in.readInt(); 1924 printlnObjectId("Object id:", objectId); printlnObjectId("Thread id:", threadId); printlnReferenceTypeId("Class type id:", classTypeId); printlnMethodId("Method id:", methodId); println("Arguments count:", argsCount); for (int i= 0; i < argsCount; i++) { 1930 readAndPrintlnTaggedValue("Argument:", in); } 1932 int invocationOption= in.readInt(); 1933 printInvocationOptions(invocationOption); 1934 } 1935 1936 private void printOrInvokeMethodReply(DataInputStream in) throws IOException , UnableToParseDataException { 1937 readAndPrintlnTaggedValue("Return value:", in); byte signatureByte= in.readByte(); 1939 long exception= readObjectID(in); 1940 printlnTaggedObjectId("Exception object id:", exception, signatureByte); } 1942 1943 private void printOrIsCollectedReply(DataInputStream in) throws IOException { 1944 boolean isCollected= in.readBoolean(); 1945 println("Is collected:", isCollected); } 1947 1948 private void printSrValueCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1949 long stringObjectId= readObjectID(in); 1950 printlnObjectId("String object id:", stringObjectId); } 1952 1953 private void printSrValueReply(DataInputStream in) throws IOException { 1954 String value= readString(in); 1955 println("Value:", value); } 1957 1958 private void printTrDefaultCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1959 long threadId= readObjectID(in); 1960 printlnObjectId("Thread id:", threadId); } 1962 1963 private void printTrNameReply(DataInputStream in) throws IOException { 1964 String threadName= readString(in); 1965 println("Name:", threadName); } 1967 1968 private void printTrStatusReply(DataInputStream in) throws IOException { 1969 int threadStatus= in.readInt(); 1970 int suspendStatus= in.readInt(); 1971 printThreadStatus(threadStatus); 1972 printSuspendStatus(suspendStatus); 1973 } 1974 1975 private void printTrThreadGroupReply(DataInputStream in) throws IOException , UnableToParseDataException { 1976 long threadGroupId= readObjectID(in); 1977 printlnObjectId("Thread group id:", threadGroupId); } 1979 1980 private void printTrFramesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 1981 long threadId= readObjectID(in); 1982 int startFrame= in.readInt(); 1983 int length= in.readInt(); 1984 printlnObjectId("Thread id:", threadId); println("First frame:", startFrame); println("Number of frame:", length); } 1988 1989 private void printTrFramesReply(DataInputStream in) throws IOException , UnableToParseDataException { 1990 int framesCount= in.readInt(); 1991 println("Frames count:", framesCount); for (int i= 0; i < framesCount; i++) { 1993 long frameId= readFrameID(in); 1994 printlnFrameId("Frame id:", frameId); readAndPrintLocation(in); 1996 } 1997 } 1998 1999 private void printTrFrameCountReply(DataInputStream in) throws IOException { 2000 int framesCount= in.readInt(); 2001 println("Frames count:", framesCount); } 2003 2004 private void printTrOwnedMonitorsReply(DataInputStream in) throws IOException , UnableToParseDataException { 2005 int monitorsCount= in.readInt(); 2006 println("Monitors count:", monitorsCount); for (int i= 0; i < monitorsCount; i++) { 2008 byte signatureByte= in.readByte(); 2009 long monitorObjectId= readObjectID(in); 2010 printlnTaggedObjectId("Monitor object id:", monitorObjectId, signatureByte); } 2012 } 2013 2014 private void printTrCurrentContendedMonitorReply(DataInputStream in) throws IOException , UnableToParseDataException { 2015 byte signatureByte= in.readByte(); 2016 long monitorObjectId= readObjectID(in); 2017 printlnTaggedObjectId("Monitor object id:", monitorObjectId, signatureByte); } 2019 2020 private void printTrStopCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2021 long threadId= readObjectID(in); 2022 long exceptionObjectId= readObjectID(in); 2023 printlnObjectId("Thread id:", threadId); printlnObjectId("Exception object id:", exceptionObjectId); } 2026 2027 private void printTrSuspendCountReply(DataInputStream in) throws IOException { 2028 int suspendCount= in.readInt(); 2029 println("Suspend count:", suspendCount); } 2031 2032 private void printTgrDefaultCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2033 long threadGroupId= readObjectID(in); 2034 printlnObjectId("Thread group id:", threadGroupId); } 2036 2037 private void printTgrNameReply(DataInputStream in) throws IOException { 2038 String name= readString(in); 2039 println("Name:", name); } 2041 2042 private void printTgrParentReply(DataInputStream in) throws IOException , UnableToParseDataException { 2043 long parentThreadGroupId= readObjectID(in); 2044 printlnObjectId("Parent thread group id:", parentThreadGroupId); } 2046 2047 private void printTgrChildrenReply(DataInputStream in) throws IOException , UnableToParseDataException { 2048 int childThreadsCount= in.readInt(); 2049 println("Child threads count:", childThreadsCount); for (int i= 0; i < childThreadsCount; i++) { 2051 long childThreadId= readObjectID(in); 2052 printlnObjectId("Child thread id:", childThreadId); } 2054 int childGroupThreadsCount= in.readInt(); 2055 println("Child group threads count:", childGroupThreadsCount); for (int i= 0; i < childGroupThreadsCount; i++) { 2057 long childGroupThreadId= readObjectID(in); 2058 printlnObjectId("Child group thread id:", childGroupThreadId); } 2060 } 2061 2062 private void printArLengthCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2063 long arrayObjectId= readObjectID(in); 2064 printlnObjectId("Array object id:", arrayObjectId); } 2066 2067 private void printArLengthReply(DataInputStream in) throws IOException { 2068 int length= in.readInt(); 2069 println("Length:", length); } 2071 2072 private void printArGetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2073 long arrayObjectId= readObjectID(in); 2074 int firstIndex= in.readInt(); 2075 int length= in.readInt(); 2076 printlnObjectId("Array object id:", arrayObjectId); println("First index:", firstIndex); println("Length:", length); } 2080 2081 private void printArGetValuesReply(DataInputStream in) throws IOException , UnableToParseDataException { 2082 readAndPrintArrayRegion(in); 2083 } 2084 2085 private void printArSetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2086 long arrayObjectId= readObjectID(in); 2087 int firstIndex= in.readInt(); 2088 int length= in.readInt(); 2089 printlnObjectId("Array object id:", arrayObjectId); println("First index:", firstIndex); println("Length:", length); throw new UnableToParseDataException("List of values: NOT MANAGED", remainderData(in)); } 2094 2095 private void printClrVisibleClassesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2096 long classLoaderObjectId= readObjectID(in); 2097 printlnObjectId("Class loader object id:", classLoaderObjectId); } 2099 2100 private void printClrVisibleClassesReply(DataInputStream in) throws IOException , UnableToParseDataException { 2101 int classesCount= in.readInt(); 2102 println("Classes count:", classesCount); for (int i= 0; i < classesCount; i++) { 2104 byte refTypeTag= in.readByte(); 2105 long typeId= readReferenceTypeID(in); 2106 printRefTypeTag(refTypeTag); 2107 printlnReferenceTypeId("Type id:", typeId); } 2109 } 2110 2111 private void printErSetCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2112 byte eventKind= in.readByte(); 2113 byte suspendPolicy= in.readByte(); 2114 int modifiersCount= in.readInt(); 2115 printEventKind(eventKind); 2116 printSuspendPolicy(suspendPolicy); 2117 println("Modifiers count:", modifiersCount); for (int i= 0; i < modifiersCount; i++) { 2119 byte modKind= in.readByte(); 2120 printDescription("Modifier kind:"); printHex(modKind); 2122 switch (modKind) { 2123 case 1: println(" (Count)"); int count= in.readInt(); 2126 println("Count:", count); break; 2128 case 2: println(" (Conditional)"); int exprId= in.readInt(); 2131 println("Expression id:", exprId); break; 2133 case 3: println(" (ThreadOnly)"); long threadId= readObjectID(in); 2136 printlnObjectId("Thread id:", threadId); break; 2138 case 4: println(" (ClassOnly)"); long classId= readReferenceTypeID(in); 2141 printlnReferenceTypeId("Class type id:", classId); break; 2143 case 5: println(" (ClassMatch)"); String classPatern= readString(in); 2146 println("Class pattern:", classPatern); break; 2148 case 6: println(" (ClassExclude)"); classPatern= readString(in); 2151 println("Class pattern:", classPatern); break; 2153 case 7: println(" (LocationOnly)"); readAndPrintLocation(in); 2156 break; 2157 case 8: println(" (ExceptionOnly)"); long typeId= readReferenceTypeID(in); 2160 boolean caught= in.readBoolean(); 2161 boolean uncaught= in.readBoolean(); 2162 printlnReferenceTypeId("Exception type id:", typeId); println("Caught:", caught); println("Uncaught:", uncaught); break; 2166 case 9: println(" (FieldOnly)"); long declaringTypeId= readReferenceTypeID(in); 2169 long fieldId= readFieldID(in); 2170 printlnReferenceTypeId("Declaring type id:", declaringTypeId); printlnFieldId("Field id:", fieldId); break; 2173 case 10: println(" (Step)"); threadId= readObjectID(in); 2176 int stepSize= in.readInt(); 2177 int stepDepth= in.readInt(); 2178 printlnObjectId("Thread id:", threadId); printStepSize(stepSize); 2180 printStepDepth(stepDepth); 2181 break; 2182 case 11: println(" (InstanceOnly)"); long objectId= readObjectID(in); 2185 printlnObjectId("Object id:", objectId); break; 2187 } 2188 } 2189 } 2190 2191 private void printErSetReply(DataInputStream in) throws IOException { 2192 int requestId= in.readInt(); 2193 println("Request id:", requestId); } 2195 2196 private void printErClearCommand(DataInputStream in) throws IOException { 2197 byte eventKind= in.readByte(); 2198 int requestId= in.readInt(); 2199 printEventKind(eventKind); 2200 println("Request id:", requestId); } 2202 2203 private void printSfDefaultCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2204 long threadId= readObjectID(in); 2205 long frameId= readFrameID(in); 2206 printlnObjectId("Thread object id:", threadId); printlnFrameId("Frame id:", frameId); } 2209 2210 private void printSfGetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2211 long threadId= readObjectID(in); 2212 long frameId= readFrameID(in); 2213 int slotsCount= in.readInt(); 2214 printlnObjectId("Thread object id:", threadId); printlnFrameId("Frame id:", frameId); println("Slots count:", slotsCount); for (int i= 0; i < slotsCount; i++) { 2218 int slotIndex= in.readInt(); 2219 byte signatureTag= in.readByte(); 2220 println("Slot index:", slotIndex); printDescription("Signature tag:"); printSignatureByte(signatureTag, true); 2223 println(); 2224 } 2225 } 2226 2227 private void printSfGetValuesReply(DataInputStream in) throws IOException , UnableToParseDataException { 2228 int valuesCount= in.readInt(); 2229 println("Values count:", valuesCount); for (int i= 0; i < valuesCount; i++) { 2231 readAndPrintlnTaggedValue("Value:", in); } 2233 } 2234 2235 private void printSfSetValuesCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2236 long threadId= readObjectID(in); 2237 long frameId= readFrameID(in); 2238 int slotsCount= in.readInt(); 2239 printlnObjectId("Thread object id:", threadId); printlnFrameId("Frame id:", frameId); println("Slots count:", slotsCount); for (int i= 0; i < slotsCount; i++) { 2243 int slotIndex= in.readInt(); 2244 println("Slot index:", slotIndex); readAndPrintlnTaggedValue("Values:", in); } 2247 } 2248 2249 private void printSfThisObjectReply(DataInputStream in) throws IOException , UnableToParseDataException { 2250 byte signatureByte= in.readByte(); 2251 long objectId= readObjectID(in); 2252 printlnTaggedObjectId("'this' object id:", objectId, signatureByte); } 2254 2255 private void printCorReflectedTypeCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2256 long classObjectId= readObjectID(in); 2257 printlnObjectId("Class object id:", classObjectId); } 2259 2260 private void printCorReflectedTypeReply(DataInputStream in) throws IOException , UnableToParseDataException { 2261 byte refTypeTag= in.readByte(); 2262 long typeId= readReferenceTypeID(in); 2263 printRefTypeTag(refTypeTag); 2264 printlnReferenceTypeId("Type id:", typeId); } 2266 2267 private void printECompositeCommand(DataInputStream in) throws IOException , UnableToParseDataException { 2268 byte suspendPolicy= in.readByte(); 2269 int eventsCount= in.readInt(); 2270 printSuspendPolicy(suspendPolicy); 2271 println("Events count:", eventsCount); for (int i= 0; i < eventsCount; i++) { 2273 byte eventKind= in.readByte(); 2274 int requestId= in.readInt(); 2275 printEventKind(eventKind); 2276 println("Request id:", requestId); switch (eventKind) { 2278 case EVENTKIND_VM_START: 2279 long threadId= readObjectID(in); 2280 printlnObjectId("Initial thread object id:", threadId); break; 2282 case EVENTKIND_SINGLE_STEP: 2283 case EVENTKIND_BREAKPOINT: 2284 case EVENTKIND_METHOD_ENTRY: 2285 case EVENTKIND_METHOD_EXIT: 2286 threadId= readObjectID(in); 2287 printlnObjectId("Thread object id:", threadId); readAndPrintLocation(in); 2289 break; 2290 case EVENTKIND_EXCEPTION: 2291 threadId= readObjectID(in); 2292 readAndPrintLocation(in); 2293 byte signatureByte= in.readByte(); 2294 long objectId= readObjectID(in); 2295 printlnTaggedObjectId("Exception object id:", objectId, signatureByte); readAndPrintLocation(in); 2297 break; 2298 case EVENTKIND_THREAD_START: 2299 case EVENTKIND_THREAD_DEATH: 2300 threadId= readObjectID(in); 2301 printlnObjectId("Thread object id:", threadId); break; 2303 case EVENTKIND_CLASS_PREPARE: 2304 threadId= readObjectID(in); 2305 byte refTypeTag= in.readByte(); 2306 long typeId= readReferenceTypeID(in); 2307 String typeSignature= readString(in); 2308 int status= in.readInt(); 2309 printlnObjectId("Thread object id:", threadId); printRefTypeTag(refTypeTag); 2311 printlnReferenceTypeId("Type id:", typeId); println("Type signature:", typeSignature); println("Status:", status); break; 2315 case EVENTKIND_CLASS_UNLOAD: 2316 typeSignature= readString(in); 2317 println("Type signature:", typeSignature); break; 2319 case EVENTKIND_FIELD_ACCESS: 2320 threadId= readObjectID(in); 2321 printlnObjectId("Thread object id:", threadId); readAndPrintLocation(in); 2323 refTypeTag= in.readByte(); 2324 typeId= readReferenceTypeID(in); 2325 long fieldId= readFieldID(in); 2326 signatureByte= in.readByte(); 2327 objectId= readObjectID(in); 2328 printRefTypeTag(refTypeTag); 2329 printlnReferenceTypeId("Type id:", typeId); printlnFieldId("Field id:", fieldId); printlnTaggedObjectId("Object id:", objectId, signatureByte); break; 2333 case EVENTKIND_FIELD_MODIFICATION: 2334 threadId= readObjectID(in); 2335 printlnObjectId("Thread object id:", threadId); readAndPrintLocation(in); 2337 refTypeTag= in.readByte(); 2338 typeId= readReferenceTypeID(in); 2339 fieldId= readFieldID(in); 2340 signatureByte= in.readByte(); 2341 objectId= readObjectID(in); 2342 printRefTypeTag(refTypeTag); 2343 printlnReferenceTypeId("Type id:", typeId); printlnFieldId("Field id:", fieldId); printlnTaggedObjectId("Object id:", objectId, signatureByte); readAndPrintlnTaggedValue("Value:", in); break; 2348 case EVENTKIND_VM_DEATH: 2349 break; 2350 } 2351 } 2352 } 2353 2354 2359 private static String readString(DataInputStream in) throws IOException { 2360 int utfSize = in.readInt(); 2361 byte utfBytes[] = new byte[utfSize]; 2362 in.readFully(utfBytes); 2363 2364 StringBuffer strBuffer = new StringBuffer (utfSize / 3 * 2); 2365 for (int i = 0; i < utfSize;) { 2366 int a = utfBytes[i] & 0xFF; 2367 if ((a >> 4) < 12) { 2368 strBuffer.append((char) a); 2369 i++; 2370 } else { 2371 int b = utfBytes[i + 1] & 0xFF; 2372 if ((a >> 4) < 14) { 2373 if ((b & 0xBF) == 0) { 2374 throw new UTFDataFormatException ("Second byte input does not match UTF Specification"); } 2376 strBuffer.append((char) (((a & 0x1F) << 6) | (b & 0x3F))); 2377 i += 2; 2378 } else { 2379 int c = utfBytes[i + 2] & 0xFF; 2380 if ((a & 0xEF) > 0) { 2381 if (((b & 0xBF) == 0) || ((c & 0xBF) == 0)) { 2382 throw new UTFDataFormatException ("Second or third byte input does not mach UTF Specification_"); } 2384 strBuffer.append((char) (((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))); 2385 i += 3; 2386 } else { 2387 throw new UTFDataFormatException ("Input does not match UTF Specification"); } 2389 } 2390 } 2391 } 2392 return strBuffer.toString(); 2393 } 2394 2395 private byte[] remainderData(DataInputStream in) throws IOException { 2396 byte[] buffer= new byte[100]; 2397 byte[] res = new byte[0], newRes; 2398 int resLength= 0, length; 2399 while ((length= in.read(buffer)) != -1) { 2400 newRes= new byte[resLength + length]; 2401 System.arraycopy(res, 0, newRes, 0, resLength); 2402 System.arraycopy(buffer, 0, newRes, resLength, length); 2403 res= newRes; 2404 resLength += length; 2405 } 2406 return res; 2407 } 2408 2409 private long readObjectID(DataInputStream in) throws IOException , UnableToParseDataException { 2410 if (!TcpipSpy.hasSizes()) { 2411 throw new UnableToParseDataException("Unable to parse remaining data", remainderData(in)); } 2413 return readID(in, TcpipSpy.getObjectIDSize()); 2414 } 2415 2416 private long readReferenceTypeID(DataInputStream in) throws IOException , UnableToParseDataException { 2417 if (!TcpipSpy.hasSizes()) { 2418 throw new UnableToParseDataException("Unable to parse remaining data", remainderData(in)); } 2420 return readID(in, TcpipSpy.getReferenceTypeIDSize()); 2421 } 2422 2423 private long readFieldID(DataInputStream in) throws IOException , UnableToParseDataException { 2424 if (!TcpipSpy.hasSizes()) { 2425 throw new UnableToParseDataException("Unable to parse remaining data", remainderData(in)); } 2427 return readID(in, TcpipSpy.getFieldIDSize()); 2428 } 2429 2430 private long readMethodID(DataInputStream in) throws IOException , UnableToParseDataException { 2431 if (!TcpipSpy.hasSizes()) { 2432 throw new UnableToParseDataException("Unable to parse remaining data", remainderData(in)); } 2434 return readID(in, TcpipSpy.getMethodIDSize()); 2435 } 2436 2437 private long readFrameID(DataInputStream in) throws IOException , UnableToParseDataException { 2438 if (!TcpipSpy.hasSizes()) { 2439 throw new UnableToParseDataException("Unable to parse remaining data", remainderData(in)); } 2441 return readID(in, TcpipSpy.getFrameIDSize()); 2442 } 2443 2444 private long readID(DataInputStream in, int size) throws IOException { 2445 long id = 0; 2446 for (int i = 0; i < size; i++) { 2447 int b = in.readUnsignedByte(); id = id << 8 | b; 2449 } 2450 return id; 2451 } 2452 2453 private void readAndPrintlnTaggedValue(String description, DataInputStream in) throws IOException , UnableToParseDataException { 2454 byte tag= in.readByte(); 2455 readAndPrintlnUntaggedValue(description, in, tag, true); 2456 } 2457 2458 private void readAndPrintlnUntaggedValue(String description, DataInputStream in, byte tag, boolean printTagValue) throws IOException , UnableToParseDataException { 2459 printDescription(description); 2460 int size; 2461 boolean isId= false; 2462 switch (tag) { 2463 case VOID_TAG: 2464 printSignatureByte(tag, printTagValue); 2465 println(); 2466 return; 2467 case BOOLEAN_TAG: 2468 if (printTagValue) { 2469 printSignatureByte(tag, true); 2470 print(' '); 2471 println(in.readBoolean()); 2472 } else { 2473 println(in.readBoolean()); 2474 print(' '); 2475 printSignatureByte(tag, false); 2476 } 2477 return; 2478 case BYTE_TAG: 2479 size= 1; 2480 break; 2481 case CHAR_TAG: 2482 case SHORT_TAG: 2483 size= 2; 2484 break; 2485 case INT_TAG: 2486 case FLOAT_TAG: 2487 size= 4; 2488 break; 2489 case DOUBLE_TAG: 2490 case LONG_TAG: 2491 size= 8; 2492 break; 2493 case ARRAY_TAG: 2494 case OBJECT_TAG: 2495 case STRING_TAG: 2496 case THREAD_TAG: 2497 case THREAD_GROUP_TAG: 2498 case CLASS_LOADER_TAG: 2499 case CLASS_OBJECT_TAG: 2500 if (!TcpipSpy.hasSizes()) { 2501 throw new UnableToParseDataException("Unable to parse remaining data", remainderData(in)); } 2503 size= TcpipSpy.getObjectIDSize(); 2504 isId= true; 2505 break; 2506 default: 2507 size= 0; 2508 break; 2509 } 2510 2511 long value= readID(in, size); 2512 if (printTagValue) { 2513 printSignatureByte(tag, true); 2514 print(' '); 2515 } 2516 printHex(value, size); 2517 if (isId) { 2518 printParanthetical(value); 2519 } else { 2520 switch (tag) { 2521 case BYTE_TAG: 2522 printParanthetical((byte) value); 2523 break; 2524 case CHAR_TAG: 2525 printParanthetical((char) value); 2526 break; 2527 case SHORT_TAG: 2528 printParanthetical((short) value); 2529 break; 2530 case INT_TAG: 2531 printParanthetical((int) value); 2532 break; 2533 case FLOAT_TAG: 2534 printParanthetical(Float.intBitsToFloat((int) value)); 2535 break; 2536 case DOUBLE_TAG: 2537 printParanthetical(Double.longBitsToDouble(value)); 2538 break; 2539 case LONG_TAG: 2540 printParanthetical(value); 2541 break; 2542 } 2543 } 2544 if (!printTagValue) { 2545 print(' '); 2546 printSignatureByte(tag, false); 2547 } 2548 println(); 2549 } 2550 2551 private void printSignatureByte(byte signatureByte, boolean printValue) { 2552 String type; 2553 switch (signatureByte) { 2554 case VOID_TAG: 2555 type= "void"; break; 2557 case BOOLEAN_TAG: 2558 type= "boolean"; break; 2560 case BYTE_TAG: 2561 type= "byte"; break; 2563 case CHAR_TAG: 2564 type= "char"; break; 2566 case SHORT_TAG: 2567 type= "short"; break; 2569 case INT_TAG: 2570 type= "int"; break; 2572 case FLOAT_TAG: 2573 type= "float"; break; 2575 case DOUBLE_TAG: 2576 type= "double"; break; 2578 case LONG_TAG: 2579 type= "long"; break; 2581 case ARRAY_TAG: 2582 type= "array id"; break; 2584 case OBJECT_TAG: 2585 type= "object id"; break; 2587 case STRING_TAG: 2588 type= "string id"; break; 2590 case THREAD_TAG: 2591 type= "thread id"; break; 2593 case THREAD_GROUP_TAG: 2594 type= "thread group id"; break; 2596 case CLASS_LOADER_TAG: 2597 type= "class loader id"; break; 2599 case CLASS_OBJECT_TAG: 2600 type= "class object id"; break; 2602 default: 2603 type= "unknown"; break; 2605 } 2606 if (printValue) { 2607 printHex(signatureByte); 2608 print(" ("); print(signatureByte); 2610 print(" - "); } else { 2612 print(" ("); } 2614 print(type + ')'); 2615 } 2616 2617 private void readAndPrintLocation(DataInputStream in) throws IOException , UnableToParseDataException { 2618 byte typeTag= in.readByte(); 2619 long classId= readReferenceTypeID(in); 2620 long methodId= readMethodID(in); 2621 long index= in.readLong(); 2622 printlnReferenceTypeIdWithTypeTag("Location: class id:", classId, typeTag); printlnMethodId(" method id:", methodId); println(" index:", index); } 2626 2627 private void readAndPrintArrayRegion(DataInputStream in) throws IOException , UnableToParseDataException { 2628 byte signatureByte= in.readByte(); 2629 int valuesCount= in.readInt(); 2630 printDescription("Signature byte:"); printSignatureByte(signatureByte, true); 2632 println(); 2633 println("Values count:", valuesCount); switch (signatureByte) { 2635 case ARRAY_TAG: 2636 case OBJECT_TAG: 2637 case STRING_TAG: 2638 case THREAD_TAG: 2639 case THREAD_GROUP_TAG: 2640 case CLASS_LOADER_TAG: 2641 case CLASS_OBJECT_TAG: 2642 for (int i= 0; i < valuesCount; i ++) { 2643 readAndPrintlnTaggedValue("Value", in); } 2645 break; 2646 default: 2647 for (int i= 0; i < valuesCount; i ++) { 2648 readAndPrintlnUntaggedValue("Value", in, signatureByte, false); } 2650 break; 2651 } 2652 } 2653 2654 protected void println(String description, int value) { 2655 printDescription(description); 2656 printHex(value); 2657 printParanthetical(value); 2658 println(); 2659 } 2660 2661 protected void println(String description, long value) { 2662 printDescription(description); 2663 printHex(value); 2664 printParanthetical(value); 2665 println(); 2666 } 2667 2668 protected void println(String description, String value) { 2669 printDescription(description); 2670 print('\"'); 2671 StringBuffer val= new StringBuffer (); 2672 int pos= 0, lastPos= 0; 2673 while ((pos= value.indexOf('\n', lastPos)) != -1) { 2674 pos++; 2675 val.append(value.substring(lastPos, pos)); 2676 val.append(shift); 2677 lastPos= pos; 2678 } 2679 val.append(value.substring(lastPos, value.length())); 2680 print(val); 2681 println('"'); 2682 } 2683 2684 protected void println(String description, boolean value) { 2685 printDescription(description); 2686 println(value); 2687 } 2688 2689 protected void printlnReferenceTypeId(String description, long value) { 2690 println(description, value, TcpipSpy.getReferenceTypeIDSize()); 2691 } 2692 2693 protected void printlnReferenceTypeIdWithTypeTag(String description, long value, byte typeTag) { 2694 printDescription(description); 2695 printRefTypeTagValue(typeTag); 2696 print(" - "); printHex(value, TcpipSpy.getReferenceTypeIDSize()); 2698 printParanthetical(value); 2699 println(); 2700 } 2701 2702 protected void printlnObjectId(String description, long value) { 2703 printDescription(description); 2704 printHex(value, TcpipSpy.getObjectIDSize()); 2705 if (value == 0) { 2706 println(" (NULL)"); } else { 2708 printParanthetical(value); 2709 println(); 2710 } 2711 } 2712 2713 protected void printlnTaggedObjectId(String description, long value, byte signatureByte) { 2714 printDescription(description); 2715 printSignatureByte(signatureByte, true); 2716 print(' '); 2717 printHex(value, TcpipSpy.getReferenceTypeIDSize()); 2718 if (value == 0) { 2719 println(" (NULL)"); } else { 2721 printParanthetical(value); 2722 println(); 2723 } 2724 } 2725 2726 2727 protected void printlnFieldId(String description, long value) { 2728 println(description, value, TcpipSpy.getFieldIDSize()); 2729 } 2730 2731 protected void printlnMethodId(String description, long value) { 2732 println(description, value, TcpipSpy.getMethodIDSize()); 2733 } 2734 2735 protected void printlnFrameId(String description, long value) { 2736 println(description, value, TcpipSpy.getFrameIDSize()); 2737 } 2738 2739 protected void println(String description, long value, int size) { 2740 printDescription(description); 2741 printHex(value, size); 2742 printParanthetical(value); 2743 println(); 2744 } 2745 2746 protected void printDescription(String description) { 2747 int width = 38 - description.length(); 2749 print(description); 2750 write(padding, 0, width); 2751 } 2752 2753 protected void printHexString(String hex, int width) { 2754 width-= hex.length(); 2755 print("0x"); write(zeros, 0, width); 2757 print(hex); 2758 } 2759 2760 protected void printHex(long l, int byteNumber) { 2761 printHexString(Long.toHexString(l).toUpperCase(), byteNumber * 2); 2762 } 2763 2764 protected void printHex(byte b) { 2765 printHexString(Integer.toHexString(b & 0xFF).toUpperCase(), 2); 2766 } 2767 2768 protected void printHex(int i) { 2769 printHexString(Integer.toHexString(i).toUpperCase(), 8); 2770 } 2771 2772 protected void printHex(long l) { 2773 printHexString(Long.toHexString(l).toUpperCase(), 16); 2774 } 2775 2776 protected void printHex(byte[] b) { 2777 if (b == null) { 2778 println("NULL"); return; 2780 } 2781 int i, length; 2782 for (i= 0, length= b.length; i < length; i ++) { 2783 String hexa= Integer.toHexString(b[i]).toUpperCase(); 2784 if (hexa.length() == 1) { 2785 print('0'); 2786 } 2787 print(hexa); 2788 if ((i % 32) == 0 && i != 0) { 2789 println(); 2790 print(shift); 2791 } else { 2792 print(' '); 2793 } 2794 } 2795 println(); 2796 } 2797 2798 protected void printParanthetical(byte i) { 2799 print(" ("); print(i); 2801 print(')'); 2802 } 2803 2804 protected void printParanthetical(char i) { 2805 print(" ("); print(i); 2807 print(')'); 2808 } 2809 2810 protected void printParanthetical(short i) { 2811 print(" ("); print(i); 2813 print(')'); 2814 } 2815 2816 protected void printParanthetical(int i) { 2817 print(" ("); print(i); 2819 print(')'); 2820 } 2821 2822 protected void printParanthetical(long l) { 2823 print(" ("); print(l); 2825 print(')'); 2826 } 2827 2828 protected void printParanthetical(float f) { 2829 print(" ("); print(f); 2831 print(')'); 2832 } 2833 2834 protected void printParanthetical(double d) { 2835 print(" ("); print(d); 2837 print(')'); 2838 } 2839 2840 protected void printParanthetical(String s) { 2841 print(" ("); print(s); 2843 print(')'); 2844 } 2845 2846} 2847 | Popular Tags |