diff --git a/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets b/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets
index 1990ca21c..7232f4f4e 100644
--- a/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets
+++ b/source2/Build/Cosmos.Build.MSBuild/Cosmos.targets
@@ -52,7 +52,7 @@
Condition="$(IsELF) == 'true'"/>
@@ -66,7 +66,7 @@
diff --git a/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs b/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs
index c24b4a8a9..759583327 100644
--- a/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs
+++ b/source2/Build/Cosmos.Build.MSBuild/IL2CPUTask.cs
@@ -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;
diff --git a/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs b/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs
index 3886a1336..7551a8896 100644
--- a/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs
+++ b/source2/Debug/Cosmos.Debug.Common/DebugInfo.cs
@@ -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 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 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> 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);
diff --git a/source2/Debug/Cosmos.Debug.Common/Empty.mdf b/source2/Debug/Cosmos.Debug.Common/Empty.mdf
index 8b15f9286..f6438e41c 100644
Binary files a/source2/Debug/Cosmos.Debug.Common/Empty.mdf and b/source2/Debug/Cosmos.Debug.Common/Empty.mdf differ
diff --git a/source2/Debug/Cosmos.Debug.GDB/FormMain.cs b/source2/Debug/Cosmos.Debug.GDB/FormMain.cs
index f6053a321..a914ee8b9 100644
--- a/source2/Debug/Cosmos.Debug.GDB/FormMain.cs
+++ b/source2/Debug/Cosmos.Debug.GDB/FormMain.cs
@@ -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)
diff --git a/source2/Debug/Cosmos.Debug.GDB/Settings.cs b/source2/Debug/Cosmos.Debug.GDB/Settings.cs
index 61a56a623..e9aa8264c 100644
--- a/source2/Debug/Cosmos.Debug.GDB/Settings.cs
+++ b/source2/Debug/Cosmos.Debug.GDB/Settings.cs
@@ -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;
diff --git a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs
index 5af0b9105..2f79c5212 100644
--- a/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs
+++ b/source2/Debug/Cosmos.Debug.VSDebugEngine/AD7.Impl/AD7Process.cs
@@ -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.");
}
diff --git a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Assembler.cs b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Assembler.cs
index bed9e477a..e1af7e63c 100644
--- a/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Assembler.cs
+++ b/source2/IL2CPU/Cosmos.IL2CPU.Profiler/Assembler.cs
@@ -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))) {