Hooking up the Profiler

Hello again, can anyone give me pointers about how to make Profilers work with a custom language.  I can start the Profiler (JProfiler) on my Clojure code, and I get information about which function is using how much time.  However, when I say "Go To Source", it doesn't know where to go.

I have looked at the PositionManager which I believe maps debug information to actual lines in files.  However, I haven't figured out how it called during profiling.  I assume that it must be similar to how the Debugger works.

Is there documentation on this, or can someone tell me where to look in the Groovy plugin code.

Thanks
Peter

5 comments
Comment actions Permalink

Hello Peter,

I fear there's currently not much you can do about it, as IDEA doesn't
have a standard way for profiler navigation. I don't know how other
profilers work, but in the case of JProfiler the source navigation is
handled by the JProfiler plugin, based on the PSI tree of the
corresponding Java source file. And as the JProfiler plugin doesn't know
anything about the PSI representation of a Clojure source file, there's
no way that it could navigate there.

The only option you have is to ask JetBrains to invent some standard way
for profiler navigation, where a custom language plugin can provide its
own implementation.

Regards,
Martin

Peter Wolf wrote:

Hello again, can anyone give me pointers about how to make Profilers work with a custom language. I can start the Profiler (JProfiler) on my Clojure code, and I get information about which function is using how much time. However, when I say "Go To Source", it doesn't know where to go.

I have looked at the PositionManager which I believe maps debug information to actual lines in files. However, I haven't figured out how it called during profiling. I assume that it must be similar to how the Debugger works.

Is there documentation on this, or can someone tell me where to look in the Groovy plugin code.

Thanks
Peter

---
Original message URL: http://www.jetbrains.net/devnet/message/5230325#5230325


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0
Comment actions Permalink

Thanks Martin,

Just for my own understanding...  Is this right?

Both the Profiler and Debugger use an implementation of PositionManager to map byte code positions to source code.

In the case of JProfiler, that implementation of PositionManager is part of the JProfiler plugin, and I can't get at it.

In the case of the Debugger, the implementation is provided by the CustomLanguage plugin, which is my code.  If so, how does the Debugger find my PositionManager?

I am currently working on the Debugger, so this is a very useful conversation

Thanks
Peter

0
Comment actions Permalink

The (J)Profiler doesn't use a PositionManager at all. It uses the PSI
interface to find the correct class file and then searches manually
through the PSI tree to find the matching method (by comparing method
name and parameter info). And of course the way how JProfiler transmits
the current class and method information to the JProfiler plugin is a
proprietary interface.

The debugger on the other hand indeed uses a PositionManager which is
provided by your plugin. But I don't know how you have to register it.
In the case of a JavaEE plugin there is some code like this:

DebuggerManager.getInstance(project).addDebugProcessListener(handler,
new DebugProcessAdapter() {
@Override
public void processAttached(DebugProcess process) {
process.appendPositionManager(createPositionManager(process));
}
});

Both the Profiler and Debugger use an implementation of PositionManager to map byte code positions to source code.

In the case of JProfiler, that implementation of PositionManager is part of the JProfiler plugin, and I can't get at it.

In the case of the Debugger, the implementation is provided by the CustomLanguage plugin, which is my code. If so, how does the Debugger find my PositionManager?

I am currently working on the Debugger, so this is a very useful conversation

Thanks
Peter

---
Original message URL: http://www.jetbrains.net/devnet/message/5230663#5230663


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0
Comment actions Permalink

Excellent.  Thank you!

Since the last message, I have actually gotten my PositionManager to be called.  I added an Application Component, and put this code in the initComponent() method

  public void initComponent() {

    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
      public void projectOpened(final Project project) {

        DebuggerManager.getInstance(project).registerPositionManagerFactory(new Function<DebugProcess, PositionManager>() {
          public PositionManager fun(DebugProcess debugProcess) {
            return new ClojurePositionManager(debugProcess);
          }
        });
      }
    });
  }

I am now trying to understand how it works.  Do you know what any of these methods do?

    public ClassPrepareRequest createPrepareRequest(final ClassPrepareRequestor requestor, final SourcePosition position)

    public SourcePosition getSourcePosition(final Location location)
    public List<ReferenceType> getAllClasses(final SourcePosition position)

Also, is there a default PositionManager implementation I can use if I want to treat Clojure as compiled Java?  This would be similar to the old Groovy plugin.

Thanks
Peter

0
Comment actions Permalink

Sorry, that's outside of my knowledge now. I don't have any experience
with debugger support in custom languages.

--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0

Please sign in to leave a comment.