Home » Archived » Test and Performance Tools Platform (TPTP) » Identifying Executed Lines of Code Using ProbeKit (2)
Identifying Executed Lines of Code Using ProbeKit (2) [message #83194] |
Tue, 12 September 2006 10:37  |
Eclipse User |
|
|
|
Originally posted by: aheydarn.cs.uwaterloo.ca
Hi,
I used an executableUnit fragment to print out the line numbers of the code
that were executed during a program run. For this purpose, I used the
following code in this fragment:
System.out.println(spaces + "Line Number: " + myLineNumber);
In the above code, myLineNumber is of type executableUnitNumber. Now, the
program prints out the line numbers of code that were executed. However, for
loops (e.g., for, while, ...) the result is somehow strange. For example, it
prints out 0, 1, 2, 5, 6, 7, and so on. It seems that a loop is being
translated into a number of lines of code. Am I right? Does TPTP uses
three-address method for translating Java programs? If yes, do you know what
method of translation is used (e.g., Jimple)?
Thanks a lot in advance for your help,
All the best,
Abbas
|
|
|
Re: Identifying Executed Lines of Code Using ProbeKit (2) [message #83392 is a reply to message #83194] |
Tue, 12 September 2006 18:22  |
Eclipse User |
|
|
|
Originally posted by: nmehrega.ca.ibm.com
This is a multipart message in MIME format.
--=_alternative 007ADE2F852571E7_=
Content-Type: text/plain; charset="US-ASCII"
Hi Abbas,
One thing to keep in mind is that executable unit number is NOT the same
thing as source line number. I think you might have confused the two. To
get source line numbers, you need to use a data item of type
methodLineTables, which is an encoded list of line numbers that correspond
with every executable unit of code in the class Please see the Probekit
help content for information on how it's encoded. In Eclipse, just click
on help -> help contents -> type in 'method line table' in the search text
box -> Click on 'The methodLineTables data string format'.
I get a different output for my loops than you do. I experimented with the
following class:
public class MainClass {
public static void main(String[] args) throws Exception {
int x = 0;
for (int i=0; i < 5; i++)
{
x++;
}
}
}
My probe consisted of an executableUnit fragment, which printed the
following:
System.out.println("[" + myClassName + "." + myMethodName + "]" + "
Executable Unit: " + myExecutableNumber + " Method Line Table: " +
myMethodLineTable);
myExecutableNumber is of type executableUnitNumber and myMethodLineTable
is of type methodLineTables. Here's the output when I instrumented
MainClass with this probe:
[MainClass.main] Executable Unit: 0 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 1 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04
[MainClass.main] Executable Unit: 5 Method Line Table: +10,312#5+04
Notice the repeat in the executable unit numbers, thus indicating a loop
in the class (0, 1, 4, 2, 3, 4, 2, 3, ...., 5). These are just the number
of executable units that it executes. Please see the help content to see
how you can map the executable units with the source line number by using
the method line table.
Navid Mehregani
--=_alternative 007ADE2F852571E7_=
Content-Type: text/html; charset="US-ASCII"
<br><font size=2 face="sans-serif">Hi Abbas,</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
One thing to keep in mind is that executable unit number is NOT the same
thing as source line number. I think you might have confused the
two. To get source line numbers, you need to use a data item of type
methodLineTables, which is an encoded list of line numbers that correspond
with every executable unit of code in the class Please see
the Probekit help content for information on how it's encoded. In
Eclipse, just click on help -> help contents -> type in 'method line
table' in the search text box -> Click on 'The methodLineTables data
string format'.</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
I get a different output for my loops than you do. I experimented with
the following class:</font><font size=3> <br>
</font><font size=2 color=#820040 face="Courier New"><b><br>
public</b></font><font size=2 face="Courier New"> </font><font size=2 color=#820040 face="Courier New"><b>class</b></font><font size=2 face="Courier New">
MainClass {</font><font size=3> <br>
</font><font size=2 face="Courier New"><br>
</font><font size=2 color=#820040 face="Courier New"><b>public</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>static</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>void</b></font><font size=2 face="Courier New">
main(String[] args) </font><font size=2 color=#820040 face="Courier New"><b>throws</b></font><font size=2 face="Courier New">
Exception {</font><font size=3> </font><font size=2 face="Courier New"><br>
</font><font size=2 color=#820040 face="Courier New"><b>int</b></font><font size=2 face="Courier New">
x = 0;</font><font size=3> </font><font size=2 face="Courier New"><br>
</font><font size=2 color=#820040 face="Courier New"><b>for</b></font><font size=2 face="Courier New">
(</font><font size=2 color=#820040 face="Courier New"><b>int</b></font><font size=2 face="Courier New">
i=0; i < 5; i++)</font><font size=3> </font><font size=2 face="Courier New"><br>
{</font><font size=3>
</font><font size=2 face="Courier New"><br>
x++;</font><font size=3> </font><font size=2 face="Courier New"><br>
}</font><font size=3>
</font><font size=2 face="Courier New"><br>
}</font><font size=3> </font><font size=2 face="Courier New"><br>
}</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
My probe consisted of an executableUnit fragment, which printed the following:</font><font size=3>
<br>
</font><font size=1 face="Tahoma"><br>
System.out.println(</font><font size=1 color=#4200ff face="Tahoma">"["</font><font size=1 face="Tahoma">
+ myClassName + </font><font size=1 color=#4200ff face="Tahoma">"."</font><font size=1 face="Tahoma">
+ myMethodName + </font><font size=1 color=#4200ff face="Tahoma">"]"</font><font size=1 face="Tahoma">
+ </font><font size=1 color=#4200ff face="Tahoma">" Executable
Unit: "</font><font size=1 face="Tahoma"> + myExecutableNumber + </font><font size=1 color=#4200ff face="Tahoma">"
Method Line Table: "</font><font size=1 face="Tahoma"> + myMethodLineTable);</font><font size=3>
<br>
</font><font size=2 face="sans-serif"><br>
myExecutableNumber is of type executableUnitNumber and myMethodLineTable
is of type methodLineTables. Here's the output when I instrumented
MainClass with this probe:</font><font size=3> <br>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 0 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 1 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 2 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 3 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 4 Method Line Table: +10,312#5+04</font><font size=3>
</font><font size=2 face="Courier New"><br>
[MainClass.main] Executable Unit: 5 Method Line Table: +10,312#5+04</font><font size=3>
<br>
</font><font size=2 face="sans-serif"><br>
Notice the repeat in the executable unit numbers, thus indicating a loop
in the class (0, 1, 4, 2, 3, 4, 2, 3, ...., 5). These are just the
number of executable units that it executes. Please see the help
content to see how you can map the executable units with the source line
number by using the method line table.</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
Navid Mehregani</font>
--=_alternative 007ADE2F852571E7_=--
|
|
|
Goto Forum:
Current Time: Sun Jun 01 10:05:46 EDT 2025
Powered by FUDForum. Page generated in 0.02402 seconds
|