mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-10 10:11:31 +00:00
Fixed asm stepping. also fixed IL2CPU Profiler and changed Label replace chars with a compiled regex.
This commit is contained in:
parent
4e3328ec3a
commit
eab46e2cb0
9 changed files with 140 additions and 53 deletions
|
|
@ -88,7 +88,7 @@ Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Docs", "..\Docs", "{67E7DEF
|
|||
Release.AspNetCompiler.ForceOverwrite = "true"
|
||||
Release.AspNetCompiler.FixedNames = "false"
|
||||
Release.AspNetCompiler.Debug = "False"
|
||||
VWDPort = "64695"
|
||||
VWDPort = "1739"
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "Kudzu.Breakpoints", "..\source2\Users\Kudzu\Breakpoints\Kudzu.Breakpoints.Cosmos", "{E5647BFD-1507-4F02-A7D5-E0F9D6AECE3A}"
|
||||
|
|
@ -230,6 +230,11 @@ Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "GeramysTestBoot", "GeramysT
|
|||
{DA4198CA-59DF-41B3-9884-867647900D76} = {DA4198CA-59DF-41B3-9884-867647900D76}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{21D9A04D-C5CC-4162-B7B4-C28940042A64}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Performance1.psess = Performance1.psess
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(TeamFoundationVersionControl) = preSolution
|
||||
SccNumberOfProjects = 61
|
||||
|
|
|
|||
|
|
@ -36,19 +36,20 @@ namespace Cosmos.Assembler {
|
|||
public static string Get(string aMethodLabel, int aIlPos) {
|
||||
return aMethodLabel + ".IL_" + aIlPos.ToString("X4");
|
||||
}
|
||||
|
||||
public static System.Text.RegularExpressions.Regex IllegalCharsReplace = new System.Text.RegularExpressions.Regex(@"[&.,+$<>{}\-\`\\'/\\ \(\)\[\]\*!=_]", System.Text.RegularExpressions.RegexOptions.Compiled);
|
||||
public static string Final(string xName) {
|
||||
var xSB = new StringBuilder(xName);
|
||||
|
||||
//var xSB = new StringBuilder(xName);
|
||||
|
||||
// DataMember.FilterStringForIncorrectChars also does some filtering but replacing empties or non _ chars
|
||||
// causes issues with legacy hardcoded values. So we have a separate function.
|
||||
//
|
||||
// For logging possibilities, we generate fuller names, and then strip out spacing/characters.
|
||||
const string xIllegalChars = "&.,+$<>{}-`\'/\\ ()[]*!=_";
|
||||
/*const string xIllegalChars = "&.,+$<>{}-`\'/\\ ()[]*!=_";
|
||||
foreach (char c in xIllegalChars) {
|
||||
xSB.Replace(c.ToString(), "");
|
||||
}
|
||||
|
||||
}*/
|
||||
xName = IllegalCharsReplace.Replace(xName, "");
|
||||
var xSB = new StringBuilder(xName);
|
||||
if (xSB.Length > MaxLengthWithoutSuffix) {
|
||||
using (var xHash = MD5.Create()) {
|
||||
var xValue = xHash.ComputeHash(Encoding.Default.GetBytes(xName));
|
||||
|
|
|
|||
|
|
@ -82,10 +82,16 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
// Yes this throws an exception if the database doesnt exist, so we have to run it only if we
|
||||
// know it exists. This will detach and also delete the physical files.
|
||||
using (var xCmd = xConn.CreateCommand())
|
||||
try
|
||||
{
|
||||
using (var xCmd = xConn.CreateCommand())
|
||||
{
|
||||
xCmd.CommandText = "DROP DATABASE " + aDbName;
|
||||
xCmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
xCmd.CommandText = "DROP DATABASE " + aDbName;
|
||||
xCmd.ExecuteNonQuery();
|
||||
}
|
||||
if (damagedDatabase)
|
||||
{
|
||||
|
|
@ -409,8 +415,9 @@ namespace Cosmos.Debug.Common {
|
|||
public void Dispose() {
|
||||
if (mConnection != null) {
|
||||
var xConn = mConnection;
|
||||
mConnection = null;
|
||||
xConn.Close();
|
||||
xConn = null;
|
||||
mConnection = null;
|
||||
// Dont set to null... causes problems because of bad code :(
|
||||
// Need to fix the whole class, but its here for now.
|
||||
//CurrentInstance = null;
|
||||
|
|
|
|||
|
|
@ -59,11 +59,16 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Assembler.cs" />
|
||||
<Compile Include="FakeKernel.cs" />
|
||||
<Compile Include="ILOp.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Build\Cosmos.Build.Common\Cosmos.Build.Common.csproj">
|
||||
<Project>{0462E82B-8C29-41A9-8265-9C89038ADB29}</Project>
|
||||
<Name>Cosmos.Build.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Cosmos.Assembler\Cosmos.Assembler.csproj">
|
||||
<Project>{1116130E-28E0-428A-A597-F4B3B676C0CA}</Project>
|
||||
<Name>Cosmos.Assembler</Name>
|
||||
|
|
|
|||
21
source2/IL2CPU/Cosmos.IL2CPU.Profiler/FakeKernel.cs
Normal file
21
source2/IL2CPU/Cosmos.IL2CPU.Profiler/FakeKernel.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Cosmos.IL2CPU.Profiler
|
||||
{
|
||||
public class FakeKernel: Cosmos.System.Kernel
|
||||
{
|
||||
protected override void BeforeRun()
|
||||
{
|
||||
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
Console.Write("Enter some text to be echoed back to you: ");
|
||||
Console.WriteLine(Console.ReadLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,9 @@ using System.Reflection;
|
|||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using Cosmos.System;
|
||||
using Cosmos.Debug.Common;
|
||||
using Cosmos.Build.Common;
|
||||
using System.IO;
|
||||
using Console = System.Console;
|
||||
|
||||
namespace Cosmos.IL2CPU.Profiler {
|
||||
|
|
@ -16,32 +19,64 @@ namespace Cosmos.IL2CPU.Profiler {
|
|||
|
||||
static void Main(string[] args) {
|
||||
Program.DoScan();
|
||||
Console.WriteLine("Press any key to continue.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static void DoScan() {
|
||||
var xSW = new Stopwatch();
|
||||
xSW.Start();
|
||||
|
||||
var xAsmblr = new Assembler();
|
||||
using (var xScanner = new ILScanner(xAsmblr)) {
|
||||
//TODO: Add plugs into the scanning equation to profile scanning them too
|
||||
//System.Reflection.MethodInfo[] name = typeof(SSchockeTest.Kernel).GetMethods();
|
||||
Type xFoundType = typeof(Kernel);
|
||||
var xCtor = xFoundType.GetConstructor(Type.EmptyTypes);
|
||||
typeof(Cosmos.System.Plugs.System.System.ConsoleImpl).IsSubclassOf(typeof(object));
|
||||
var xEntryPoint = typeof(Kernel).GetMethod("Start", BindingFlags.Public | BindingFlags.Instance);
|
||||
//var xEntryPoint = typeof(Program).GetMethod("ScannerEntryPoint", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
//EnableLogging(pathToLogFile)
|
||||
xScanner.EnableLogging(AppDomain.CurrentDomain.BaseDirectory + "log.txt");
|
||||
//xScanner.TempDebug += new Action<string>(xScanner_TempDebug);
|
||||
//xScanner.
|
||||
xScanner.Execute(xCtor);
|
||||
private static void DoScan()
|
||||
{
|
||||
|
||||
xSW.Stop();
|
||||
Console.WriteLine("Total time : {0}", xSW.Elapsed);
|
||||
Console.WriteLine("Method count: {0}", xScanner.MethodCount);
|
||||
//Console.WriteLine("Instruction count: {0}", xScanner.InstructionCount);
|
||||
}
|
||||
var xSW = new Stopwatch();
|
||||
xSW.Start();
|
||||
string MDFFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.mdf";
|
||||
if (File.Exists(MDFFile))
|
||||
File.Delete(MDFFile);
|
||||
|
||||
var outFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.out";
|
||||
if (File.Exists(outFile))
|
||||
File.Delete(outFile);
|
||||
|
||||
var logFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.log";
|
||||
if (File.Exists(logFile))
|
||||
File.Delete(logFile);
|
||||
|
||||
var xAsmblr = new AppAssembler(1);
|
||||
using (var xScanner = new ILScanner(xAsmblr))
|
||||
{
|
||||
using (var xDebugInfo = new DebugInfo(MDFFile, true))
|
||||
{
|
||||
xAsmblr.DebugInfo = xDebugInfo;
|
||||
xAsmblr.DebugEnabled = true;
|
||||
xAsmblr.DebugMode = DebugMode.Source;
|
||||
xAsmblr.TraceAssemblies = TraceAssemblies.All;
|
||||
xAsmblr.IgnoreDebugStubAttribute = false;
|
||||
|
||||
xAsmblr.Assembler.Initialize();
|
||||
//TODO: Add plugs into the scanning equation to profile scanning them too
|
||||
//System.Reflection.MethodInfo[] name = typeof(SSchockeTest.Kernel).GetMethods();
|
||||
Type xFoundType = typeof(FakeKernel);
|
||||
var xCtor = xFoundType.GetConstructor(Type.EmptyTypes);
|
||||
typeof(Cosmos.System.Plugs.System.System.ConsoleImpl).IsSubclassOf(typeof(object));
|
||||
var xEntryPoint = typeof(Kernel).GetMethod("Start", BindingFlags.Public | BindingFlags.Instance);
|
||||
//var xEntryPoint = typeof(Program).GetMethod("ScannerEntryPoint", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
//EnableLogging(pathToLogFile)
|
||||
xScanner.EnableLogging(logFile);
|
||||
//xScanner.TempDebug += new Action<string>(xScanner_TempDebug);
|
||||
//xScanner.
|
||||
xScanner.QueueMethod(xEntryPoint);
|
||||
xScanner.Execute(xCtor);
|
||||
using (var xOut = new StreamWriter(outFile, false))
|
||||
{
|
||||
//if (EmitDebugSymbols) {
|
||||
xAsmblr.Assembler.FlushText(xOut);
|
||||
xAsmblr.FinalizeDebugInfo();
|
||||
}
|
||||
xSW.Stop();
|
||||
Console.WriteLine("Total time : {0}", xSW.Elapsed);
|
||||
Console.WriteLine("Method count: {0}", xScanner.MethodCount);
|
||||
//Console.WriteLine("Instruction count: {0}", xScanner.InstructionCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void xScanner_TempDebug(string obj)
|
||||
|
|
@ -61,4 +96,4 @@ namespace Cosmos.IL2CPU.Profiler {
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -372,7 +372,7 @@ namespace Cosmos.IL2CPU {
|
|||
|
||||
public int MethodCount {
|
||||
get {
|
||||
return 0;
|
||||
return mMethodUIDs.Count;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ namespace Cosmos.VS.Windows {
|
|||
protected byte[] mData = new byte[0];
|
||||
|
||||
public void Update(string aTag, byte[] aData) {
|
||||
mData = aData;
|
||||
Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
(Action)delegate() {
|
||||
mData = aData;
|
||||
DoUpdate(aTag);
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -59,25 +59,38 @@ namespace Cosmos.VS.Windows {
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateFrame(byte[] aData) {
|
||||
var xValues = MemoryViewUC.Split(aData);
|
||||
int xCount = xValues.Count;
|
||||
memvEBP.Clear();
|
||||
for (int i = 0; i < xCount; i++) {
|
||||
// We start at EBP + 8, because lower is not transmitted
|
||||
// [EBP] is old EBP - not needed
|
||||
// [EBP + 4] is saved EIP - not needed
|
||||
memvEBP.Add("[EBP + " + (i * 4 + 8) + "]", xValues[i]);
|
||||
}
|
||||
public void UpdateFrame(byte[] aData)
|
||||
{
|
||||
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal,
|
||||
(Action)delegate()
|
||||
{
|
||||
var xValues = MemoryViewUC.Split(aData);
|
||||
int xCount = xValues.Count;
|
||||
memvEBP.Clear();
|
||||
for (int i = 0; i < xCount; i++)
|
||||
{
|
||||
// We start at EBP + 8, because lower is not transmitted
|
||||
// [EBP] is old EBP - not needed
|
||||
// [EBP + 4] is saved EIP - not needed
|
||||
memvEBP.Add("[EBP + " + (i * 4 + 8) + "]", xValues[i]);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void UpdateStack(byte[] aData) {
|
||||
var xValues = MemoryViewUC.Split(aData);
|
||||
int xCount = xValues.Count;
|
||||
memvESP.Clear();
|
||||
for (int i = 0; i < xCount; i++) {
|
||||
memvESP.Add(("[EBP - " + ((xCount - i) * 4) + "]").PadRight(10) + " [ESP + " + (i * 4) + "]", xValues[i]);
|
||||
}
|
||||
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal,
|
||||
(Action)delegate()
|
||||
{
|
||||
var xValues = MemoryViewUC.Split(aData);
|
||||
int xCount = xValues.Count;
|
||||
memvESP.Clear();
|
||||
for (int i = 0; i < xCount; i++)
|
||||
{
|
||||
memvESP.Add(("[EBP - " + ((xCount - i) * 4) + "]").PadRight(10) + " [ESP + " + (i * 4) + "]", xValues[i]);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue