I'm running
java -cp some:jars:out \
-agentlib:hprof=cpu=times,format=a,file=java.hprof.txt,lineno=y,doe=y com.foo.Benchmark \
< /dev/null
and in the output I get stack frames without line numbers
THREAD START (obj=50000150, id = 200002, name="HPROF gc_finish watcher", group="system")
THREAD START (obj=50000151, id = 200001, name="main", group="main")
THREAD START (obj=50000281, id = 200003, name="Thread-1", group="main")
THREAD END (id = 200003)
THREAD END (id = 200001)
THREAD START (obj=500002a5, id = 200004, name="DestroyJavaVM", group="main")
THREAD END (id = 200004)
TRACE 307081:
com.foo.Benchmark.methodName(Benchmark.java:Unknown line)
com.foo.Benchmark.anotherMethodName(Benchmark.java:Unknown line)
...
If I change lineno=y to lineno=n I still get Unknown line.
I compiled the classes with -g. My javac looks like
javac -g -Xlint -encoding UTF-8 -source 1.5 -d out -classpath ... src/main/com/foo/*.java
I checked the .class files to make sure they have line numbers:
javap -classpath out -c -l com.foo.Benchmark
shows plenty of things like
LineNumberTable:
line 1077: 0
line 1078: 8
line 1079: 14
line 1080: 21
line 1082: 23
line 1083: 31
line 1084: 43
Am I using some flag combination that prevents line number output?
I faced exactly the same problem, but compiling the source with -g helped. After compiling with -g, I see the line numbers like this (which I don't see otherwise, without -g option) -
LineNumberTable:
line 16: 0
line 17: 8
line 18: 12
line 19: 20
line 18: 29
line 21: 35
Now, if I run this -
java -cp "./build/classes" -agentlib:hprof=heap=sites,depth=20 org.sample.welcome.Main a b c
I do get the line numbers for the user-defined classes. Even though I am not sure what's going wrong in your case, these are my observations -
Using javac without -g: If I have -lineno (default y) set to y, I still don't see the line numbers for most of the classes except for the user-defined classes (Main in the above case). If I've set -lineno to n, then I won't see line numbers for any of the classes anyway.
Using javac with -g: If I have -lineno set to y, I can see the line numbers for all the classes (not sure what's going wrong in your case).
The only documentation I could find for HPROF doesn't say anything beyond this. I think one option would be to try with fewer optional arguments and see the results.
Note: I'm using JDK 1.6 in the above example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With