Browse Source

Adding VS2015 debugger attach support

JoshEngebretson 10 years ago
parent
commit
a3d7b4a9c3

+ 2 - 0
Script/AtomicEditor/ui/EditorStrings.ts

@@ -21,6 +21,7 @@ export enum StringID {
     ShortcutCloseFile,
     ShortcutSaveFile,
     ShortcutPlay,
+    ShortcutPlayDebug,
     ShortcutBuild,
     ShortcutBuildSettings
 }
@@ -71,6 +72,7 @@ export class EditorString {
         lookup[StringID.ShortcutCloseFile] = shortcutKey + "W";
 
         lookup[StringID.ShortcutPlay] = shortcutKey + "P";
+        lookup[StringID.ShortcutPlayDebug] = "⇧" + shortcutKey + "P";
 
         lookup[StringID.ShortcutBuild] = shortcutKey + "B";
 

+ 8 - 0
Script/AtomicEditor/ui/Shortcuts.ts

@@ -26,6 +26,14 @@ class Shortcuts extends Atomic.ScriptObject {
 
     }
 
+    invokePlayDebug() {
+
+        this.sendEvent(EditorEvents.SaveAllResources);
+        Atomic.editorMode.playProjectDebug();
+
+    }
+
+
     invokeFormatCode() {
 
         var editor = EditorUI.getMainFrame().resourceframe.currentResourceEditor;

+ 7 - 1
Script/AtomicEditor/ui/frames/menus/MainFrameMenu.ts

@@ -58,6 +58,11 @@ class MainFrameMenu extends Atomic.ScriptObject {
                 return true;
             }
 
+            if (refid == "edit play debug") {
+                EditorUI.getShortcuts().invokePlayDebug();
+                return true;
+            }
+
             if (refid == "edit format code") {
                 EditorUI.getShortcuts().invokeFormatCode();
                 return true;
@@ -244,7 +249,8 @@ var editItems = {
     "-3": null,
     "Format Code": ["edit format code", StringID.ShortcutBeautify],
     "-4": null,
-    "Play": ["edit play", StringID.ShortcutPlay]
+    "Play": ["edit play", StringID.ShortcutPlay],
+    "Debug (C# Project)": ["edit play debug", StringID.ShortcutPlayDebug]
 
 };
 

+ 4 - 0
Script/AtomicNET/AtomicNETTest/MyClass.cs

@@ -18,9 +18,13 @@ namespace AtomicNETTest
         [Inspector]
         float speed = 1.0f;
 
+        [Inspector]
+        float pitchSpeed = 0.0f;
+
         public override void Update(float timeStep)
         {
           Node.Yaw(timeStep * speed * 75.0f);
+          Node.Pitch(timeStep * pitchSpeed * 75.0f);
 
           //Console.WriteLine("TICK! : {0}", speed);
         }

+ 16 - 2
Source/AtomicEditor/Application/AEPlayerApp.cpp

@@ -47,7 +47,8 @@ namespace AtomicEditor
 {
 
 AEPlayerApplication::AEPlayerApplication(Context* context) :
-    AEEditorCommon(context)
+    AEEditorCommon(context),
+    debugPlayer_(false)
 {
 }
 
@@ -100,6 +101,10 @@ void AEPlayerApplication::Setup()
             {
                 SubscribeToEvent(E_LOGMESSAGE, HANDLER(AEPlayerApplication, HandleLogMessage));
             }
+            else if (argument == "--debug")
+            {
+                debugPlayer_ = true;
+            }
             else if (argument == "--project" && value.Length())
             {
                 engineParameters_["ResourcePrefixPath"] = "";
@@ -115,8 +120,10 @@ void AEPlayerApplication::Setup()
                          ATOMIC_ROOT_SOURCE_DIR, ATOMIC_ROOT_SOURCE_DIR, value.CString(), value.CString(), value.CString(), value.CString());
 
 #ifdef ATOMIC_DOTNET
+                NETCore* netCore = GetSubsystem<NETCore>();
                 String assemblyLoadPath = GetNativePath(ToString("%sResources/Assemblies/", value.CString()));
-                GetSubsystem<NETCore>()->AddAssemblyLoadPath(assemblyLoadPath);
+                netCore->AddAssemblyLoadPath(assemblyLoadPath);
+
 #endif
 
 #else
@@ -159,6 +166,13 @@ void AEPlayerApplication::Start()
 
     SubscribeToEvent(E_JSERROR, HANDLER(AEPlayerApplication, HandleJSError));
 
+#ifdef ATOMIC_DOTNET
+        if (debugPlayer_)
+        {
+           GetSubsystem<NETCore>()->WaitForDebuggerConnect();
+        }
+#endif
+
     vm_->SetModuleSearchPaths("Modules");
 
     // Instantiate and register the Player subsystem

+ 2 - 0
Source/AtomicEditor/Application/AEPlayerApp.h

@@ -41,6 +41,8 @@ private:
 
     void HandleLogMessage(StringHash eventType, VariantMap& eventData);
 
+    bool debugPlayer_;
+
 };
 
 }

+ 9 - 1
Source/AtomicEditor/EditorMode/AEEditorMode.cpp

@@ -87,7 +87,7 @@ void EditorMode::HandleIPCJSError(StringHash eventType, VariantMap& eventData)
 
 }
 
-bool EditorMode::PlayProject()
+bool EditorMode::PlayProject(bool debug)
 {
     ToolEnvironment* env = GetSubsystem<ToolEnvironment>();
     ToolSystem* tsystem = GetSubsystem<ToolSystem>();
@@ -117,6 +117,9 @@ bool EditorMode::PlayProject()
 
     vargs = args.Split(' ');
 
+    if (debug)
+        vargs.Insert(0, "--debug");
+
     String dump;
     dump.Join(vargs, " ");
     LOGINFOF("Launching Broker %s %s", editorBinary.CString(), dump.CString());
@@ -135,4 +138,9 @@ bool EditorMode::PlayProject()
 
 }
 
+bool EditorMode::PlayProjectDebug()
+{
+    return PlayProject(true);
+}
+
 }

+ 2 - 1
Source/AtomicEditor/EditorMode/AEEditorMode.h

@@ -32,7 +32,8 @@ public:
     /// Destruct.
     virtual ~EditorMode();
 
-    bool PlayProject();
+    bool PlayProject(bool debug = false);
+    bool PlayProjectDebug();
 
 private:
 

+ 5 - 0
Source/AtomicNET/NETCore/NETCore.cpp

@@ -239,6 +239,11 @@ ATOMIC_EXPORT_API void csb_AtomicEngine_ReleaseRef(RefCounted* ref)
 
 }
 
+void NETCore::WaitForDebuggerConnect()
+{
+    netHost_->WaitForDebuggerConnect();
+}
+
 void NETCore::AddAssemblyLoadPath(const String& assemblyPath)
 {
     typedef void (*AddAssemblyLoadPathFunction)(const char* assemblyPath);

+ 1 - 0
Source/AtomicNET/NETCore/NETCore.h

@@ -46,6 +46,7 @@ public:
 
     void AddAssemblyLoadPath(const String& assemblyPath);
     bool CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut);
+    void WaitForDebuggerConnect();
 
     /// We access this directly in binding code, where there isn't a context
     /// to get a reference from

+ 1 - 0
Source/AtomicNET/NETCore/NETHost.h

@@ -19,6 +19,7 @@ public:
 
     virtual bool Initialize(const String& coreCLRFilesAbsPath, const String& assemblyLoadPaths) = 0;
     virtual bool CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut) = 0;
+    virtual void WaitForDebuggerConnect() = 0;
 
 };
 

+ 5 - 5
Source/AtomicNET/NETCore/Platforms/Windows/NETHostWindows.cpp

@@ -98,15 +98,15 @@ bool NETHostWindows::Initialize(const String& coreCLRFilesAbsPath, const String
     }
 
 
-    /*
+    return true;
+}
+
+void NETHostWindows::WaitForDebuggerConnect()
+{
     while (!IsDebuggerPresent())
     {
         Sleep(100);
     }
-    */
-
-
-    return true;
 }
 
 bool NETHostWindows::LoadCLRDLL()

+ 2 - 0
Source/AtomicNET/NETCore/Platforms/Windows/NETHostWindows.h

@@ -67,6 +67,8 @@ public:
 
     bool CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut);
 
+    void WaitForDebuggerConnect();
+
 private:
 
     bool LoadCLRDLL();