visualvm icon indicating copy to clipboard operation
visualvm copied to clipboard

Show line numbers alongside all method names

Open cowwoc opened this issue 2 years ago • 6 comments

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.

cowwoc avatar May 30 '22 20:05 cowwoc

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

thurka avatar Jun 01 '22 12:06 thurka

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.

cowwoc avatar Jun 03 '22 02:06 cowwoc

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

thurka avatar Jun 13 '22 10:06 thurka

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.

thurka avatar Jun 13 '22 11:06 thurka

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.

Marcono1234 avatar Aug 11 '22 22:08 Marcono1234

@Marcono1234 Yes, that's what I meant.

cowwoc avatar Aug 12 '22 15:08 cowwoc