Browse Source

Fixed Forum-7997: Error getting a name of a thread;

The problem was that ICorDebugValue2.ExactType returned null.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3200 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
dfa2158fc4
  1. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Thread.cs
  2. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs
  3. 1
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj
  4. 171
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs
  5. 112
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ThreadName.cs

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Thread.cs

@ -142,12 +142,14 @@ namespace Debugger @@ -142,12 +142,14 @@ namespace Debugger
}
}
// NB: The value is null during the CreateThread callback
/// <summary> Returns value representing the System.Threading.Thread object </summary>
/// <remarks> The value is null while the thread is being created (the CreateThread callback). </remarks>
public Value RuntimeValue {
get {
process.AssertPaused();
return new Value(process, new EmptyExpression(), CorThread.Object);
ICorDebugValue corValue = this.CorThread.Object;
return new Value(process, new EmptyExpression(), corValue);
}
}

13
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs

@ -123,8 +123,17 @@ namespace Debugger @@ -123,8 +123,17 @@ namespace Debugger
this.corValue = corValue;
this.corValue_pauseSession = process.PauseSession;
ICorDebugType exactType = this.CorValue.CastTo<ICorDebugValue2>().ExactType;
type = DebugType.Create(this.Process, exactType);
if (corValue.Is<ICorDebugReferenceValue>() &&
corValue.CastTo<ICorDebugReferenceValue>().Value == 0 &&
corValue.CastTo<ICorDebugValue2>().ExactType == null)
{
// We were passed null reference and no metadata description
// (happens during CreateThread callback for the thread object)
this.type = DebugType.Create(this.Process, null, "System.Object");
} else {
ICorDebugType exactType = this.CorValue.CastTo<ICorDebugValue2>().ExactType;
this.type = DebugType.Create(this.Process, exactType);
}
}
/// <summary> Returns the <see cref="Debugger.DebugType"/> of the value </summary>

1
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj

@ -74,6 +74,7 @@ @@ -74,6 +74,7 @@
<Compile Include="Src\TestPrograms\Symbols.cs" />
<Compile Include="Src\TestPrograms\TerminatePausedProcess.cs" />
<Compile Include="Src\TestPrograms\TerminateRunningProcess.cs" />
<Compile Include="Src\TestPrograms\ThreadName.cs" />
<Compile Include="Src\TestPrograms\ValueType.cs" />
<Compile Include="Src\TestPrograms\_Template.cs" />
<EmbeddedResource Include="Src\TestPrograms\*.xml" />

171
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <owner name="David Srbeck<EFBFBD>" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
@ -53,7 +53,7 @@ namespace Debugger.Tests.TestPrograms @@ -53,7 +53,7 @@ namespace Debugger.Tests.TestPrograms
namespace Debugger.Tests {
public partial class DebuggerTests
{
[NUnit.Framework.Test, NUnit.Framework.Ignore]
[NUnit.Framework.Test]
public void Expressions()
{
StartTest("Expressions.cs");
@ -69,4 +69,169 @@ namespace Debugger.Tests { @@ -69,4 +69,169 @@ namespace Debugger.Tests {
#endif
#if EXPECTED_OUTPUT
<?xml version="1.0" encoding="utf-8"?>
<DebuggerTests>
<Test
name="Expressions.cs">
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>Expressions.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break</DebuggingPaused>
<Arguments
Capacity="4"
Count="1">
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="argValue"
Expression="arg"
IsInvalid="False"
IsNull="False"
PrimitiveValue="argValue"
Type="System.String" />
</Item>
</Arguments>
<LocalVariables
Capacity="4"
Count="3">
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="0"
Expression="i"
IsInvalid="False"
IsNull="False"
PrimitiveValue="0"
Type="System.Int32" />
</Item>
<Item>
<Value
ArrayDimensions="{3}"
ArrayLenght="3"
ArrayRank="1"
AsString="{System.String[]}"
Expression="array"
IsInvalid="False"
IsNull="False"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.String[]" />
</Item>
<Item>
<Value
ArrayDimensions="{2, 2}"
ArrayLenght="4"
ArrayRank="2"
AsString="{System.String[,]}"
Expression="array2"
IsInvalid="False"
IsNull="False"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.String[,]" />
</Item>
</LocalVariables>
<this>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="derived name"
Expression="this.name"
IsInvalid="False"
IsNull="False"
PrimitiveValue="derived name"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="derived value"
Expression="this.Value"
IsInvalid="False"
IsNull="False"
PrimitiveValue="derived value"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="field value"
Expression="this.field"
IsInvalid="False"
IsNull="False"
PrimitiveValue="field value"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{3}"
ArrayLenght="3"
ArrayRank="1"
AsString="{System.String[]}"
Expression="this.array"
IsInvalid="False"
IsNull="False"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.String[]" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="derived name"
Expression="this.Name"
IsInvalid="False"
IsNull="False"
PrimitiveValue="derived name"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="base name"
Expression="this.name"
IsInvalid="False"
IsNull="False"
PrimitiveValue="base name"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="base value"
Expression="this.Value"
IsInvalid="False"
IsNull="False"
PrimitiveValue="base value"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLenght="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="base name"
Expression="this.Name"
IsInvalid="False"
IsNull="False"
PrimitiveValue="base name"
Type="System.String" />
</Item>
</this>
<ProcessExited />
</Test>
</DebuggerTests>
#endif // EXPECTED_OUTPUT

112
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ThreadName.cs

@ -0,0 +1,112 @@ @@ -0,0 +1,112 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger.Tests.TestPrograms
{
public class ThreadName
{
public static void Main()
{
System.Diagnostics.Debugger.Break();
System.Threading.Thread.CurrentThread.Name = "ThreadName";
System.Diagnostics.Debugger.Break();
}
}
}
#if TEST_CODE
namespace Debugger.Tests {
public partial class DebuggerTests
{
[NUnit.Framework.Test]
public void ThreadName()
{
debugger.ProcessStarted += delegate(object sender, ProcessEventArgs e) {
e.Process.ThreadStarted += delegate(object sender2, ThreadEventArgs f) {
ObjectDump("ThreadStartedEvent", f.Thread);
};
};
StartTest("ThreadName.cs");
ObjectDump("Thread", process.SelectedThread);
process.Continue();
ObjectDump("Thread", process.SelectedThread);
EndTest();
}
}
}
#endif
#if EXPECTED_OUTPUT
<?xml version="1.0" encoding="utf-8"?>
<DebuggerTests>
<Test
name="ThreadName.cs">
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ThreadStartedEvent>
<Thread
CurrentException="null"
CurrentExceptionIsUnhandled="False"
CurrentExceptionType="0"
HasExited="False"
IsAtSafePoint="True"
IsInValidState="True"
IsMostRecentStackFrameNative="False"
MostRecentStackFrame="System.AppDomain.SetupDomain"
MostRecentStackFrameWithLoadedSymbols="null"
Name=""
OldestStackFrame="System.AppDomain.SetupDomain"
Priority="Normal"
RuntimeValue="? = null"
SelectedStackFrame="null"
Suspended="False" />
</ThreadStartedEvent>
<ModuleLoaded>ThreadName.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break</DebuggingPaused>
<Thread>
<Thread
CurrentException="null"
CurrentExceptionIsUnhandled="False"
CurrentExceptionType="0"
HasExited="False"
IsAtSafePoint="True"
IsInValidState="True"
IsMostRecentStackFrameNative="False"
MostRecentStackFrame="Debugger.Tests.TestPrograms.ThreadName.Main"
MostRecentStackFrameWithLoadedSymbols="Debugger.Tests.TestPrograms.ThreadName.Main"
Name=""
OldestStackFrame="Debugger.Tests.TestPrograms.ThreadName.Main"
Priority="Normal"
RuntimeValue="? = {System.Threading.Thread}"
SelectedStackFrame="Debugger.Tests.TestPrograms.ThreadName.Main"
Suspended="False" />
</Thread>
<DebuggingPaused>Break</DebuggingPaused>
<Thread>
<Thread
CurrentException="null"
CurrentExceptionIsUnhandled="False"
CurrentExceptionType="0"
HasExited="False"
IsAtSafePoint="True"
IsInValidState="True"
IsMostRecentStackFrameNative="False"
MostRecentStackFrame="Debugger.Tests.TestPrograms.ThreadName.Main"
MostRecentStackFrameWithLoadedSymbols="Debugger.Tests.TestPrograms.ThreadName.Main"
Name="ThreadName"
OldestStackFrame="Debugger.Tests.TestPrograms.ThreadName.Main"
Priority="Normal"
RuntimeValue="? = {System.Threading.Thread}"
SelectedStackFrame="Debugger.Tests.TestPrograms.ThreadName.Main"
Suspended="False" />
</Thread>
<ProcessExited />
</Test>
</DebuggerTests>
#endif // EXPECTED_OUTPUT
Loading…
Cancel
Save