Skip to content

Commit ae44ad0

Browse files
Merge pull request #43 from telerik/tachev/detach-native-debugger
fix: close the gdb socket on start application in order to avoid app freeze on unhandled exception
2 parents 23f6090 + d28b888 commit ae44ad0

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

IOSDeviceLib/GDBHelper.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ bool init(std::string& executable, SOCKET socket, std::string& application_ident
6262
return true;
6363
}
6464

65-
bool run_application(std::string& executable, SOCKET socket, std::string& application_identifier, std::map<std::string, ApplicationCache>& apps_cache)
65+
bool run_application(std::string& executable, SOCKET socket, std::string& application_identifier, DeviceData* device_data)
6666
{
67-
RETURN_IF_FALSE(init(executable, socket, application_identifier, apps_cache));
67+
RETURN_IF_FALSE(init(executable, socket, application_identifier, device_data->apps_cache));
6868
// Couldn't find official info on this but I'm guessing this is the method we need to call
6969
RETURN_IF_FALSE(await_response("qLaunchSuccess", socket));
7070
// vCont specifies a command to be run - c means continue
@@ -81,6 +81,9 @@ bool run_application(std::string& executable, SOCKET socket, std::string& applic
8181
// We have decided we do not need this at the moment, but it is vital that it be read from the pipe
8282
// Else it will remain there and may be read later on and mistaken for a response to same other package
8383
std::string answer = receive_message_raw(socket);
84+
85+
detach_connection(socket, application_identifier, device_data);
86+
8487
return true;
8588
}
8689

@@ -130,4 +133,5 @@ void detach_connection(SOCKET socket, std::string& application_identifier, Devic
130133
std::string answer = receive_message_raw(socket);
131134
device_data->apps_cache[application_identifier].has_initialized_gdb = false;
132135
device_data->services.erase(kDebugServer);
136+
close(socket);
133137
}

IOSDeviceLib/GDBHelper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
std::string get_gdb_message(std::string message);
88
int gdb_send_message(std::string message, SOCKET socket, long long length = -1);
9-
bool run_application(std::string& executable, SOCKET socket, std::string& application_identifier, std::map<std::string, ApplicationCache>& apps_cache);
9+
bool run_application(std::string& executable, SOCKET socket, std::string& application_identifier, DeviceData* device_data);
1010
bool stop_application(std::string& executable, SOCKET socket, std::string& application_identifier, std::map<std::string, ApplicationCache>& apps_cache);
1111
void detach_connection(SOCKET socket, std::string& application_identifier, DeviceData* device_data);
1212

IOSDeviceLib/IOSDeviceLib.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ void start_app(std::string device_identifier, std::string application_identifier
12601260
}
12611261

12621262
std::string executable = map[application_identifier][kPathPascalCase] + "/" + map[application_identifier]["CFBundleExecutable"];
1263-
if (run_application(executable, (SOCKET)gdb, application_identifier, devices[device_identifier].apps_cache))
1263+
if (run_application(executable, (SOCKET)gdb, application_identifier, &devices[device_identifier]))
12641264
print(json({ { kResponse, "Successfully started application" },{ kId, method_id },{ kDeviceId, device_identifier } }));
12651265
else
12661266
print_error("Could not start application", device_identifier, method_id, kApplicationsCustomError);

0 commit comments

Comments
 (0)