一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - ASP.NET教程 - 如何把 .NET 進程中的所有托管異常找出來?

如何把 .NET 進程中的所有托管異常找出來?

2021-10-26 22:04一線碼農聊技術Tess ASP.NET教程

大家應該知道 .NET異常 本質上就是一個 Object 對象,也就是說只要你執行了 new XXException() 語句,那么它就會分配到 GC Heap 上。

如何把 .NET 進程中的所有托管異常找出來?

大家應該知道 .NET異常 本質上就是一個 Object 對象,也就是說只要你執行了 new XXException() 語句,那么它就會分配到 GC Heap 上。

這也就意味著,如果你有一個進程的dump文件,那你就可以從dump中導出程序最近都拋了什么異常,換句話說只要這些異常沒有被 GC 回收,你都可以給它找出來。

實現起來很簡單,只要在 windbg 中輸入如下命令即可。

  1. 0:015>!dumpheap-typeException
  2. ------------------------------
  3. Heap0
  4. AddressMTSize
  5. 02ea6b0c79330a8072
  6. 02ea75f07930eab476
  7. 06f57aa47930eab476
  8. 06f5829c7930eab476
  9. 06f58a947930eab476
  10. 06f5928c7930eab476
  11. 06f59a847930eab476
  12. 06f5a27c7930eab476
  13. 06f5aa747930eab476
  14. 06f5b26c7930eab476
  15. 06f5ba647930eab476
  16. 06f5c25c7930eab476
  17. 06f5ca547930eab476
  18. 06f5d24c7930eab476
  19. total319objects
  20. ------------------------------
  21. total656objects
  22. Statistics:
  23. MTCountTotalSizeClassName
  24. 79333dc0112System.Text.DecoderExceptionFallback
  25. 79333d7c112System.Text.EncoderExceptionFallback
  26. 793172f8264System.UnhandledExceptionEventHandler
  27. 79330c30172System.ExecutionEngineException
  28. 79330ba0172System.StackOverflowException
  29. 79330b10172System.OutOfMemoryException
  30. 79330a80172System.Exception
  31. 79330cc02144System.Threading.ThreadAbortException
  32. 7930eab464649096System.IO.DirectoryNotFoundException
  33. Total656objects

如果你想看某一個具體異常的詳細信息,可以使用命令 !pe 02ea6b0c 。

  1. !pe02ea6b0c
  2. Exceptionobject:02ea6b0c
  3. Exceptiontype:System.Exception
  4. Message:Theemailenteredisnotavalidemailaddress
  5. InnerException:
  6. StackTrace(generated):
  7. SPIPFunction
  8. 024AF2C80FE3125EApp_Code_da2s7oyo!BuggyMail.IsValidEmailAddress(System.String)+0x76
  9. 024AF2E80FE31192App_Code_da2s7oyo!BuggyMail.SendEmail(System.String,System.String)+0x4a
  10. StackTraceString:
  11. HResult:80131500
  12. Therearenestedexceptionsonthisthread.Runwith-nestedfordetails

那現在問題來了,我想看所有異常的詳細信息怎么辦呢?人肉一個一個的用 !pe 命令去執行,那將會多惡心。。。所以友好的方式就是寫腳本去提速,這里我使用 .foreach 命令。

  1. .foreach(ex{!dumpheap-typeException-short}){.echo"********************************";!pe${ex}}

上面我用了一個 -short 參數,目的就是只輸出 address 地址方便腳本遍歷,然后將迭代項送入 !pe ,輸出結果如下:

  1. 0:015>.foreach(ex{!dumpheap-typeException-short}){.echo"********************************";!pe${ex}}
  2. ********************************
  3. Exceptionobject:02ea6b0c
  4. Exceptiontype:System.Exception
  5. Message:Theemailenteredisnotavalidemailaddress
  6. InnerException:
  7. StackTrace(generated):
  8. SPIPFunction
  9. 024AF2C80FE3125EApp_Code_da2s7oyo!BuggyMail.IsValidEmailAddress(System.String)+0x76
  10. 024AF2E80FE31192App_Code_da2s7oyo!BuggyMail.SendEmail(System.String,System.String)+0x4a
  11. StackTraceString:
  12. HResult:80131500
  13. Therearenestedexceptionsonthisthread.Runwith-nestedfordetails
  14. ********************************
  15. Exceptionobject:02ea75f0
  16. Exceptiontype:System.IO.DirectoryNotFoundException
  17. Message:Couldnotfindapartofthepath'c:\idontexist\log.txt'.
  18. InnerException:
  19. StackTrace(generated):
  20. SPIPFunction
  21. 024AF044792741F2mscorlib_ni!System.IO.__Error.WinIOError(Int32,System.String)+0xc2
  22. 024AF0A0792EB22Bmscorlib_ni!System.IO.FileStream.Init(System.String,System.IO.FileMode,System.IO.FileAccess,Int32,Boolean,System.IO.FileShare,Int32,System.IO.FileOptions,SECURITY_ATTRIBUTES,System.String,Boolean)+0x48b
  23. 024AF198792EA882mscorlib_ni!System.IO.FileStream..ctor(System.String,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,Int32,System.IO.FileOptions)+0x42
  24. 024AF1C07927783Fmscorlib_ni!System.IO.StreamWriter.CreateFile(System.String,Boolean)+0x3f
  25. 024AF1D4792777DBmscorlib_ni!System.IO.StreamWriter..ctor(System.String,Boolean,System.Text.Encoding,Int32)+0x3b
  26. 024AF1F4797EE19Fmscorlib_ni!System.IO.StreamWriter..ctor(System.String)+0x1f
  27. 024AF2040FE31325App_Code_da2s7oyo!Utility.WriteToLog(System.String,System.String)+0x5d
  28. StackTraceString:
  29. HResult:80070003
  30. Therearenestedexceptionsonthisthread.Runwith-nestedfordetails
  31. ********************************
  32. Exceptionobject:02ea7de8
  33. Exceptiontype:System.IO.DirectoryNotFoundException
  34. Message:Couldnotfindapartofthepath'c:\idontexist\log.txt'.
  35. InnerException:
  36. StackTrace(generated):
  37. SPIPFunction
  38. 024AEF60792741F2mscorlib_ni!System.IO.__Error.WinIOError(Int32,System.String)+0xc2
  39. 024AEFBC792EB22Bmscorlib_ni!System.IO.FileStream.Init(System.String,System.IO.FileMode,System.IO.FileAccess,Int32,Boolean,System.IO.FileShare,Int32,System.IO.FileOptions,SECURITY_ATTRIBUTES,System.String,Boolean)+0x48b
  40. 024AF0B4792EA882mscorlib_ni!System.IO.FileStream..ctor(System.String,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,Int32,System.IO.FileOptions)+0x42
  41. 024AF0DC7927783Fmscorlib_ni!System.IO.StreamWriter.CreateFile(System.String,Boolean)+0x3f
  42. 024AF0F0792777DBmscorlib_ni!System.IO.StreamWriter..ctor(System.String,Boolean,System.Text.Encoding,Int32)+0x3b
  43. 024AF110797EE19Fmscorlib_ni!System.IO.StreamWriter..ctor(System.String)+0x1f
  44. 024AF1200FE31325App_Code_da2s7oyo!Utility.WriteToLog(System.String,System.String)+0x5d
  45. StackTraceString:
  46. HResult:80070003
  47. Therearenestedexceptionsonthisthread.Runwith-nestedfordetails

當然你也可以打印出當前異常的內部異常,配上一個 -nest 參數即可。

  1. .foreach(ex{!dumpheap-typeException-short}){.echo"********************************";!pe–nested${ex}}

原文鏈接:https://mp.weixin.qq.com/s/LhxU7Nr8n9bAx1sXKSlT4g

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: videojapan日本孕交孕 | 星星动漫在线观看免费 | 乌克兰xxxxx 我要色色网 | 暖暖 免费 高清 日本 在线 | 午夜视频一区二区 | 国产亚洲精品第一综合另类 | 午夜影院0606免费 | 亚洲男人天堂久久 | 91亚洲精品国产自在现线 | 国产精品久久久久久久午夜片 | 久草草在线视视频 | 国产亚洲人成网站天堂岛 | 99热久久国产精品这里 | 青青网在线视频 | 办公室的秘密在线观看 | 午夜想想爱 | 9久热这里只有精品免费 | 天天综合亚洲 | 武侠古典久久亚洲精品 | 国内自拍2019 | 女仆色网址 | 色综合天天网 | 欧美精品一区二区三区久久 | 美女草b | 亚洲福利一区二区精品秒拍 | 亚洲精品一区制服丝袜 | www.亚洲色图| 99在线观看视频免费 | 18free性欧美另类hd | 精品淑女少妇AV久久免费 | 国产精品亚洲精品日韩已满 | 国产精品香蕉一区二区三区 | chinese壮直男gay老年人 | 果冻传媒新在线观看免费 | 日韩一级精品视频在线观看 | 99亚洲 | 美女扒开胸罩露出奶 | 99在线精品视频 | 国产福利免费看 | 顶级欧美做受xxx000 | 我不卡影院手机在线观看 |