Open spouliot opened 2 years ago
Trying to decompile one of the methods shows
private void MoveNext()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
...
The first block is:
IL_004d: callvirt instance valuetype [System.Runtime]System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1<!0> class [System.Runtime]System.Threading.Tasks.Task`1<class Foundation.NSUrlRequest>::ConfigureAwait(bool) /* 0A000BCE */
IL_0052: stloc.s 5
IL_0054: ldloca.s 5
IL_0056: call instance valuetype [System.Runtime]System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1/ConfiguredTaskAwaiter<!0> valuetype [System.Runtime]System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1<class Foundation.NSUrlRequest>::GetAwaiter() /* 0A000BCF */
so maybe it just needs to find System.Runtime
...
Nope, that did not help :|
I tried your tool, but it does not give me the same output on Windows. No errors are reported using it on Microsoft.iOS.dll
with a PDB generated by ILSpy. However, I found a difference between ILSpy and other PDB tools. I will push a fix soon, but I am not sure, if it will fix all your problems, because I cannot reproduce the Cecil crashes using your tool.
I'm on a Mac computer. Is there Windows (or Mac) specific code paths for PDB ?
Anyway I'll be trying your fix once pushed, thanks for looking :)
It works for me when using the Avalonia version of ILSpy (version 7.2.0.0.rc) on the Mac.
So I could be an issue (only) with ilspycmd
. Or there's something broken in master
(that I used to build ilspycmd
) versus the latest release of ILSpy/Avalonia
Did you try using the command tool ?
I tried ILSpy master and the released version of ilspycmd, that is 7.2.1.6856 (via dotnet tool install). It's interesting that it's the same version that ILSpyAvalonia is using currently: https://github.com/icsharpcode/AvaloniaILSpy/blob/master/ILSpy.Core/ILSpy.Core.csproj#L32
I have pushed two commits that fix some of the issues I saw. Can you please try again? Thanks!
In my original report I used the prebuilt tools (ilspycmd
and ILSpy/Avalonia).
This time I
Updated ILSpy repo to f2da2552001b1a77499f6821b6a7ce784aff416e (current HEAD) and ensure I had no local diff
I copied the latest Microsoft.iOS.dll|.pdb
to a tmp
directory
cp /usr/local/share/dotnet//packs/Microsoft.iOS.Runtime.iossimulator-x86/16.0.523/runtimes/iossimulator-x86/lib/net6.0/* tmp/
dotnet
cd ILSpy
git clean -xfd
cd ICSharpCode.ILSpyCmd
dotnet run -- -genpdb /Users/poupou/git/external/uno/uno.vscode/tmp/Microsoft.iOS.dll -usepdb /Users/poupou/git/external/uno/uno.vscode/tmp/Microsoft.iOS.pdb
This is hitting Debug.Assert
conditions
/Users/poupou/.nuget/packages/microsoft.build.tasks.git/1.1.1/build/Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file '/Users/poupou/git/external/ILSpy/ILSpy-tests/.git'. The source code won't be available via Source Link. [/Users/poupou/git/external/ILSpy/ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj]
/Users/poupou/.nuget/packages/microsoft.build.tasks.git/1.1.1/build/Microsoft.Build.Tasks.Git.targets(25,5): warning : Could not find file '/Users/poupou/git/external/ILSpy/ILSpy-tests/.git'. The source code won't be available via Source Link. [/Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj]
Process terminated. Assertion failed.
Duplicate sequence point definition detected: 060186C5
at ICSharpCode.Decompiler.DebugInfo.PortablePdbWriter.<>c__DisplayClass2_0.<WritePdb>g__ProcessMethod|6(MethodDefinitionHandle method, DocumentHandle document, List`1 sequencePoints, SyntaxTree syntaxTree) in /Users/poupou/git/external/ILSpy/ICSharpCode.Decompiler/DebugInfo/PortablePdbWriter.cs:line 261
at ICSharpCode.Decompiler.DebugInfo.PortablePdbWriter.WritePdb(PEFile file, CSharpDecompiler decompiler, DecompilerSettings settings, Stream targetStream, Boolean noLogo, Nullable`1 pdbId, IProgress`1 progress) in /Users/poupou/git/external/ILSpy/ICSharpCode.Decompiler/DebugInfo/PortablePdbWriter.cs:line 141
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.GeneratePdbForAssembly(String assemblyFileName, String pdbFileName, CommandLineApplication app) in /Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs:line 322
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecute>g__PerformPerFileAction|48_0(String fileName, <>c__DisplayClass48_0& ) in /Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs:line 198
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.OnExecute(CommandLineApplication app) in /Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs:line 144
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<Apply>b__0(CancellationToken ct)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](IConsole console, String[] args)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](String[] args)
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.Main(String[] args) in /Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs:line 51
If I try the same in a release build (dotnet publish -c Release
) it gets farther (takes more time and modifies the .pdb file) but it still fails.
./ilspycmd -genpdb /Users/poupou/git/external/uno/uno.vscode/tmp/Microsoft.iOS.dll -usepdb /Users/poupou/git/external/uno/uno.vscode/tmp/Microsoft.iOS.pdb
ICSharpCode.Decompiler.Metadata.PEFileNotSupportedException: PE file does not contain any managed metadata.
at ICSharpCode.Decompiler.Metadata.PEFile..ctor(String fileName, PEReader reader, MetadataReaderOptions metadataOptions) in /Users/poupou/git/external/ILSpy/ICSharpCode.Decompiler/Metadata/PEFile.cs:line 70
at ICSharpCode.Decompiler.Metadata.PEFile..ctor(String fileName, Stream stream, PEStreamOptions streamOptions, MetadataReaderOptions metadataOptions) in /Users/poupou/git/external/ILSpy/ICSharpCode.Decompiler/Metadata/PEFile.cs:line 61
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.GeneratePdbForAssembly(String assemblyFileName, String pdbFileName, CommandLineApplication app) in /Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs:line 308
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.<OnExecute>g__PerformPerFileAction|48_0(String fileName, <>c__DisplayClass48_0& ) in /Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs:line 198
at ICSharpCode.ILSpyCmd.ILSpyCmdProgram.OnExecute(CommandLineApplication app) in /Users/poupou/git/external/ILSpy/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs:line 144
If I do not specify -usepdb
then there's no error - but I thought I needed that to get the original information, like variable names right ?
The build works but the decompiled sources are not visible in the debugger and the .pdb
is only 13MB. The working (with sources) version (from ILSpy/Avalonia) was 20MB.
Maybe I missing a step somewhere ?
Ok, so there is multiple issues:
1) The assertion regarding Duplicate sequence point definition
is due ILSpy's inability to recognize some async state-machines. Unfortunately, ilspycmd has no way to "ignore" the assertion, unlike "ILSpy for Windows ". Compiling in release mode will fix that.
2) If you look at the command line help of ilspycmd, you will see that -usepdb
does not accept an argument. The PDB file is treated as normal DLL by ilspycmd and when it tries to load it, it fails with "PE file does not contain any managed metadata", because the PDB file is not a full PE image. -usepdb
will cause ilspycmd to automatically resolve and load the PDB file next to the DLL.
Regarding the differences in file size... I will have to investigate further, but you can always look at the PDB file in ILSpy and check if the Document
table contains any rows...
From what I can see, it seems that the PDB generated by ILSpy is fine:
That makes sense. Thanks for the help!
Sadly ILSpy/Avalonia does not show the metadata tables :( but I can check that with some code...
or UPS will finally deliver me my volterra devkit and I'll have a window box again (after more than 15 years)
So after doing a (more proper) ./ilspycmd -genpdb tmp/Microsoft.iOS.dll -usepdb
I have no error (as expected) but don't get any document (0x30) from the assembly... binaries attached
Don't know which tool you used in that screenshot, but it's somehow broken. This is what ILSpy shows for the files you provided:
I see them on Windows too. I noticed the workload number changed so I might have copied the pdb to the older location... I'll restart this from scratch and compare the results (myself) on Windows.
Background
The iOS SDK does not use Source Link and also does not embed sources inside PDB (which would be quite useful for the generated code). I thought ILSpy could help :)
Steps to reproduce
Both
and
were tried.
Original files: Microsoft.iOS.zip
Error message shown
Versions
More details
I have hit a few PDB issues in the past so I wrote a tool to see what could be wrong in them (or Cecil).
The output I get is:
Microsoft.iOS
CoreFoundation.CFNetwork/d15 / System.Void CoreFoundation.CFNetwork/d 15::MoveNext()
System.Net.Http.NSUrlSessionHandler/NSUrlSessionDataTaskStream/d14 / System.Void System.Net.Http.NSUrlSessionHandler/NSUrlSessionDataTaskStream/d 14::MoveNext()
System.Net.Http.NSUrlSessionHandler/d57 / System.Void System.Net.Http.NSUrlSessionHandler/d 57::MoveNext()
System.Net.Http.NSUrlSessionHandler/d58 / System.Void System.Net.Http.NSUrlSessionHandler/d 58::MoveNext()
System.Net.Http.CFContentStream/d10 / System.Void System.Net.Http.CFContentStream/d 10::MoveNext()
System.Net.Http.CFNetworkHandler/d19 / System.Void System.Net.Http.CFNetworkHandler/d 19::MoveNext()
System.Net.Http.CFNetworkHandler/d20 / System.Void System.Net.Http.CFNetworkHandler/d 20::MoveNext()
Compression.CompressionStream/CopyToAsyncStream/d8 / System.Void Compression.CompressionStream/CopyToAsyncStream/d 8::MoveNext()
Compression.CompressionStream/CopyToAsyncStream/d9 / System.Void Compression.CompressionStream/CopyToAsyncStream/d 9::MoveNext()
Compression.CompressionStream/d41 / System.Void Compression.CompressionStream/d 41::MoveNext()
Compression.CompressionStream/d73 / System.Void Compression.CompressionStream/d 73::MoveNext()
Compression.CompressionStream/d74 / System.Void Compression.CompressionStream/d 74::MoveNext()