oracle / visualvm

VisualVM is an All-in-One Java Troubleshooting Tool
https://visualvm.github.io/
Other
2.86k stars 299 forks source link

Show line numbers alongside all method names #408

Open cowwoc opened 2 years ago

cowwoc commented 2 years ago

Is your feature request related to a problem? Please describe. When a stack trace or GC trace references method invocations it's not clear which line number the method is on, especially when the trace references a lambda function.

Describe the solution you'd like Add line numbers to any entry that references a function, especially for lambdas.

Describe alternatives you've considered Convert lambdas to named methods, but this is a lot of work for large programs.

thurka commented 2 years ago

It would be great, if you can provide the screenshot to illustrate the issue. Thanks.

cowwoc commented 2 years ago

The situation is actually a bit more problematic than I had originally anticipated.

Sometimes you have the following entry in the stack trace:

void org.apache.sshd.common.util.closeable.SequentialCloseable$1

but sometimes you have:

void org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(CloseFuture)

As a user, I have no way of knowing which lambda function $1 refers to. In the first case, it would be helpful to output something along the lines of:

void org.apache.sshd.common.util.closeable.SequentialCloseable$1:52

where 52 denotes the beginning of the lambda function.

The second case is more problematic because the lambda shows up in the middle of the fully-qualified name.

Would inserting line numbers in the middle look odd? For example:

void org.apache.sshd.common.util.closeable.SequentialCloseable$1:52.operationComplete(CloseFuture)

Another approach would be to only add line numbers for last element in the fully-qualified name. For example:

void org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(CloseFuture):55

If I walk to line 55 then I might get an idea where $1 is relative to that method.

I'm not sure how to tackle this from a usability perspective, but certainly the first case should be easy to solve.

I'll try to attach a screenshot later on. I don't have any handy at the moment.

thurka commented 2 years ago

Screenshot will be useful. I still don't know if you are talking about profiler, sampler, heapviewer or plain thread dump.

thurka commented 2 years ago

BTW: You should be able to use 'Go to Source' and it will find the correct anonymous class and opens it in your favourite editor/IDE.

Marcono1234 commented 2 years ago

In my case it would be useful if VisualVM showed the line numbers in the Profiler CPU and Memory tab if that is possible (and the Profiler snapshot tab), and maybe also for the CPU sampler. Though I am not sure if that is what cowwoc meant as well.

In some cases setting up the Source Roots is more cumbersome than directly looking in the IDE where you are currently editing the source, or can easily browse the source of third party dependencies. Additionally it looks like 'Go to Source' does not work for Kotlin source files, so it is not an alternative in that case (or I have used it incorrectly). Though I have not tested the VisualVM IDE integrations yet.

cowwoc commented 2 years ago

@Marcono1234 Yes, that's what I meant.