Copy stack: use jstack format

Questions about YourKit Java Profiler
Post Reply
plethora
Posts: 314
Joined: Thu Jun 02, 2005 8:36 pm

Copy stack: use jstack format

Post by plethora »

In the "Threads" view, I often use "copy stack" on the stack of the selected thread shown in the bottom pane.
It would be very convenient, if the format of the thread stack that YourKit puts on the system clipboard was similar to jstack.

For one, it would allow me to use the IntelliJ Analyze->Stacktrace feature.

At the moment, when I want to follow the stack of a give thread stack from frame to frame, I can of course also click, and the IDE integration will take me there.
However, especially when using only a single screen, this is far from an enjoyable UI experience. When clicking on a link shows you the source, but then you've lost the context (thread stack), and vice versa.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Copy stack: use jstack format

Post by Anton Katilin »

Hi Taras

I see your point, but it seems there is a technical problem.

IDEA's Analyze -> Stacktrace feature turns to clickable links only lines in format

Code: Select all

 at com.foo.ClassName.methodName(ClassName.java:<LineNumber>)
but not

Code: Select all

 at com.foo.ClassName.methodName(Unknown Source)
or

Code: Select all

 at com.foo.ClassName.methodName(Native Method)
That is, it allows to navigate only if the source code position, file and line, is known.

The problem is that the stacks in YourKit include methods but not the source code points <file name>:<line number>. Why it is so and whether there should be an ability/option to see the source code lines is subject to discuss. But the fact is that the current version does not have and all older versions never had the line number for the stacks.

As the result, we cannot present the stacks in that format now.

You can ask: But how the navigation feature works? How does it manage to find to the source code location inside the IDE? Well, it passes the method signature to IDE, and uses the IDE's internal code introspection API to locate the source code position. It always navigates to the beginning of the method body.

Which solutions I see:

1. Add line numbers. This requires serious changes and definitely will not be implemented in one of the version 12 updates.

2. Use the IDE's power to retrieve the line number. It could work like this:
- on attempt to produce the stack trace, the profiler UI collects the list of methods for which the source code is needed, and makes a call to the IDE plugin;
- the plugin retrieves the source positions for each of the methods, just like it does now when it navigates to source code from the profiler UI;
- the plugin sends the source code positions back to the profiler UI;
- the profiler UI generate the stacks.
But note: this will be a "strange" stack trace: the line numbers will always correspond to the method beginnings.

3. File a feature request to JetBrains, to make the lines without the source code position clickable too. Let it navigate to the beginning of the method.

I personally prefer #3, but not sure how fast they could implement this suggestion, if ever.
And #1 as a potential request for the future version.

Best regards,
Anton
plethora
Posts: 314
Joined: Thu Jun 02, 2005 8:36 pm

Re: Copy stack: use jstack format

Post by plethora »

Hi Anton,

#1 would be a nice feature request for YK 13.
Having stack traces with lines numbers (if available) would be useful beyond my specific use case.

Cheers,
Taras
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Copy stack: use jstack format

Post by Anton Katilin »

Hi Taras

Line numbers are available in version 2014.

Best regards,
Anton
Post Reply