Skip to content

Commit 55a12cb

Browse files
author
senthil
committed
Fix for issues 51 and 52
51: Updated the python:run_command to look for : Locked. 52: Added option -L that is a variation of non-interactive Added the constant with safequit and implemented the equivalent python
1 parent 5f90ebb commit 55a12cb

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

ios-deploy.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
command script add -f {python_command}.connect_command connect\n\
3636
command script add -s asynchronous -f {python_command}.run_command run\n\
3737
command script add -s asynchronous -f {python_command}.autoexit_command autoexit\n\
38+
command script add -s asynchronous -f {python_command}.safequit_command safequit\n\
3839
connect\n\
3940
")
4041

@@ -44,6 +45,12 @@ const char* lldb_prep_interactive_cmds = "\
4445
run\n\
4546
";
4647

48+
const char* lldb_prep_noninteractive_justlaunch_cmds = "\
49+
run\n\
50+
detach\n\
51+
safequit\n\
52+
";
53+
4754
const char* lldb_prep_noninteractive_cmds = "\
4855
run\n\
4956
autoexit\n\
@@ -88,7 +95,15 @@ def run_command(debugger, command, result, internal_dict):\n\
8895
error = lldb.SBError()\n\
8996
lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_app))\n\
9097
lldb.target.Launch(lldb.SBLaunchInfo(shlex.split('{args}')), error)\n\
91-
print str(error)\n\
98+
lockedstr = ': Locked'\n\
99+
if lockedstr in str(error):\n\
100+
print('\\nDevice Locked\\n')\n\
101+
sys.exit(254)\n\
102+
else:\n\
103+
print(str(error))\n\
104+
\n\
105+
def safequit_command(debugger, command, result, internal_dict):\n\
106+
sys.exit(0);\n\
92107
\n\
93108
def autoexit_command(debugger, command, result, internal_dict):\n\
94109
process = lldb.target.process\n\
@@ -135,6 +150,7 @@ char *target_filename = NULL;
135150
char *upload_pathname = NULL;
136151
char *bundle_id = NULL;
137152
bool interactive = true;
153+
bool justlaunch = false;
138154
char *app_path = NULL;
139155
char *device_id = NULL;
140156
char *args = NULL;
@@ -688,7 +704,12 @@ void write_lldb_prep_cmds(AMDeviceRef device, CFURLRef disk_app_url) {
688704
// Write additional commands based on mode we're running in
689705
const char* extra_cmds;
690706
if (!interactive)
691-
extra_cmds = lldb_prep_noninteractive_cmds;
707+
{
708+
if (justlaunch)
709+
extra_cmds = lldb_prep_noninteractive_justlaunch_cmds;
710+
else
711+
extra_cmds = lldb_prep_noninteractive_cmds;
712+
}
692713
else if (nostart)
693714
extra_cmds = lldb_prep_no_cmds;
694715
else
@@ -1335,6 +1356,7 @@ void usage(const char* app) {
13351356
" -x, --gdbexec <file> GDB commands script file\n"
13361357
" -n, --nostart do not start the app when debugging\n"
13371358
" -I, --noninteractive start in non interactive mode (quit when app crashes or exits)\n"
1359+
" -L, --justlaunch just launch the app and exit lldb\n"
13381360
" -v, --verbose enable verbose output\n"
13391361
" -m, --noinstall directly start debugging without app install (-d not required)\n"
13401362
" -p, --port <number> port used for device, default: 12345 \n"
@@ -1363,6 +1385,7 @@ int main(int argc, char *argv[]) {
13631385
{ "unbuffered", no_argument, NULL, 'u' },
13641386
{ "nostart", no_argument, NULL, 'n' },
13651387
{ "noninteractive", no_argument, NULL, 'I' },
1388+
{ "justlaunch", no_argument, NULL, 'L' },
13661389
{ "detect", no_argument, NULL, 'c' },
13671390
{ "version", no_argument, NULL, 'V' },
13681391
{ "noinstall", no_argument, NULL, 'm' },
@@ -1376,7 +1399,7 @@ int main(int argc, char *argv[]) {
13761399
};
13771400
char ch;
13781401

1379-
while ((ch = getopt_long(argc, argv, "VmcdvunlrIi:b:a:t:g:x:p:1:2:o:", longopts, NULL)) != -1)
1402+
while ((ch = getopt_long(argc, argv, "VmcdvunlrILi:b:a:t:g:x:p:1:2:o:", longopts, NULL)) != -1)
13801403
{
13811404
switch (ch) {
13821405
case 'm':
@@ -1410,6 +1433,10 @@ int main(int argc, char *argv[]) {
14101433
case 'I':
14111434
interactive = false;
14121435
break;
1436+
case 'L':
1437+
interactive = false;
1438+
justlaunch = true;
1439+
break;
14131440
case 'c':
14141441
detect_only = true;
14151442
break;

0 commit comments

Comments
 (0)