Browse Source

Function.cs refactored to use MetaData wrapper

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@196 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
c18c7c8a9f
  1. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/Module.cs
  2. 160
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  3. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs

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

@ -23,12 +23,6 @@ namespace DebuggerLibrary @@ -23,12 +23,6 @@ namespace DebuggerLibrary
ISymbolReader symReader;
object pMetaDataInterface;
IMetaDataImport metaDataInterface;
public IMetaDataImport MetaDataInterface {
get {
return metaDataInterface;
}
}
internal MetaData MetaData {
get {

160
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -19,17 +19,15 @@ namespace DebuggerLibrary @@ -19,17 +19,15 @@ namespace DebuggerLibrary
{
NDebugger debugger;
string name;
Module module;
SymbolToken token;
uint parentClassToken = 0;
uint attributes;
ICorDebugFrame corFrame;
ICorDebugFunction corFunction;
ICorDebugFunction corFunction;
MethodProps methodProps;
public string Name {
get {
return name;
return methodProps.Name;
}
}
@ -41,13 +39,7 @@ namespace DebuggerLibrary @@ -41,13 +39,7 @@ namespace DebuggerLibrary
public bool IsStatic {
get {
return (attributes & (uint)CorMethodAttr.mdStatic) != 0;
}
}
public uint Token {
get {
return (uint)token.GetToken();
return methodProps.IsStatic;
}
}
@ -78,57 +70,13 @@ namespace DebuggerLibrary @@ -78,57 +70,13 @@ namespace DebuggerLibrary
corFrame.GetFunction(out corFunction);
uint functionToken;
corFunction.GetToken(out functionToken);
this.token = new SymbolToken((int)functionToken);
ICorDebugModule corModule;
corFunction.GetModule(out corModule);
module = debugger.GetModule(corModule);
Init();
}
unsafe void Init()
{
uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero;
uint codeRVA;
uint implFlags;
IntPtr pSigBlob;
uint sigBlobSize;
module.MetaDataInterface.GetMethodProps(
Token,
out parentClassToken,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out attributes,
new IntPtr(&pSigBlob),
out sigBlobSize,
out codeRVA,
out implFlags);
// Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
module.MetaDataInterface.GetMethodProps(
Token,
out parentClassToken,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out attributes,
new IntPtr(&pSigBlob),
out sigBlobSize,
out codeRVA,
out implFlags);
name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString);
SignatureStream sig = new SignatureStream(pSigBlob, sigBlobSize);
//Marshal.FreeCoTaskMem(pSigBlob);
methodProps = module.MetaData.GetMethodProps(functionToken);
}
#region Helpping proprerties
internal ICorDebugILFrame corILFrame {
@ -158,7 +106,7 @@ namespace DebuggerLibrary @@ -158,7 +106,7 @@ namespace DebuggerLibrary
internal ISymbolMethod symMethod {
get {
return symReader.GetMethod(token);
return symReader.GetMethod(new SymbolToken((int)methodProps.Token));
}
}
@ -344,42 +292,7 @@ namespace DebuggerLibrary @@ -344,42 +292,7 @@ namespace DebuggerLibrary
public string GetParameterName(int index)
{
uint paramToken = 0;
Module.MetaDataInterface.GetParamForMethodIndex(Token, (uint)index, ref paramToken);
uint unused;
uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero;
uint argPos, attr, type;
Module.MetaDataInterface.GetParamProps(paramToken,
out unused,
out argPos,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out attr,
out type,
IntPtr.Zero,
out unused);
// Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
Module.MetaDataInterface.GetParamProps(paramToken,
out unused,
out argPos,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out attr,
out type,
IntPtr.Zero,
out unused);
string name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString);
return name;
return module.MetaData.GetParamForMethodIndex(methodProps.Token, (uint)index).Name;
}
public int GetArgumentCount {
@ -421,64 +334,15 @@ namespace DebuggerLibrary @@ -421,64 +334,15 @@ namespace DebuggerLibrary
return localVariables;
}
string GetMethodName(uint methodToken, out uint attrib)
{
uint unused;
uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero;
module.MetaDataInterface.GetMethodProps(
methodToken,
out unused,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out attrib,
IntPtr.Zero,
out unused,
out unused,
out unused);
// Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
module.MetaDataInterface.GetMethodProps(
methodToken,
out unused,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out attrib,
IntPtr.Zero,
out unused,
out unused,
out unused);
string name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString);
return name;
}
VariableCollection GetPropertyVariables()
{
VariableCollection properties = new VariableCollection();
IntPtr methodEnumPtr = IntPtr.Zero;
while(true) {
uint methodToken;
uint methodsFetched;
Module.MetaDataInterface.EnumMethods(ref methodEnumPtr, parentClassToken, out methodToken, 1, out methodsFetched);
if (methodsFetched == 0) break;
uint attrib;
string name = GetMethodName(methodToken, out attrib);
if (name.StartsWith("get_") && (attrib & (uint)CorMethodAttr.mdSpecialName) != 0) {
name = name.Remove(0,4);
foreach(MethodProps method in module.MetaData.EnumMethods(methodProps.ClassToken)) {
if (method.Name.StartsWith("get_") && method.HasSpecialName) {
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
Module.CorModule.GetFunctionFromToken(methodToken, out evalCorFunction);
Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
if (IsStatic) {
evalArgs = new ICorDebugValue[0];
} else {
@ -486,7 +350,7 @@ namespace DebuggerLibrary @@ -486,7 +350,7 @@ namespace DebuggerLibrary
}
Eval eval = new Eval(debugger, evalCorFunction, evalArgs);
debugger.EvalQueue.AddEval(eval);
properties.Add(new PropertyVariable(debugger, eval, name));
properties.Add(new PropertyVariable(debugger, eval, method.Name.Remove(0, 4)));
}
}

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

@ -115,9 +115,8 @@ namespace DebuggerLibrary @@ -115,9 +115,8 @@ namespace DebuggerLibrary
// see FindTypeDefByName in dshell.cpp
// TODO: preservesig
try {
m.MetaDataInterface.FindTypeDefByName(fullTypeName, 0, out classProps.SuperClassToken);
}
catch {
classProps.SuperClassToken = m.MetaData.FindTypeDefByName(fullTypeName, 0).Token;
} catch {
continue;
}
corModuleSuperclass = m.CorModule;

Loading…
Cancel
Save