mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 04:48:53 +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\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
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<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.Utilities.v4.0" />
|
||||
<Reference Include="System" />
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
Condition="$(IsELF) == 'true'"/>
|
||||
<Delete Files="$(TargetDir)$(MSBuildProjectName).obj" Condition="$(IsELF) == 'true'"/>
|
||||
<ExtractMapFromElfFile InputFile="$(TargetDir)$(MSBuildProjectName).bin"
|
||||
OutputFile="$(TargetDir)$(MSBuildProjectName).cmap"
|
||||
OutputFile="$(TargetDir)$(MSBuildProjectName).cpdb"
|
||||
WorkingDir="$(TargetDir)"
|
||||
CosmosBuildDir="$(CosmosDir)\Build"
|
||||
Condition="$(IsELF) == 'true'"/>
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
<!--binary only-->
|
||||
<ReadNAsmMapToCosmosMap InputBaseDir="$(TargetDir)"
|
||||
OutputFile="$(TargetDir)$(MSBuildProjectName).cmap"
|
||||
OutputFile="$(TargetDir)$(MSBuildProjectName).cpdb"
|
||||
Condition="$(IsELF) == 'false'"/>
|
||||
<!--end of binary only-->
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<MLDebugSymbol> 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<MLDebugSymbol> 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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<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>();
|
||||
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<string, uint> 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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue