mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-05 15:51:56 +00:00
Only 1 debug info file is used now (.cpdb)
This commit is contained in:
parent
140a8c3a03
commit
121464d6cd
7 changed files with 105 additions and 73 deletions
|
|
@ -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\raw.*; DestDir: {app}\Build\VSIP\; Flags: ignoreversion uninsremovereadonly
|
||||||
Source: .\Build\VSIP\fbembed.dll; 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\icu*.dll; DestDir: {app}\Build\VSIP\; Flags: ignoreversion uninsremovereadonly
|
||||||
|
Source: .\Build\VSIP\FirebirdSql.Data.FirebirdClient.*; DestDir: {app}\Build\VSIP\; Flags: ignoreversion uninsremovereadonly
|
||||||
|
|
||||||
; wizards
|
; wizards
|
||||||
Source: .\Build\VSIP\Cosmos.VS.Wizards.*; DestDir: {code:VSNET2010_PATH}\PrivateAssemblies; Flags: ignoreversion uninsremovereadonly
|
Source: .\Build\VSIP\Cosmos.VS.Wizards.*; DestDir: {code:VSNET2010_PATH}\PrivateAssemblies; Flags: ignoreversion uninsremovereadonly
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="FirebirdSql.Data.FirebirdClient, Version=2.5.2.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\Debug\Cosmos.Debug.Common\FirebirdSql.Data.FirebirdClient.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Microsoft.Build.Framework" />
|
<Reference Include="Microsoft.Build.Framework" />
|
||||||
<Reference Include="Microsoft.Build.Utilities.v4.0" />
|
<Reference Include="Microsoft.Build.Utilities.v4.0" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
Condition="$(IsELF) == 'true'"/>
|
Condition="$(IsELF) == 'true'"/>
|
||||||
<Delete Files="$(TargetDir)$(MSBuildProjectName).obj" Condition="$(IsELF) == 'true'"/>
|
<Delete Files="$(TargetDir)$(MSBuildProjectName).obj" Condition="$(IsELF) == 'true'"/>
|
||||||
<ExtractMapFromElfFile InputFile="$(TargetDir)$(MSBuildProjectName).bin"
|
<ExtractMapFromElfFile InputFile="$(TargetDir)$(MSBuildProjectName).bin"
|
||||||
OutputFile="$(TargetDir)$(MSBuildProjectName).cmap"
|
OutputFile="$(TargetDir)$(MSBuildProjectName).cpdb"
|
||||||
WorkingDir="$(TargetDir)"
|
WorkingDir="$(TargetDir)"
|
||||||
CosmosBuildDir="$(CosmosDir)\Build"
|
CosmosBuildDir="$(CosmosDir)\Build"
|
||||||
Condition="$(IsELF) == 'true'"/>
|
Condition="$(IsELF) == 'true'"/>
|
||||||
|
|
@ -69,7 +69,7 @@
|
||||||
|
|
||||||
<!--binary only-->
|
<!--binary only-->
|
||||||
<ReadNAsmMapToCosmosMap InputBaseDir="$(TargetDir)"
|
<ReadNAsmMapToCosmosMap InputBaseDir="$(TargetDir)"
|
||||||
OutputFile="$(TargetDir)$(MSBuildProjectName).cmap"
|
OutputFile="$(TargetDir)$(MSBuildProjectName).cpdb"
|
||||||
Condition="$(IsELF) == 'false'"/>
|
Condition="$(IsELF) == 'false'"/>
|
||||||
<!--end of binary only-->
|
<!--end of binary only-->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,8 @@ namespace Cosmos.Build.MSBuild {
|
||||||
if (EmitDebugSymbols)
|
if (EmitDebugSymbols)
|
||||||
{
|
{
|
||||||
xNasmAsm.FlushText(xOut);
|
xNasmAsm.FlushText(xOut);
|
||||||
xAsm.WriteDebugSymbols(xOutputFilename + ".cxdb");
|
File.Delete(xOutputFilename + ".cpdb");
|
||||||
|
xAsm.WriteDebugSymbols(xOutputFilename + ".cpdb");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,18 @@ namespace Cosmos.Debug.Common
|
||||||
|
|
||||||
public class MLDebugSymbol
|
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)
|
private static FbConnection OpenCPDB(string aPathname, bool aCreate)
|
||||||
{
|
{
|
||||||
var xCSB = new FbConnectionStringBuilder();
|
var xCSB = new FbConnectionStringBuilder();
|
||||||
|
|
@ -85,7 +97,7 @@ namespace Cosmos.Debug.Common
|
||||||
var xExec = new FbBatchExecution(DBConn);
|
var xExec = new FbBatchExecution(DBConn);
|
||||||
|
|
||||||
xExec.SqlStatements.Add(
|
xExec.SqlStatements.Add(
|
||||||
"CREATE TABLE SYMBOL ("
|
"CREATE TABLE MLSYMBOL ("
|
||||||
+ " LABELNAME VARCHAR(255) NOT NULL"
|
+ " LABELNAME VARCHAR(255) NOT NULL"
|
||||||
+ " , ADDRESS BIGINT NOT NULL"
|
+ " , ADDRESS BIGINT NOT NULL"
|
||||||
+ " , STACKDIFF INT NOT NULL"
|
+ " , STACKDIFF INT NOT NULL"
|
||||||
|
|
@ -96,6 +108,11 @@ namespace Cosmos.Debug.Common
|
||||||
+ " , METHODNAME VARCHAR(255) NOT NULL"
|
+ " , METHODNAME VARCHAR(255) NOT NULL"
|
||||||
+ ");"
|
+ ");"
|
||||||
);
|
);
|
||||||
|
xExec.SqlStatements.Add(
|
||||||
|
"CREATE TABLE ADDRESSLABELMAPPING ("
|
||||||
|
+ " LABELNAME VARCHAR(255) NOT NULL"
|
||||||
|
+ ", ADDRESS BIGINT NOT NULL"
|
||||||
|
+ ");");
|
||||||
|
|
||||||
xExec.Execute();
|
xExec.Execute();
|
||||||
// Batch execution closes the connection, so we have to reopen it
|
// Batch execution closes the connection, so we have to reopen it
|
||||||
|
|
@ -106,80 +123,73 @@ namespace Cosmos.Debug.Common
|
||||||
|
|
||||||
public static void WriteSymbolsListToFile(IEnumerable<MLDebugSymbol> aSymbols, string aFile)
|
public static void WriteSymbolsListToFile(IEnumerable<MLDebugSymbol> aSymbols, string aFile)
|
||||||
{
|
{
|
||||||
// Use a temporary file for the database and then move the newly created database to the wanted location afterwards.
|
using (FbConnection DBConn = OpenOrCreateCPDB(aFile))
|
||||||
// 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))
|
|
||||||
{
|
{
|
||||||
var xDS = new SymbolsDS();
|
|
||||||
|
|
||||||
using (FbTransaction transaction = DBConn.BeginTransaction())
|
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)";
|
" VALUES (@LABELNAME, @ADDRESS, @STACKDIFF, @ILASMFILE, @TYPETOKEN, @METHODTOKEN, @ILOFFSET, @METHODNAME)";
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
// 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.
|
// 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)
|
foreach (var xItem in aSymbols)
|
||||||
{
|
{
|
||||||
var x = xDS.Entry.NewEntryRow();
|
xCmd.Parameters[0].Value = xItem.LabelName;
|
||||||
x.LabelName = xItem.LabelName;
|
xCmd.Parameters[1].Value = xItem.Address;
|
||||||
x.Address = xItem.Address;
|
xCmd.Parameters[2].Value = xItem.StackDifference;
|
||||||
x.StackDiff = xItem.StackDifference;
|
xCmd.Parameters[3].Value = xItem.AssemblyFile;
|
||||||
x.ILAsmFile = xItem.AssemblyFile;
|
xCmd.Parameters[4].Value = xItem.TypeToken;
|
||||||
x.TypeToken = xItem.TypeToken;
|
xCmd.Parameters[5].Value = xItem.MethodToken;
|
||||||
x.MethodToken = xItem.MethodToken;
|
xCmd.Parameters[6].Value = xItem.ILOffset;
|
||||||
x.ILOffset = xItem.ILOffset;
|
xCmd.Parameters[7].Value = xItem.MethodName;
|
||||||
x.MethodName = xItem.MethodName;
|
|
||||||
xDS.Entry.AddEntryRow(x);
|
|
||||||
|
|
||||||
using (var xCmd = new FbCommand(sqlstmt, DBConn, transaction))
|
|
||||||
{
|
|
||||||
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.ExecuteNonQuery();
|
xCmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
xDS.WriteXml(aFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(dbname))
|
|
||||||
File.Delete(dbname);
|
|
||||||
|
|
||||||
File.Move(tmpdbname, dbname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ReadSymbolsListFromFile(List<MLDebugSymbol> aSymbols, string aFile)
|
public static void ReadSymbolsListFromFile(List<MLDebugSymbol> aSymbols, string aFile)
|
||||||
{
|
{
|
||||||
//OpenCPDB(Path.ChangeExtension(aFile, ".cpdb"), false);
|
using (var xConn = OpenCPDB(aFile, false))
|
||||||
var xDS = new SymbolsDS();
|
{
|
||||||
xDS.ReadXml(aFile);
|
using (var xCmd = xConn.CreateCommand())
|
||||||
foreach (SymbolsDS.EntryRow x in xDS.Entry.Rows)
|
{
|
||||||
|
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
|
aSymbols.Add(new MLDebugSymbol
|
||||||
{
|
{
|
||||||
LabelName = x.LabelName,
|
LabelName=xReader.GetString(0),
|
||||||
Address = x.Address,
|
Address = (uint)xReader.GetInt64(1),
|
||||||
StackDifference = x.StackDiff,
|
StackDifference = xReader.GetInt32(2),
|
||||||
AssemblyFile = x.ILAsmFile,
|
AssemblyFile = xReader.GetString(3),
|
||||||
TypeToken = x.TypeToken,
|
TypeToken = xReader.GetInt32(4),
|
||||||
MethodToken = x.MethodToken,
|
MethodToken = xReader.GetInt32(5),
|
||||||
ILOffset = x.ILOffset,
|
ILOffset = xReader.GetInt32(6),
|
||||||
MethodName = x.MethodName
|
MethodName = xReader.GetString(7)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string LabelName
|
public string LabelName
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using Microsoft.Samples.Debugging.CorSymbolStore;
|
||||||
using System.Diagnostics.SymbolStore;
|
using System.Diagnostics.SymbolStore;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using FirebirdSql.Data.FirebirdClient;
|
||||||
|
|
||||||
namespace Cosmos.Debug.Common
|
namespace Cosmos.Debug.Common
|
||||||
{
|
{
|
||||||
|
|
@ -51,11 +52,24 @@ namespace Cosmos.Debug.Common
|
||||||
|
|
||||||
public static void WriteToFile(SortedList<uint, String> aMap, string outFile)
|
public static void WriteToFile(SortedList<uint, String> 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<uint, string>();
|
oAddressLabelMappings = new Dictionary<uint, string>();
|
||||||
oLabelAddressMappings = new Dictionary<string, uint>();
|
oLabelAddressMappings = new Dictionary<string, uint>();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,18 +189,18 @@ namespace Cosmos.Debug.VSDebugEngine {
|
||||||
|
|
||||||
IDictionary<uint, string> xAddressLabelMappings;
|
IDictionary<uint, string> xAddressLabelMappings;
|
||||||
IDictionary<string, uint> xLabelAddressMappings;
|
IDictionary<string, uint> xLabelAddressMappings;
|
||||||
string xCmapPath = Path.ChangeExtension(mISO, "cmap");
|
string xCpdbPath = Path.ChangeExtension(mISO, "cpdb");
|
||||||
if (!File.Exists(xCmapPath))
|
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)
|
if (xAddressLabelMappings.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Debug data not found: LabelByAddressMapping");
|
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) {
|
if (mSourceMappings.Count == 0) {
|
||||||
throw new Exception("Debug data not found: SourceMappings");
|
throw new Exception("Debug data not found: SourceMappings");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue