Cosmos/source2/Debug/Cosmos.Debug.Common/ReverseSourceInfo.cs
kudzu_cp 3d2e7d8640
2012-08-07 01:47:53 +00:00

33 lines
No EOL
1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Microsoft.Samples.Debugging.CorSymbolStore;
using System.Diagnostics.SymbolStore;
using System.IO;
namespace Cosmos.Debug.Common {
public class ReverseSourceInfos {
private readonly SourceInfos mSourceInfos;
public ReverseSourceInfos(SourceInfos aSourceInfos) {
mSourceInfos = aSourceInfos;
}
public bool FindAddressForSourceLocation(string documentName, uint aLine, uint aColumn, out uint aAddress) {
aAddress = UInt32.MaxValue;
foreach (var xItem in mSourceInfos) {
if (!documentName.Equals(xItem.Value.SourceFile, StringComparison.InvariantCultureIgnoreCase)) {
continue;
}
// todo: improve check to also consider column
if (xItem.Value.Line == aLine) {
if (aAddress > xItem.Key) {
aAddress = xItem.Key;
}
}
}
return aAddress < UInt32.MaxValue;
}
}
}