使用 nuget 进行单声道调试

Mono debugging with nuget

我有一个问题,当前的单声道不能与我的一个包的当前 nuget 一起使用。它无限期地挂在 CPU 上。这似乎是单声道运行时的一个错误,但我不确定。

我想调试它,但我不知道该怎么做。我已经使用 pdb 生成了 nuget.exe 的调试版本,但现在该怎么办?我尝试了 xamarin studio(在 windows 上),它不允许我启动单声道进程并中断它。

知道要使用什么工具和做什么吗?

编辑:详细信息

问题发生在 windows、linux/x64 和 linux/arm、windows 单声道 4.0.1、linux 4.0.2.4(其中我自己建造的)。

我的命令是这样的:

mono --debug nuget.exe install LC3xx.Frontend -ConfigFile nuget.config -ExcludeVersion -Verbosity detailed

进程挂起,使用 1 CPU 核心和 windows 我可以看到它正在读取数据(进程资源管理器显示 I/O 读取字节增加(千兆字节和千兆字节)虽然我的 nuget 包只有 5 MB。

当我按 ctrl-C 有时会显示:

Unhandled Exception: System.ObjectDisposedException: The object was used after being disposed. at System.IO.FileStream.Flush () [0x00020] in /root/mono-3.12.1/mcs/class/corlib/System.IO/FileStream.cs:826 at zipsharp.ZipStream.Dispose (bool) [0x00007] in /root/mono-3.12.1/mcs/class/WindowsBase/ZipSharp/ZipStream.cs:89 at System.IO.Stream.Close () [0x00000] in /root/mono-3.12.1/mcs/class/corlib/System.IO/Stream.cs:113 at zipsharp.ZipStream.CloseFile_Native (intptr,intptr) [0x00000] in /root/mono-3.12.1/mcs/class/WindowsBase/ZipSharp/ZipStream.cs:123 at (wrapper native-to-managed) zipsharp.ZipStream.CloseFile_Native (intptr,intptr) <IL 0x00025, 0x000af> at (wrapper managed-to-native) zipsharp.NativeUnzip.unzClose (zipsharp.UnzipHandle) <0x0003b> at zipsharp.NativeUnzip.CloseArchive (zipsharp.UnzipHandle) [0x00000] in /root/mono-3.12.1/mcs/class/WindowsBase/ZipSharp/NativeUnzip.cs:27 at zipsharp.UnzipHandle.ReleaseHandle () <0x00013> at System.Runtime.InteropServices.SafeHandle.Finalize () [0x00016] in /root/mono-3.12.1/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:237

自从 Linux 我自己构建了单声道后,我去了 ZipStream.cs 并在 Dispose() 中注释掉了 Flush()。这将消息更改为:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at zipsharp.ZipStream.CloseFile_Native (IntPtr opaque, IntPtr stream) [0x00000] in /home/user/mono-4.0.2/mcs/class/WindowsBase/ZipSharp/ZipStream.cs:123 at (wrapper managed-to-native) zipsharp.NativeUnzip:unzClose (zipsharp.UnzipHandle) at zipsharp.NativeUnzip.CloseArchive (zipsharp.UnzipHandle handle) [0x00000] in /home/user/mono-4.0.2/mcs/class/WindowsBase/ZipSharp/NativeUnzip.cs:27 at zipsharp.UnzipHandle.ReleaseHandle () [0x00000] in /home/user/mono-4.0.2/mcs/class/WindowsBase/ZipSharp/UnzipHandle.cs:28 at System.Runtime.InteropServices.SafeHandle.Dispose (Boolean disposing) [0x00045] in /home/user/mono-4.0.2/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:175 at System.Runtime.InteropServices.SafeHandle.Finalize () [0x00000] in /home/user/mono-4.0.2/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:233 更奇怪的是,因为 CloseFile_Native() 只是调用了 this.Close(),所以它一定是在一个已销毁的对象上调用的!?

奇怪的是,今天,在 windows,我的 nuget 包的安装实际上已经完成,耗时(120 秒以上)并且在此过程中以某种方式读取了 50gigs 的数据。

调试:当我将 VS 调试器附加到进程时,我只在主线程中看到:

ntdll.dll!770c2315()    Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
monosgen-2.0.dll!1015afde() Unknown
00510a80()  Unknown
MonoPosixHelper.dll!68a4f549()  Unknown
MonoPosixHelper.dll!68a4f6af()  Unknown
MonoPosixHelper.dll!68a4f99b()  Unknown
MonoPosixHelper.dll!68a5027e()  Unknown
MonoPosixHelper.dll!68a5039b()  Unknown
05116730()  Unknown
051165c8()  Unknown
051153b4()  Unknown
051207fc()  Unknown
05114958()  Unknown
05114744()  Unknown
051146f0()  Unknown
0511458e()  Unknown
05114550()  Unknown
05113d87()  Unknown
05113c9c()  Unknown
05113ba4()  Unknown
05111700()  Unknown
05111634()  Unknown
05111560()  Unknown
05110fb4()  Unknown
05110459()  Unknown
051102f4()  Unknown
037f546a()  Unknown
0381ad6e()  Unknown
037f54d2()  Unknown
03805460()  Unknown
038052e0()  Unknown
05102f34()  Unknown
05102b84()  Unknown
05102827()  Unknown
051053c8()  Unknown
05110234()  Unknown
0510fde0()  Unknown
0510fc74()  Unknown
0510fc2c()  Unknown
0510fbcc()  Unknown
0510f61a()  Unknown
0510f448()  Unknown
05108e94()  Unknown
051082ec()  Unknown
051081e0()  Unknown
051020d7()  Unknown
03846cf1()  Unknown
03845c74()  Unknown
0381ffb0()  Unknown
037b3429()  Unknown
037b383f()  Unknown
monosgen-2.0.dll!10025f64() Unknown
monosgen-2.0.dll!100f7c70() Unknown
monosgen-2.0.dll!100f7afd() Unknown
monosgen-2.0.dll!100f8626() Unknown
monosgen-2.0.dll!100865f2() Unknown
monosgen-2.0.dll!10085c56() Unknown
monosgen-2.0.dll!10087d02() Unknown
mono-sgen.exe!mono_main_with_options(int argc, char * * argv) Line 91   C
mono-sgen.exe!main() Line 112   C
mono-sgen.exe!__tmainCRTStartup() Line 626  C
kernel32.dll!74d3337a() Unknown
ntdll.dll!770d92e2()    Unknown
ntdll.dll!770d92b5()    Unknown`

我看不到 nuget 所在的调用。所以我真的不知道这是 nuget 错误还是单声道错误(尽管它看起来非常像单声道错误)

当我不使用 ctrl-C 中断进程时,我没有收到任何错误消息,只是坐在那里并在读取数据时吃 CPU。

编辑发现:看来我发现了问题。 Mono 的 System.IO.Packaging.Package 要求包内每个文件的压缩级别,依次读取并解压缩整个存档 - 对于其中的每个文件。我有一个包含 1000 多个文件的 nuget 包,所以它花了那么长时间。

在 Linux 或 Mac 上,通过使用 MonoDevelop 或 Xamarin Studio 调试在 Mono 下 运行ning 的 .NET 应用程序通常更容易。

在MonoDevelop中打开NuGet.sln,在项目选项中配置你要使用的命令行,运行,CommandLine项目的General,然后调试CommandLine项目。 CommandLine 项目将 运行 NuGet.exe 在调试器下