mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 05:52:11 +00:00
Merge pull request #672 from CosmosOS/nre_message
Improve the NullReferenceException message
This commit is contained in:
commit
348134f97b
1 changed files with 21 additions and 0 deletions
|
|
@ -379,6 +379,27 @@ namespace Cosmos.VS.DebugEngine.AD7.Impl
|
|||
|
||||
private void DbgCmdNullReferenceOccurred(uint lastEIPAddress)
|
||||
{
|
||||
if (mDebugInfo.TryGetValue(BuildPropertyNames.DebugModeString, out var xDebugMode))
|
||||
{
|
||||
if (xDebugMode == "Source")
|
||||
{
|
||||
try
|
||||
{
|
||||
var xMethod = mDebugInfoDb.GetMethod(lastEIPAddress);
|
||||
var xLabel = mDebugInfoDb.GetLabels(lastEIPAddress)[0];
|
||||
var xMethodIlOp = mDebugInfoDb.TryGetFirstMethodIlOpByLabelName(xLabel.Remove(xLabel.LastIndexOf('.'))).IlOffset;
|
||||
var xSequencePoints = mDebugInfoDb.GetSequencePoints(mDebugInfoDb.GetAssemblyFileById(xMethod.AssemblyFileID).Pathname, xMethod.MethodToken);
|
||||
var xLine = xSequencePoints.Where(q => q.Offset <= xMethodIlOp).Last().LineStart;
|
||||
|
||||
AD7Util.MessageBox($"NullReferenceException occurred in '{xMethod.LabelCall}'{Environment.NewLine}Document: {mDebugInfoDb.GetDocumentById(xMethod.DocumentID)}{Environment.NewLine}Line: {xLine}{Environment.NewLine}Address: 0x{lastEIPAddress.ToString("X8")}");
|
||||
return;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AD7Util.MessageBox(String.Format("NullReferenceException occurred at address 0x{0:X8}! Halting now.", lastEIPAddress));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue