Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Execution Traces

lzccc edited this page Oct 14, 2020 · 6 revisions

NOTE: This file is outdated, some information is incorrect.

Execution Traces

Execution traces will be shown in your console directly. You need to redirect the output or change the output source code if you want to them to be stored somewhere else.

Execution Trace Format

NOTE: This format is undergoing constant, minor changes, and as such, is unstable.

Event Types

Each line in a trace represents one of the three kinds of events:

  • Method Declaration Event: this means that the instrumentation of a method body has just begun
  • Instruction Event: this means that probe instructions for a certain instruction have been inserted in the enclosing class file, as a part of instrumenting a Java method.
  • Instruction Execution Event: this means that a certain instruction just got executed, or is about to be executed.

The format for each of the above event-types is stated below.

Method Declaration Event

Indicates that the instrumentation of a method body has just begun. Following is the format of such an event:

$$method$$,<ID>,<NAME>,<OWNER>,<ACCESS>
  • $$method$$: is a string literal that indicates the beginning of a method declaration log
    <ID> is a unique id assigned to the log of an method declaration event
    <NAME> name of the method
    <OWNER> owner-class where the method is declared and defined
    <ACCESS> an integer value that specifies the access modifiers (e.g. public, static, final, etc) of the method.

Instruction Event

Indicates that the probe instructions for a certain instruction have been inserted in the instruction's owner method, as a part of instrumenting the Java method. Following is the format of such an event:

INSTRUCTION_TYPE,ID,DECL_HOST_ID,LINE_NUMBER,BYTECODE_INDEX,OPCODE,OPERAND1,OPERAND2,OPERAND3;

<INSTRUCTION_TYPE> is one of the following string literals that gives a human readable indication of the kind of instruction --

  • $enter$
  • $exit$
  • $line$
  • $athrow$
  • $return$
  • $invoke$
  • $complete$
  • $var$
  • $jump$
  • $field$
  • $iinc$
  • $zero$
  • $constant$
  • $arrayload$
  • $arraystore$
  • $math$
  • $stack$
  • $type$
  • $compare$
  • $arraylen$
  • $monitor$
  • $switch$

<ID> is a unique id assigned to this instruction <DECL_HOST_ID> is <ID> value of a method declaration event -- for a method that contains this instruction
<LINE_NUMBER> is the actual line number (within a Java source file) of the actual instruction
<BYTECODE_INDEX> is the bytecode index of the actual instruction (within a Java class file)
<OPCODE> is the (byte-code) opcode value of the instruction
<OPERAND1> is the value of the first operand to the instruction (may be empty or null)
<OPERAND2> is the value of the second operand to the instruction (may be empty or null)
<OPERAND3> is the value of the third operand to the instruction (may be empty or null)

Instruction Execution Event

Represents that a certain instruction just got executed, or is about to be executed. Following is the format of such an event:

$$$,<ID>,<THREAD_ID>,<TIMESTAMP>,<CALL_DEPTH>,<DYN_HOST_ID>,<INSN_EVENT_ID>,<INSN_EVENT_TYPE>

< THREAD_ID > is obtained from the following code snippet: Thread.currentThread().getId(). It identifies the thread of execution along which the source code instruction was executed.
<ID> is a unique id assigned to an instruction execution.
<TIMESTAMP> is the time at which the instruction was executed.
<CALL_DEPTH> is the current call depth of the method, within which the instruction is executed.
<INSN_EVENT_ID> is value of instruction event that indicates the actual instruction being executed.
<INSN_EVENT_TYPE> is one of the string literals that gives a human readable indication of the kind of instruction, just as in the case of <INSTRUCTION_TYPE> in a instruction event.
<DYN_HOST_ID> is the dynamically observed system-hashcode for the this object iff the instruction is executed within a non-static method. This value is computed with the System.identityHashcode(Object object); method available in the Java SDK, and may not be the same as the hashcode() method available to all objects in Java. In the event of a static method, the name of the owner-class is recorded instead of a numeric hashcode value.

Negative Numbers and their Meaning in Execution Traces

Used as Opcodes

The entry into a method's execution does not have a byte code instruction, and thus no real opcode. So, -1, -2, -3, -4, and -5 are opcodes that identify various kinds of execution events:

  • -5 means that the execution has just entered a constructor's execution;
  • -4 means that the execution has just completed a method's execution;
  • -3 means that the execution has just entered a static method's execution;
  • -2 means that the execution has just entered a regular method's execution;
  • -1, when used as an opcode is used to indicate source code lines.
Used as Source Line Number

-1 is also used as "unknown line number". This will show up in "$enter$" or method-entry events, because the bytecode in any class file does not provide the source line number for a method's declaration ... Source Line number mapping in bytecode is available for only executable bytecode.