Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get source line number in JQF #206

Closed
xxwxxwen opened this issue Nov 16, 2022 · 3 comments
Closed

How to get source line number in JQF #206

xxwxxwen opened this issue Nov 16, 2022 · 3 comments

Comments

@xxwxxwen
Copy link

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!

@rohanpadhye
Copy link
Owner

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.

@rohanpadhye
Copy link
Owner

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.

@xxwxxwen
Copy link
Author

@rohanpadhye Thank you for your quick reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants