Browse Source

Fixed bug that prevented recompiling due to files locked by the debugger

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@513 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
47adfb89f7
  1. 47
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs
  2. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs

47
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs

@ -24,15 +24,14 @@ namespace DebuggerLibrary
int orderOfLoading = 0; int orderOfLoading = 0;
readonly ICorDebugModule corModule; readonly ICorDebugModule corModule;
ISymbolReader symReader; ISymbolReader symReader;
object pMetaDataInterface;
IMetaDataImport metaDataInterface; IMetaDataImport metaDataInterface;
internal MetaData MetaData { internal MetaData MetaData {
get { get {
return new MetaData(metaDataInterface); return new MetaData(metaDataInterface);
} }
} }
public ISymbolReader SymReader { public ISymbolReader SymReader {
get { get {
return symReader; return symReader;
@ -97,7 +96,7 @@ namespace DebuggerLibrary
orderOfLoading = value; orderOfLoading = value;
} }
} }
public bool JMCStatus { public bool JMCStatus {
set { set {
uint unused = 0; uint unused = 0;
@ -114,12 +113,13 @@ namespace DebuggerLibrary
pModule.IsDynamic(out isDynamic); pModule.IsDynamic(out isDynamic);
pModule.IsInMemory(out isInMemory); pModule.IsInMemory(out isInMemory);
Guid metaDataInterfaceGuid = new Guid("{ 0x7dac8207, 0xd3ae, 0x4c75, { 0x9b, 0x67, 0x92, 0x80, 0x1a, 0x49, 0x7d, 0x44 } }"); Guid metaDataInterfaceGuid = new Guid("{ 0x7dac8207, 0xd3ae, 0x4c75, { 0x9b, 0x67, 0x92, 0x80, 0x1a, 0x49, 0x7d, 0x44 } }");
object pMetaDataInterface;
pModule.GetMetaDataInterface(ref metaDataInterfaceGuid, out pMetaDataInterface); pModule.GetMetaDataInterface(ref metaDataInterfaceGuid, out pMetaDataInterface);
metaDataInterface = (IMetaDataImport) pMetaDataInterface; metaDataInterface = (IMetaDataImport) pMetaDataInterface;
uint pStringLenght = 0; // Terminating character included in pStringLenght uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero; IntPtr pString = IntPtr.Zero;
pModule.GetName(pStringLenght, pModule.GetName(pStringLenght,
@ -132,23 +132,29 @@ namespace DebuggerLibrary
pString); pString);
fullPath = Marshal.PtrToStringUni(pString); fullPath = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString); Marshal.FreeHGlobal(pString);
SymBinder symBinder = new SymBinder(); SymBinder symBinder = new SymBinder();
try { IntPtr ptr = IntPtr.Zero;
symReader = symBinder.GetReader(Marshal.GetIUnknownForObject(metaDataInterface), fullPath, string.Empty); try {
} catch (System.Exception) { ptr = Marshal.GetIUnknownForObject(metaDataInterface);
symReader = null; symReader = symBinder.GetReader(ptr, fullPath, string.Empty);
} } catch (System.Exception) {
symReader = null;
} finally {
if (ptr != IntPtr.Zero) {
Marshal.Release(ptr);
}
}
JMCStatus = SymbolsLoaded; JMCStatus = SymbolsLoaded;
} }
public void ApplyChanges(byte[] metadata, byte[] il) public void ApplyChanges(byte[] metadata, byte[] il)
{ {
(corModule as ICorDebugModule2).ApplyChanges((uint)metadata.Length, metadata, (uint)il.Length, il); (corModule as ICorDebugModule2).ApplyChanges((uint)metadata.Length, metadata, (uint)il.Length, il);
} }
public void Dispose() public void Dispose()
{ {
if (symReader != null) { if (symReader != null) {
@ -156,8 +162,19 @@ namespace DebuggerLibrary
System.Reflection.MethodInfo m = symReader.GetType().GetMethod("{dtor}"); System.Reflection.MethodInfo m = symReader.GetType().GetMethod("{dtor}");
m.Invoke(symReader, null); m.Invoke(symReader, null);
} catch { } catch {
Console.WriteLine("symReader release failed. ({dtor})");
} finally {
symReader = null;
} }
} }
try {
Marshal.FinalReleaseComObject(metaDataInterface);
} catch {
Console.WriteLine("metaDataInterface release failed. (FinalReleaseComObject)");
} finally {
metaDataInterface = null;
}
} }
} }
} }

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs

@ -55,10 +55,10 @@ namespace DebuggerLibrary
uint classToken; uint classToken;
corClass.GetToken(out classToken); corClass.GetToken(out classToken);
corClass.GetModule(out corModule); corClass.GetModule(out corModule);
metaData = new Module(corModule).MetaData; metaData = debugger.GetModule(corModule).MetaData;
classProps = metaData.GetTypeDefProps(classToken); classProps = metaData.GetTypeDefProps(classToken);
corModuleSuperclass = corModule; corModuleSuperclass = corModule;
} }

Loading…
Cancel
Save