How to get source line number in JQF
xxwxxwen opened this issue · 3 comments
I have read issue #186.But I still feel a little puzzled. TraceEvent has a field lineNumber. Does this lineNum in TraceEvent mean byte code line number? How can get source line number? How can byte code line number match corresponds to source line when running program not from console?
In JQF, can we get covered basic block? Thank you for your help!
Yes, it is the line number from source code. There is no concept of line number in bytecode. There is a bytecode offset (in bytes) from the method start, but that is not recorded. Line number will only be available if the Java classes are compiled with debug info enabled, otherwise they will be missing (I think it defaults to -1 or something).
I don't see why it matters whether the program is launched from console or elsewhere.
JQF does not track basic blocks. It only instruments branch coverage by logging conditional jumps, calls, and returns.
Yes, it is the line number from source code. There is no concept of line number in bytecode.
I should clarify: JQF still gets the line number info from the .class
files, so it's stored in the bytecode. However, the line number corresponds to the line in the corresponding .java
file whose expression was compiled down to a particular bytecode instruction. There can be many bytecode instructions for the same .java
line number, so they are not unique. The iid
field represents a unique identifier for each bytecode instruction.
@rohanpadhye Thank you for your quick reply.