Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3585 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
6 changed files with 125 additions and 4 deletions
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
// <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 MemoryReadWrite |
||||
{ |
||||
public static void Main() |
||||
{ |
||||
string hello = "Hello"; |
||||
string world = " !"; |
||||
System.Diagnostics.Debugger.Break(); |
||||
System.Diagnostics.Debug.WriteLine(hello + " " + world); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#if TEST_CODE
|
||||
namespace Debugger.Tests { |
||||
public partial class DebuggerTests |
||||
{ |
||||
[NUnit.Framework.Test] |
||||
public void MemoryReadWrite() |
||||
{ |
||||
StartTest("MemoryReadWrite.cs"); |
||||
|
||||
ulong addrHello = process.SelectedStackFrame.GetLocalVariableValue("hello").Address; |
||||
ulong addrWorld = process.SelectedStackFrame.GetLocalVariableValue("world").Address; |
||||
|
||||
addrHello = DeRef(process.ReadMemory(addrHello, 4)); |
||||
addrWorld = DeRef(process.ReadMemory(addrWorld, 4)); |
||||
|
||||
byte[] hello = process.ReadMemory(addrHello, 22); |
||||
byte[] world = process.ReadMemory(addrWorld, 24); |
||||
|
||||
ObjectDump("hello", ToHex(hello)); |
||||
ObjectDump("world", ToHex(world)); |
||||
|
||||
process.WriteMemory(addrWorld + 12, new byte[] {0x77, 0x0, 0x6F, 0x0, 0x72, 0x0, 0x6C, 0x0, 0x64, 0x0}); |
||||
|
||||
EndTest(); |
||||
} |
||||
|
||||
ulong DeRef(byte[] ptr) |
||||
{ |
||||
return (ulong)(ptr[0] + (ptr[1] << 8) + (ptr[2] << 16) + (ptr[3] << 24)); |
||||
} |
||||
|
||||
string ToHex(byte[] buffer) |
||||
{ |
||||
string hex = ""; |
||||
foreach(byte b in buffer) { |
||||
hex += b.ToString("X") + " "; |
||||
} |
||||
return hex; |
||||
} |
||||
} |
||||
} |
||||
#endif
|
||||
|
||||
#if EXPECTED_OUTPUT
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<DebuggerTests> |
||||
<Test |
||||
name="MemoryReadWrite.cs"> |
||||
<ProcessStarted /> |
||||
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded> |
||||
<ModuleLoaded>MemoryReadWrite.exe (Has symbols)</ModuleLoaded> |
||||
<ModuleLoaded>System.dll (No symbols)</ModuleLoaded> |
||||
<DebuggingPaused>Break MemoryReadWrite.cs:18,4-18,40</DebuggingPaused> |
||||
<hello>EC 8 33 79 6 0 0 0 5 0 0 0 48 0 65 0 6C 0 6C 0 6F 0 </hello> |
||||
<world>EC 8 33 79 7 0 0 0 6 0 0 0 20 0 20 0 20 0 20 0 20 0 21 0 </world> |
||||
<ModuleLoaded>System.Configuration.dll (No symbols)</ModuleLoaded> |
||||
<ModuleLoaded>System.Xml.dll (No symbols)</ModuleLoaded> |
||||
<LogMessage>Hello world!\r\n</LogMessage> |
||||
<ProcessExited /> |
||||
</Test> |
||||
</DebuggerTests> |
||||
#endif // EXPECTED_OUTPUT
|
Loading…
Reference in new issue