From 39c6b3d942e1b872538cd062347d5a5631f57f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 22 Aug 2017 00:43:10 +0200 Subject: [PATCH 1/2] Make Android debug over USB the only option 'Remote debug over ADB' is removed as that will be always the case. --- platform/android/export/export.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index ee93c295776..ffc446ff708 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -2960,11 +2960,7 @@ public: //export_temp ep.step("Exporting APK", 0); - bool use_adb_over_usb = bool(EDITOR_DEF("export/android/use_remote_debug_over_adb", true)); - - if (use_adb_over_usb) { - p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST; - } + p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST; String export_to = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport.apk"; Error err = export_project(p_preset, true, export_to, p_debug_flags); @@ -3017,7 +3013,7 @@ public: return ERR_CANT_CREATE; } - if (use_adb_over_usb) { + if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) { args.clear(); args.push_back("-s"); @@ -3036,6 +3032,9 @@ public: err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); print_line("Reverse result: " + itos(rv)); + } + + if (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT) { int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); @@ -3618,7 +3617,6 @@ void register_android_exporter() { EDITOR_DEF("export/android/force_system_user", false); EDITOR_DEF("export/android/timestamping_authority_url", ""); - EDITOR_DEF("export/android/use_remote_debug_over_adb", false); EDITOR_DEF("export/android/shutdown_adb_on_exit", true); Ref exporter = Ref(memnew(EditorExportAndroid)); From 2a5ee5dec93b768f6caeb109be2a052ca610e747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 22 Aug 2017 17:21:41 +0200 Subject: [PATCH 2/2] Fix Android remote debug not hitting breakpoints A change in `Main`'s API is needed. Please read the comment in the diff for an explanation. --- main/main.cpp | 7 +++++-- main/main.h | 3 ++- platform/android/java_glue.cpp | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index e49c66dddfb..425e736d933 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -69,7 +69,6 @@ #include "core/io/file_access_zip.h" #include "core/io/stream_peer_ssl.h" #include "core/io/stream_peer_tcp.h" -#include "core/os/thread.h" #include "main/input_default.h" #include "performance.h" #include "translation.h" @@ -886,7 +885,11 @@ error: return ERR_INVALID_PARAMETER; } -Error Main::setup2() { +Error Main::setup2(Thread::ID p_main_tid_override) { + + if (p_main_tid_override) { + Thread::_main_thread_id = p_main_tid_override; + } OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx); if (init_use_custom_pos) { diff --git a/main/main.h b/main/main.h index ca96e397ca7..98f46c13c65 100644 --- a/main/main.h +++ b/main/main.h @@ -34,6 +34,7 @@ @author Juan Linietsky */ +#include "core/os/thread.h" #include "error_list.h" #include "typedefs.h" @@ -49,7 +50,7 @@ class Main { public: static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true); - static Error setup2(); + static Error setup2(Thread::ID p_main_tid_override = 0); static bool start(); static bool iteration(); static void cleanup(); diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index eb139fb471a..33781b13859 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -1008,7 +1008,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaClassWrapper", java_class_wrapper)); _initialize_java_modules(); - Main::setup2(); + // Since Godot is initialized on the UI thread, _main_thread_id was set to that thread's id, + // but for Godot purposes, the main thread is the one running the game loop + Main::setup2(Thread::get_caller_id()); ++step; suspend_mutex->unlock(); input_mutex->unlock();