mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-11 02:31:22 +00:00
Now using SQL Local DB 2012 instead of CE.
This commit is contained in:
parent
7d54b2af32
commit
debaf8639e
8 changed files with 47 additions and 21 deletions
|
|
@ -52,7 +52,7 @@
|
|||
Condition="$(IsELF) == 'true'"/>
|
||||
|
||||
<ExtractMapFromElfFile InputFile="$(TargetDir)$(MSBuildProjectName).bin"
|
||||
DebugInfoFile="$(TargetDir)$(MSBuildProjectName).cpdb"
|
||||
DebugInfoFile="$(TargetDir)$(MSBuildProjectName).mdf"
|
||||
WorkingDir="$(TargetDir)"
|
||||
CosmosBuildDir="$(CosmosDir)\Build"
|
||||
Condition="$(IsELF) == 'true'"/>
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
<!--binary only-->
|
||||
<ReadNAsmMapToCosmosMap InputBaseDir="$(TargetDir)"
|
||||
DebugInfoFile="$(TargetDir)$(MSBuildProjectName).cpdb"
|
||||
DebugInfoFile="$(TargetDir)$(MSBuildProjectName).mdf"
|
||||
Condition="$(IsELF) == 'false'"/>
|
||||
<!--end of binary only-->
|
||||
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ namespace Cosmos.Build.MSBuild {
|
|||
}
|
||||
var xAsm = new AppAssemblerNasm(DebugCom);
|
||||
using (var xDebugInfo = new DebugInfo()) {
|
||||
xDebugInfo.CreateCPDB(xOutputFilename + ".cpdb");
|
||||
xDebugInfo.CreateDB(xOutputFilename + ".mdf");
|
||||
xAsm.DebugInfo = xDebugInfo;
|
||||
xAsm.DebugEnabled = DebugEnabled;
|
||||
xAsm.DebugMode = mDebugMode;
|
||||
|
|
|
|||
|
|
@ -54,16 +54,42 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
|
||||
private void OpenDB(string aPathname, bool aCreate) {
|
||||
var xCSB = new DbConnectionStringBuilder();
|
||||
xCSB["DataSource"] = aPathname;
|
||||
string xDbName = Path.GetFileNameWithoutExtension(aPathname);
|
||||
// Dont use DbConnectionStringBuilder class, it doesnt work with LocalDB properly.
|
||||
string xConnStr = @"Data Source=(LocalDB)\v11.0;Integrated Security=True;";
|
||||
|
||||
if (aCreate) {
|
||||
File.Delete(aPathname);
|
||||
var xEngine = new SqlEngine(xCSB.ToString());
|
||||
xEngine.CreateDatabase();
|
||||
using (var xConn = new SqlConnection(xConnStr)) {
|
||||
xConn.Open();
|
||||
|
||||
bool xDetach = false;
|
||||
using (var xCmd = xConn.CreateCommand()) {
|
||||
xCmd.CommandText = "select * from sys.databases where name = '" + xDbName + "'";
|
||||
using (var xReader = xCmd.ExecuteReader()) {
|
||||
xDetach = xReader.Read();
|
||||
}
|
||||
}
|
||||
if (xDetach) {
|
||||
using (var xCmd = xConn.CreateCommand()) {
|
||||
xCmd.CommandText = String.Format("exec sp_detach_db '{0}'", xDbName);
|
||||
xCmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
// Delete actual files
|
||||
File.Delete(aPathname);
|
||||
File.Delete(Path.Combine(Path.GetDirectoryName(aPathname), Path.GetFileNameWithoutExtension(aPathname) + "_log.ldf"));
|
||||
|
||||
// Create DB
|
||||
using (var xCmd = xConn.CreateCommand()) {
|
||||
xCmd.CommandText = String.Format("CREATE DATABASE {0} ON (NAME = N'{0}', FILENAME = '{1}')", xDbName, aPathname);
|
||||
xCmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mConnection = new SqlConnection(xCSB.ToString());
|
||||
xConnStr += "AttachDbFilename=" + aPathname + ";";
|
||||
mConnection = new SqlConnection(xConnStr);
|
||||
mConnection.Open();
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +100,7 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
}
|
||||
|
||||
public void CreateCPDB(string aPathname) {
|
||||
public void CreateDB(string aPathname) {
|
||||
OpenDB(aPathname, true);
|
||||
ExecSQL(
|
||||
"CREATE TABLE Method ("
|
||||
|
|
@ -137,7 +163,7 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
});
|
||||
|
||||
using (var xCmd = (SqlCeCommand)mConnection.CreateCommand()) {
|
||||
using (var xCmd = mConnection.CreateCommand()) {
|
||||
xCmd.CommandText = "INSERT INTO FIELD_MAPPING (TYPE_NAME, FIELD_NAME)" +
|
||||
" VALUES (@TYPE_NAME, @FIELD_NAME)";
|
||||
xCmd.Parameters.Add("@TYPE_NAME", SqlDbType.NVarChar);
|
||||
|
|
@ -199,7 +225,7 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
});
|
||||
|
||||
using (var xCmd = (SqlCeCommand)mConnection.CreateCommand()) {
|
||||
using (var xCmd = mConnection.CreateCommand()) {
|
||||
xCmd.CommandText = "INSERT INTO FIELD_INFO (TYPE, OFFSET, NAME)" +
|
||||
" VALUES (@TYPE, @OFFSET, @NAME)";
|
||||
xCmd.Parameters.Add("@TYPE", SqlDbType.NVarChar);
|
||||
|
|
@ -245,7 +271,7 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
|
||||
public void WriteSymbolsListToFile(IEnumerable<MLDebugSymbol> aSymbols) {
|
||||
using (var xCmd = (SqlCeCommand)mConnection.CreateCommand()) {
|
||||
using (var xCmd = mConnection.CreateCommand()) {
|
||||
xCmd.CommandText = "INSERT INTO MLSYMBOL (LABELNAME, STACKDIFF, ILASMFILE, TYPETOKEN, METHODTOKEN, ILOFFSET, METHODNAME)" +
|
||||
" VALUES (@LABELNAME, @STACKDIFF, @ILASMFILE, @TYPETOKEN, @METHODTOKEN, @ILOFFSET, @METHODNAME)";
|
||||
xCmd.Parameters.Add("@LABELNAME", SqlDbType.NVarChar);
|
||||
|
|
@ -312,7 +338,7 @@ namespace Cosmos.Debug.Common {
|
|||
|
||||
// tuple format: MethodLabel, IsArgument, Index, Offset
|
||||
public void WriteAllLocalsArgumentsInfos(IEnumerable<Local_Argument_Info> infos) {
|
||||
using (var xCmd = (SqlCeCommand)mConnection.CreateCommand()) {
|
||||
using (var xCmd = mConnection.CreateCommand()) {
|
||||
xCmd.CommandText = "insert into LOCAL_ARGUMENT_INFO (METHODLABELNAME, ISARGUMENT, INDEXINMETHOD, OFFSET, NAME, TYPENAME) values (@METHODLABELNAME, @ISARGUMENT, @INDEXINMETHOD, @OFFSET, @NAME, @TYPENAME)";
|
||||
xCmd.Parameters.Add("@METHODLABELNAME", SqlDbType.NVarChar);
|
||||
xCmd.Parameters.Add("@ISARGUMENT", SqlDbType.SmallInt);
|
||||
|
|
@ -392,7 +418,7 @@ namespace Cosmos.Debug.Common {
|
|||
public int AddMethod(string aLabelPrefix) {
|
||||
mMethodId++;
|
||||
|
||||
using (var xCmd = (SqlCeCommand)mConnection.CreateCommand()) {
|
||||
using (var xCmd = mConnection.CreateCommand()) {
|
||||
xCmd.CommandText = "INSERT INTO Method (MethodId, LabelPrefix) values (@MethodId, @LabelPrefix)";
|
||||
xCmd.Parameters.AddWithValue("@MethodId", mMethodId);
|
||||
xCmd.Parameters.AddWithValue("@LabelPrefix", aLabelPrefix);
|
||||
|
|
@ -403,7 +429,7 @@ namespace Cosmos.Debug.Common {
|
|||
}
|
||||
|
||||
public void WriteLabels(List<KeyValuePair<uint, string>> aMap) {
|
||||
using (var xCmd = (SqlCeCommand)mConnection.CreateCommand()) {
|
||||
using (var xCmd = mConnection.CreateCommand()) {
|
||||
xCmd.CommandText = "insert into Label (LABELNAME, ADDRESS) values (@LABELNAME, @ADDRESS)";
|
||||
xCmd.Parameters.Add("@LABELNAME", SqlDbType.NVarChar);
|
||||
xCmd.Parameters.Add("@ADDRESS", SqlDbType.BigInt);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -241,7 +241,7 @@ namespace Cosmos.Debug.GDB {
|
|||
// path of asm, obj and cgdb
|
||||
using(var xDialog = new OpenFileDialog())
|
||||
{
|
||||
xDialog.Filter = "Symbols (*.asm;*.obj;*.cpdb)|*.asm;*.obj;*.cpdb";
|
||||
xDialog.Filter = "Symbols (*.asm;*.obj;*.mdf)|*.asm;*.obj;*.mdf";
|
||||
xDialog.ShowHelp = true;
|
||||
xDialog.HelpRequest += new EventHandler(xDialog_HelpRequest);
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ namespace Cosmos.Debug.GDB {
|
|||
|
||||
void xDialog_HelpRequest(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Select a folder which contain files of type asm, obj and cpdb with same name.", "Help", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||||
MessageBox.Show("Select a folder which contain files of type asm, obj and mdf with same name.", "Help", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||||
}
|
||||
|
||||
private void OnRunStateChanged(bool stopped)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace Cosmos.Debug.GDB {
|
|||
|
||||
if (false == File.Exists(Path.Combine(mOutputPath, mObjFile))
|
||||
|| false == File.Exists(Path.Combine(mOutputPath, mAsmFile))
|
||||
|| false == File.Exists(Path.Combine(mOutputPath, Path.GetFileNameWithoutExtension(Filename) + ".cpdb")))
|
||||
|| false == File.Exists(Path.Combine(mOutputPath, Path.GetFileNameWithoutExtension(Filename) + ".mdf")))
|
||||
{
|
||||
mOutputPath = null;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace Cosmos.Debug.VSDebugEngine {
|
|||
}
|
||||
mHost.OnShutDown += HostShutdown;
|
||||
|
||||
string xDbPath = Path.ChangeExtension(mISO, "sdf");
|
||||
string xDbPath = Path.ChangeExtension(mISO, "mdf");
|
||||
if (!File.Exists(xDbPath)) {
|
||||
throw new Exception("Debug data file " + xDbPath + " not found. Could be a omitted build process of Cosmos project so that not created.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Cosmos.IL2CPU.Profiler {
|
|||
protected override void InitILOps() {
|
||||
var xILOp = new ILOp(this.Assembler);
|
||||
this.DebugInfo = new Debug.Common.DebugInfo();
|
||||
this.DebugInfo.CreateCPDB(AppDomain.CurrentDomain.BaseDirectory + "DebugInfo");
|
||||
this.DebugInfo.CreateDB(AppDomain.CurrentDomain.BaseDirectory + "DebugInfo");
|
||||
// Don't change the type in the foreach to a var, its necessary as it is now
|
||||
// to typecast it, so we can then recast to an int.
|
||||
foreach (ILOpCode.Code xCode in Enum.GetValues(typeof(ILOpCode.Code))) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue