Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Cannot debug graph visualisation #8043

Closed
kant2002 opened this issue Mar 18, 2020 · 6 comments · Fixed by #8045
Closed

Cannot debug graph visualisation #8043

kant2002 opened this issue Mar 18, 2020 · 6 comments · Fixed by #8045

Comments

@kant2002
Copy link
Contributor

I attempt to make a stab at the marshalling null values for COM, but stuck with producing correct IL. I decide that I'm smart guy and can enable debugging of the DependencyGraph. I'm not sure if this was correct decision, but that's not root cause of the issue which I encounter.

So I start follow Documentation\how-to-debug-compiler-dependency-analysis.md

  1. I setup csproj and include <IlcGenerateDgmlFile>true</IlcGenerateDgmlFile>
  2. I configure to use locally built version of CoreRT.
  3. Launch VS as admin and open ILCompiler-DependencyGraph-Viewer.sln
  4. Launch dotnet publish as admin
  5. Launch ILCompiler-DependencyGraph-Viewer inside VS

events was not there.
Under debugger, line below return false into restarted variable.

var restarted = session.EnableProvider("Microsoft-ILCompiler-DependencyGraph");

I suspect that this is related to enabling ETW somehow, or maybe I miss some other step?

@MichalStrehovsky
Copy link
Member

Can you try leaving out this: <IlcGenerateDgmlFile>true</IlcGenerateDgmlFile>? I don't think the dependency graph support multiple simultaneous logging facilities.

@MichalStrehovsky
Copy link
Member

I don't think the dependency graph will help you though. Try adding --ildump path\to\some\file.il to the ILCompiler command line. This will generate a file with all the generated IL that you can set breakpoints on/step in the debugger.

If you're not even getting that far (e.g. RyuJIT is crashing while compiling the method), your only option is to look at the generated IL in the debugger. We have a debugger visualizer for the MethodIL class so that the VS debugger can show you the IL in a nice format. Set up a breakpoint and inspect the generated MethodIL somewhere around PInvokeILEmitter.EmitIL

@kant2002
Copy link
Contributor Author

Removing <IlcGenerateDgmlFile>true</IlcGenerateDgmlFile> indeed help. I was confused by this line:
6d088c2#diff-b6a2437f0be65e16801de473eb0316cdR10
I now realize that this is out of context. But maybe I can add word that dependency graph do not support multiple simultaneous logging facilities, so make sure that you do not set IlcGenerateDgmlFile or invoke ILCompiler ith DGML generation on.

I will try --ildump, thanks. that seems to be what I need. Do you know how to fast sketch IL? or you just know it by heart 😄

@MichalStrehovsky
Copy link
Member

Yup, that line would be useful to add.

I used to write a piece of equivalent C#, compile with optimizations on, and disassemble that. But yes, at this point I know most of the important patterns by heart.

@kant2002
Copy link
Contributor Author

Sign. I hope that you know some C# godbolt which can allow me write snippet and see the view of IL. Upon search I found https://sharplab.io/ Is it helpful to use? Because IL optimization likely can be trivial. Or I am miss something important? I'm more or less know IL. Have rusty knowledge and lack of practice.

Also for Windows Forms DGML output and DependencyGraphViewer almost impractical to use 200Mb for trivial app.

@MichalStrehovsky
Copy link
Member

Yeah, sharplab.io should work. I use csc.exe/ildasm.exe but that's just because I grew up without internet.

Yeah, the DGML is proportional to the size of the app. Windows.Forms drags in a lot of stuff.

MichalStrehovsky pushed a commit that referenced this issue Mar 20, 2020
* Improve documentation around Dependency analysis
- Clarify not supported usage for ILCompiler-DependencyGraph-Viewer
- Mention about existence of WhyDGML tool
Closes: #8044, #8043
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants