From 121464d6cd9db978c5de89da0fbe8ed3f71ccc84 Mon Sep 17 00:00:00 2001
From: mterwoord_cp <7cd3fd84a0151ea055c2f79e4d2eef9576fe9afesxUZAwxD>
Date: Wed, 29 Dec 2010 12:45:29 +0000
Subject: [PATCH] Only 1 debug info file is used now (.cpdb)
---
Setup2/Cosmos.iss | 1 +
.../Cosmos.Build.MSBuild.csproj | 3 +
.../Build/Cosmos.Build.MSBuild/Cosmos.targets | 4 +-
.../Build/Cosmos.Build.MSBuild/IL2CPUTask.cs | 3 +-
.../Debug/Cosmos.Debug.Common/DebugSymbol.cs | 116 ++++++++++--------
.../Debug/Cosmos.Debug.Common/SourceInfo.cs | 39 ++++--
.../AD7.Impl/AD7Process.cs | 12 +-
7 files changed, 105 insertions(+), 73 deletions(-)
diff --git a/Setup2/Cosmos.iss b/Setup2/Cosmos.iss
index dd6588173..fe6e42c80 100644
--- a/Setup2/Cosmos.iss
+++ b/Setup2/Cosmos.iss
@@ -168,6 +168,7 @@ Source: .\Build\VSIP\corapi.*; DestDir: {app}\Build\VSIP\; Flags: ignoreversion
Source: .\Build\VSIP\raw.*; DestDir: {app}\Build\VSIP\; Flags: ignoreversion uninsremovereadonly
Source: .\Build\VSIP\fbembed.dll; DestDir: {app}\Build\VSIP\; Flags: ignoreversion uninsremovereadonly
Source: .\Build\VSIP\icu*.dll; DestDir: {app}\Build\VSIP\; Flags: ignoreversion uninsremovereadonly
+Source: .\Build\VSIP\FirebirdSql.Data.FirebirdClient.*; DestDir: {app}\Build\VSIP\; Flags: ignoreversion uninsremovereadonly
; wizards
Source: .\Build\VSIP\Cosmos.VS.Wizards.*; DestDir: {code:VSNET2010_PATH}\PrivateAssemblies; Flags: ignoreversion uninsremovereadonly
diff --git a/source2/Build/Cosmos.Build.MSBuild/Cosmos.Build.MSBuild.csproj b/source2/Build/Cosmos.Build.MSBuild/Cosmos.Build.MSBuild.csproj
index ebc809f5c..bf0a4082e 100644
--- a/source2/Build/Cosmos.Build.MSBuild/Cosmos.Build.MSBuild.csproj
+++ b/source2/Build/Cosmos.Build.MSBuild/Cosmos.Build.MSBuild.csproj
@@ -58,6 +58,9 @@
prompt
+
+ ..\..\Debug\Cosmos.Debug.Common\FirebirdSql.Data.FirebirdClient.dll
+
diff --git a/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets b/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets
index 2c424aa3a..83c7bb322 100644
--- a/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets
+++ b/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets
@@ -50,7 +50,7 @@
Condition="$(IsELF) == 'true'"/>
@@ -69,7 +69,7 @@
diff --git a/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs b/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs
index 7ad314b43..7b2227a7f 100644
--- a/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs
+++ b/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs
@@ -243,7 +243,8 @@ namespace Cosmos.Build.MSBuild {
if (EmitDebugSymbols)
{
xNasmAsm.FlushText(xOut);
- xAsm.WriteDebugSymbols(xOutputFilename + ".cxdb");
+ File.Delete(xOutputFilename + ".cpdb");
+ xAsm.WriteDebugSymbols(xOutputFilename + ".cpdb");
}
else
{
diff --git a/source2/Debug/Cosmos.Debug.Common/DebugSymbol.cs b/source2/Debug/Cosmos.Debug.Common/DebugSymbol.cs
index 86f93bc1c..7e633c42c 100644
--- a/source2/Debug/Cosmos.Debug.Common/DebugSymbol.cs
+++ b/source2/Debug/Cosmos.Debug.Common/DebugSymbol.cs
@@ -42,6 +42,18 @@ namespace Cosmos.Debug.Common
public class MLDebugSymbol
{
+ public static FbConnection OpenOrCreateCPDB(string aPathName)
+ {
+ if (File.Exists(aPathName))
+ {
+ return OpenCPDB(aPathName, false);
+ }
+ else
+ {
+ return CreateCPDB(aPathName);
+ }
+ }
+
private static FbConnection OpenCPDB(string aPathname, bool aCreate)
{
var xCSB = new FbConnectionStringBuilder();
@@ -85,7 +97,7 @@ namespace Cosmos.Debug.Common
var xExec = new FbBatchExecution(DBConn);
xExec.SqlStatements.Add(
- "CREATE TABLE SYMBOL ("
+ "CREATE TABLE MLSYMBOL ("
+ " LABELNAME VARCHAR(255) NOT NULL"
+ " , ADDRESS BIGINT NOT NULL"
+ " , STACKDIFF INT NOT NULL"
@@ -96,6 +108,11 @@ namespace Cosmos.Debug.Common
+ " , METHODNAME VARCHAR(255) NOT NULL"
+ ");"
);
+ xExec.SqlStatements.Add(
+ "CREATE TABLE ADDRESSLABELMAPPING ("
+ + " LABELNAME VARCHAR(255) NOT NULL"
+ + ", ADDRESS BIGINT NOT NULL"
+ + ");");
xExec.Execute();
// Batch execution closes the connection, so we have to reopen it
@@ -106,78 +123,71 @@ namespace Cosmos.Debug.Common
public static void WriteSymbolsListToFile(IEnumerable aSymbols, string aFile)
{
- // Use a temporary file for the database and then move the newly created database to the wanted location afterwards.
- // We do this so the user can gain compilation speed when using a faster disk for instance a mem-disk for the temporary files.
- string tmpdbname = Path.GetTempFileName();
- string dbname = Path.ChangeExtension(aFile, ".cpdb");
-
- using (FbConnection DBConn = CreateCPDB(tmpdbname))
+ using (FbConnection DBConn = OpenOrCreateCPDB(aFile))
{
- var xDS = new SymbolsDS();
-
using (FbTransaction transaction = DBConn.BeginTransaction())
{
- string sqlstmt = "INSERT INTO SYMBOL (LABELNAME, ADDRESS, STACKDIFF, ILASMFILE, TYPETOKEN, METHODTOKEN, ILOFFSET, METHODNAME)" +
+ using (var xCmd = DBConn.CreateCommand())
+ {
+ xCmd.Transaction = transaction;
+ xCmd.CommandText = "INSERT INTO MLSYMBOL (LABELNAME, ADDRESS, STACKDIFF, ILASMFILE, TYPETOKEN, METHODTOKEN, ILOFFSET, METHODNAME)" +
" VALUES (@LABELNAME, @ADDRESS, @STACKDIFF, @ILASMFILE, @TYPETOKEN, @METHODTOKEN, @ILOFFSET, @METHODNAME)";
- // Is a real DB now, but we still store all in RAM. We dont need to. Need to change to query DB as needed instead.
- foreach (var xItem in aSymbols)
- {
- var x = xDS.Entry.NewEntryRow();
- x.LabelName = xItem.LabelName;
- x.Address = xItem.Address;
- x.StackDiff = xItem.StackDifference;
- x.ILAsmFile = xItem.AssemblyFile;
- x.TypeToken = xItem.TypeToken;
- x.MethodToken = xItem.MethodToken;
- x.ILOffset = xItem.ILOffset;
- x.MethodName = xItem.MethodName;
- xDS.Entry.AddEntryRow(x);
+ xCmd.Parameters.Add("@LABELNAME", FbDbType.VarChar);
+ xCmd.Parameters.Add("@ADDRESS", FbDbType.BigInt);
+ xCmd.Parameters.Add("@STACKDIFF", FbDbType.Integer);
+ xCmd.Parameters.Add("@ILASMFILE", FbDbType.VarChar);
+ xCmd.Parameters.Add("@TYPETOKEN", FbDbType.Integer);
+ xCmd.Parameters.Add("@METHODTOKEN", FbDbType.Integer);
+ xCmd.Parameters.Add("@ILOFFSET", FbDbType.Integer);
+ xCmd.Parameters.Add("@METHODNAME", FbDbType.VarChar);
+ xCmd.Prepare();
- using (var xCmd = new FbCommand(sqlstmt, DBConn, transaction))
+ // Is a real DB now, but we still store all in RAM. We dont need to. Need to change to query DB as needed instead.
+ foreach (var xItem in aSymbols)
{
- xCmd.Parameters.Add("@LABELNAME", xItem.LabelName);
- xCmd.Parameters.Add("@ADDRESS", xItem.Address);
- xCmd.Parameters.Add("@STACKDIFF", xItem.StackDifference);
- xCmd.Parameters.Add("@ILASMFILE", xItem.AssemblyFile);
- xCmd.Parameters.Add("@TYPETOKEN", xItem.TypeToken);
- xCmd.Parameters.Add("@METHODTOKEN", xItem.MethodToken);
- xCmd.Parameters.Add("@ILOFFSET", xItem.ILOffset);
- xCmd.Parameters.Add("@METHODNAME", xItem.MethodName);
+ xCmd.Parameters[0].Value = xItem.LabelName;
+ xCmd.Parameters[1].Value = xItem.Address;
+ xCmd.Parameters[2].Value = xItem.StackDifference;
+ xCmd.Parameters[3].Value = xItem.AssemblyFile;
+ xCmd.Parameters[4].Value = xItem.TypeToken;
+ xCmd.Parameters[5].Value = xItem.MethodToken;
+ xCmd.Parameters[6].Value = xItem.ILOffset;
+ xCmd.Parameters[7].Value = xItem.MethodName;
xCmd.ExecuteNonQuery();
}
}
transaction.Commit();
}
-
- xDS.WriteXml(aFile);
}
-
- if (File.Exists(dbname))
- File.Delete(dbname);
-
- File.Move(tmpdbname, dbname);
}
public static void ReadSymbolsListFromFile(List aSymbols, string aFile)
{
- //OpenCPDB(Path.ChangeExtension(aFile, ".cpdb"), false);
- var xDS = new SymbolsDS();
- xDS.ReadXml(aFile);
- foreach (SymbolsDS.EntryRow x in xDS.Entry.Rows)
+ using (var xConn = OpenCPDB(aFile, false))
{
- aSymbols.Add(new MLDebugSymbol
+ using (var xCmd = xConn.CreateCommand())
{
- LabelName = x.LabelName,
- Address = x.Address,
- StackDifference = x.StackDiff,
- AssemblyFile = x.ILAsmFile,
- TypeToken = x.TypeToken,
- MethodToken = x.MethodToken,
- ILOffset = x.ILOffset,
- MethodName = x.MethodName
- });
+ xCmd.CommandText = "select LABELNAME, ADDRESS, STACKDIFF, ILASMFILE, TYPETOKEN, METHODTOKEN, ILOFFSET, METHODNAME from MLSYMBOL";
+ using (var xReader = xCmd.ExecuteReader())
+ {
+ while (xReader.Read())
+ {
+ aSymbols.Add(new MLDebugSymbol
+ {
+ LabelName=xReader.GetString(0),
+ Address = (uint)xReader.GetInt64(1),
+ StackDifference = xReader.GetInt32(2),
+ AssemblyFile = xReader.GetString(3),
+ TypeToken = xReader.GetInt32(4),
+ MethodToken = xReader.GetInt32(5),
+ ILOffset = xReader.GetInt32(6),
+ MethodName = xReader.GetString(7)
+ });
+ }
+ }
+ }
}
}
diff --git a/source2/Debug/Cosmos.Debug.Common/SourceInfo.cs b/source2/Debug/Cosmos.Debug.Common/SourceInfo.cs
index 73609e44e..b88fe4e9d 100644
--- a/source2/Debug/Cosmos.Debug.Common/SourceInfo.cs
+++ b/source2/Debug/Cosmos.Debug.Common/SourceInfo.cs
@@ -8,6 +8,7 @@ using Microsoft.Samples.Debugging.CorSymbolStore;
using System.Diagnostics.SymbolStore;
using System.IO;
using System.Diagnostics;
+using FirebirdSql.Data.FirebirdClient;
namespace Cosmos.Debug.Common
{
@@ -51,11 +52,24 @@ namespace Cosmos.Debug.Common
public static void WriteToFile(SortedList aMap, string outFile)
{
- using (var xOut = new StreamWriter(outFile, false))
+ using (var xConn = MLDebugSymbol.OpenOrCreateCPDB(outFile))
{
- foreach (var xItem in aMap)
+ using (var xTrans = xConn.BeginTransaction())
{
- xOut.WriteLine("{0}\t{1}", xItem.Key.ToString("X8"), xItem.Value);
+ using (var xCmd = xConn.CreateCommand())
+ {
+ xCmd.Transaction = xTrans;
+ xCmd.CommandText = "insert into ADDRESSLABELMAPPING (LABELNAME, ADDRESS) values (@LABELNAME, @ADDRESS)";
+ xCmd.Parameters.Add("@LABELNAME", FbDbType.VarChar);
+ xCmd.Parameters.Add("@ADDRESS", FbDbType.BigInt);
+ xCmd.Prepare();
+ foreach(var xItem in aMap){
+ xCmd.Parameters[0].Value = xItem.Value;
+ xCmd.Parameters[1].Value = xItem.Key;
+ xCmd.ExecuteNonQuery();
+ }
+ xTrans.Commit();
+ }
}
}
}
@@ -64,17 +78,20 @@ namespace Cosmos.Debug.Common
{
oAddressLabelMappings = new Dictionary();
oLabelAddressMappings = new Dictionary();
- foreach (var xLine in File.ReadAllLines(aFile))
+ using (var xConn = MLDebugSymbol.OpenOrCreateCPDB(aFile))
{
- if (!xLine.Contains('\t'))
+ using (var xCmd = xConn.CreateCommand())
{
- continue;
+ xCmd.CommandText = "select LABELNAME, ADDRESS from ADDRESSLABELMAPPING";
+ using (var xReader = xCmd.ExecuteReader())
+ {
+ while (xReader.Read())
+ {
+ oAddressLabelMappings.Add((uint)xReader.GetInt64(1), xReader.GetString(0));
+ oLabelAddressMappings.Add(xReader.GetString(0), (uint)xReader.GetInt64(1));
+ }
+ }
}
- var xPart1 = xLine.Substring(0, xLine.IndexOf('\t'));
- var xPart2 = xLine.Substring(xLine.IndexOf('\t') + 1);
- var xAddr = UInt32.Parse(xPart1, NumberStyles.HexNumber);
- oAddressLabelMappings.Add(xAddr, xPart2);
- oLabelAddressMappings.Add(xPart2, xAddr);
}
}
diff --git a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs
index f05e7885d..aa5cad0d5 100644
--- a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs
+++ b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs
@@ -189,18 +189,18 @@ namespace Cosmos.Debug.VSDebugEngine {
IDictionary xAddressLabelMappings;
IDictionary xLabelAddressMappings;
- string xCmapPath = Path.ChangeExtension(mISO, "cmap");
- if (!File.Exists(xCmapPath))
+ string xCpdbPath = Path.ChangeExtension(mISO, "cpdb");
+ if (!File.Exists(xCpdbPath))
{
- throw new Exception("Debug data file " + xCmapPath + " not found! Could be a omitted build process of Cosmos project so that not created.");
+ throw new Exception("Debug data file " + xCpdbPath + " not found! Could be a omitted build process of Cosmos project so that not created.");
}
- Cosmos.Debug.Common.SourceInfo.ReadFromFile(xCmapPath, out xAddressLabelMappings, out xLabelAddressMappings);
+ Cosmos.Debug.Common.SourceInfo.ReadFromFile(xCpdbPath, out xAddressLabelMappings, out xLabelAddressMappings);
if (xAddressLabelMappings.Count == 0)
{
throw new Exception("Debug data not found: LabelByAddressMapping");
}
-
- mSourceMappings = Cosmos.Debug.Common.SourceInfo.GetSourceInfo(xAddressLabelMappings, xLabelAddressMappings, Path.ChangeExtension(mISO, ".cxdb"));
+
+ mSourceMappings = Cosmos.Debug.Common.SourceInfo.GetSourceInfo(xAddressLabelMappings, xLabelAddressMappings, xCpdbPath);
if (mSourceMappings.Count == 0) {
throw new Exception("Debug data not found: SourceMappings");