@@ -319,7 +319,6 @@ RNBRunLoopLaunchInferior (RNBRemote *remote, const char *stdin_path, const char
319
319
320
320
switch (pid_state)
321
321
{
322
- default :
323
322
case eStateInvalid:
324
323
case eStateUnloaded:
325
324
case eStateAttaching:
@@ -637,28 +636,28 @@ RNBRunLoopPlatform (RNBRemote *remote)
637
636
while (mode == eRNBRunLoopModePlatformMode)
638
637
{
639
638
std::string set_events_str;
640
- const uint32_t event_mask = RNBContext::event_read_packet_available |
639
+ const uint32_t event_mask = RNBContext::event_read_packet_available |
641
640
RNBContext::event_read_thread_exiting;
642
-
641
+
643
642
DNBLogThreadedIf (LOG_RNB_EVENTS, " %s ctx.Events().WaitForSetEvents(0x%08x) ..." ,__FUNCTION__, event_mask);
644
643
nub_event_t set_events = ctx.Events ().WaitForSetEvents (event_mask);
645
644
DNBLogThreadedIf (LOG_RNB_EVENTS, " %s ctx.Events().WaitForSetEvents(0x%08x) => 0x%08x (%s)" ,__FUNCTION__, event_mask, set_events, ctx.EventsAsString (set_events, set_events_str));
646
-
645
+
647
646
if (set_events)
648
647
{
649
648
if (set_events & RNBContext::event_read_packet_available)
650
649
{
651
650
if (remote->HandleReceivedPacket () == rnb_not_connected)
652
651
mode = eRNBRunLoopModeExit;
653
652
}
654
-
653
+
655
654
if (set_events & RNBContext::event_read_thread_exiting)
656
655
{
657
656
mode = eRNBRunLoopModeExit;
658
657
}
659
658
ctx.Events ().ResetEvents (set_events);
660
659
}
661
- }
660
+ }
662
661
return eRNBRunLoopModeExit;
663
662
}
664
663
@@ -671,9 +670,9 @@ static void
671
670
PortWasBoundCallbackUnixSocket (const void *baton, in_port_t port)
672
671
{
673
672
// ::printf ("PortWasBoundCallbackUnixSocket (baton = %p, port = %u)\n", baton, port);
674
-
673
+
675
674
const char *unix_socket_name = (const char *)baton;
676
-
675
+
677
676
if (unix_socket_name && unix_socket_name[0 ])
678
677
{
679
678
// We were given a unix socket name to use to communicate the port
@@ -685,37 +684,37 @@ PortWasBoundCallbackUnixSocket (const void *baton, in_port_t port)
685
684
perror (" error: socket (AF_UNIX, SOCK_STREAM, 0)" );
686
685
exit (1 );
687
686
}
688
-
687
+
689
688
saddr_un.sun_family = AF_UNIX;
690
689
::strncpy (saddr_un.sun_path, unix_socket_name, sizeof (saddr_un.sun_path) - 1);
691
690
saddr_un.sun_path [sizeof (saddr_un.sun_path ) - 1 ] = ' \0 ' ;
692
691
saddr_un.sun_len = SUN_LEN (&saddr_un);
693
-
692
+
694
693
if (::connect (s, (struct sockaddr *)&saddr_un, static_cast <socklen_t >(SUN_LEN (&saddr_un))) < 0 )
695
694
{
696
695
perror (" error: connect (socket, &saddr_un, saddr_un_len)" );
697
696
exit (1 );
698
697
}
699
-
698
+
700
699
// ::printf ("connect () sucess!!\n");
701
-
702
-
700
+
701
+
703
702
// We were able to connect to the socket, now write our PID so whomever
704
703
// launched us will know this process's ID
705
704
RNBLogSTDOUT (" Listening to port %i...\n " , port);
706
-
705
+
707
706
char pid_str[64 ];
708
707
const int pid_str_len = ::snprintf (pid_str, sizeof (pid_str), " %u" , port);
709
708
const ssize_t bytes_sent = ::send (s, pid_str, pid_str_len, 0 );
710
-
709
+
711
710
if (pid_str_len != bytes_sent)
712
711
{
713
712
perror (" error: send (s, pid_str, pid_str_len, 0)" );
714
713
exit (1 );
715
714
}
716
-
715
+
717
716
// ::printf ("send () sucess!!\n");
718
-
717
+
719
718
// We are done with the socket
720
719
close (s);
721
720
}
@@ -893,7 +892,7 @@ main (int argc, char *argv[])
893
892
#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
894
893
struct sched_param thread_param;
895
894
int thread_sched_policy;
896
- if (pthread_getschedparam (pthread_self (), &thread_sched_policy, &thread_param) == 0 )
895
+ if (pthread_getschedparam (pthread_self (), &thread_sched_policy, &thread_param) == 0 )
897
896
{
898
897
thread_param.sched_priority = 47 ;
899
898
pthread_setschedparam (pthread_self (), thread_sched_policy, &thread_param);
@@ -915,25 +914,25 @@ main (int argc, char *argv[])
915
914
// signal (SIGINT, signal_handler);
916
915
signal (SIGPIPE, signal_handler);
917
916
signal (SIGHUP, signal_handler);
918
-
917
+
919
918
// We're always sitting in waitpid or kevent waiting on our target process' death,
920
919
// we don't need no stinking SIGCHLD's...
921
-
920
+
922
921
sigset_t sigset;
923
922
sigemptyset (&sigset);
924
923
sigaddset (&sigset, SIGCHLD);
925
924
sigprocmask (SIG_BLOCK, &sigset, NULL );
926
925
927
926
g_remoteSP.reset (new RNBRemote ());
928
-
929
-
927
+
928
+
930
929
RNBRemote *remote = g_remoteSP.get ();
931
930
if (remote == NULL )
932
931
{
933
932
RNBLogSTDERR (" error: failed to create a remote connection class\n " );
934
933
return -1 ;
935
934
}
936
-
935
+
937
936
RNBContext& ctx = remote->Context ();
938
937
939
938
int i;
@@ -965,11 +964,11 @@ main (int argc, char *argv[])
965
964
966
965
char short_options[512 ];
967
966
uint32_t short_options_idx = 0 ;
968
-
967
+
969
968
// Handle the two case that don't have short options in g_long_options
970
969
short_options[short_options_idx++] = ' k' ;
971
970
short_options[short_options_idx++] = ' t' ;
972
-
971
+
973
972
for (i=0 ; g_long_options[i].name != NULL ; ++i)
974
973
{
975
974
if (isalpha (g_long_options[i].val ))
@@ -978,7 +977,7 @@ main (int argc, char *argv[])
978
977
switch (g_long_options[i].has_arg )
979
978
{
980
979
default :
981
- case no_argument:
980
+ case no_argument:
982
981
break ;
983
982
984
983
case optional_argument:
@@ -992,7 +991,7 @@ main (int argc, char *argv[])
992
991
}
993
992
// NULL terminate the short option string.
994
993
short_options[short_options_idx++] = ' \0 ' ;
995
-
994
+
996
995
#if __GLIBC__
997
996
optind = 0 ;
998
997
#else
@@ -1074,7 +1073,7 @@ main (int argc, char *argv[])
1074
1073
}
1075
1074
}
1076
1075
break ;
1077
-
1076
+
1078
1077
case ' K' :
1079
1078
g_detach_on_error = false ;
1080
1079
@@ -1139,7 +1138,7 @@ main (int argc, char *argv[])
1139
1138
if (log_file != NULL )
1140
1139
setlinebuf (log_file);
1141
1140
}
1142
-
1141
+
1143
1142
if (log_file == NULL )
1144
1143
{
1145
1144
const char *errno_str = strerror (errno);
@@ -1190,15 +1189,15 @@ main (int argc, char *argv[])
1190
1189
case ' O' :
1191
1190
ctx.GetSTDOUT ().assign (optarg);
1192
1191
break ;
1193
-
1192
+
1194
1193
case ' E' :
1195
1194
ctx.GetSTDERR ().assign (optarg);
1196
1195
break ;
1197
1196
1198
1197
case ' n' :
1199
1198
no_stdio = true ;
1200
1199
break ;
1201
-
1200
+
1202
1201
case ' S' :
1203
1202
// Put debugserver into a new session. Terminals group processes
1204
1203
// into sessions and when a special terminal key sequences
@@ -1216,7 +1215,7 @@ main (int argc, char *argv[])
1216
1215
case ' D' :
1217
1216
g_disable_aslr = 1 ;
1218
1217
break ;
1219
-
1218
+
1220
1219
case ' p' :
1221
1220
start_mode = eRNBRunLoopModePlatformMode;
1222
1221
break ;
@@ -1228,12 +1227,12 @@ main (int argc, char *argv[])
1228
1227
case ' P' :
1229
1228
named_pipe_path.assign (optarg);
1230
1229
break ;
1231
-
1230
+
1232
1231
case ' e' :
1233
1232
// Pass a single specified environment variable down to the process that gets launched
1234
1233
remote->Context ().PushEnvironment (optarg);
1235
1234
break ;
1236
-
1235
+
1237
1236
case ' F' :
1238
1237
// Pass the current environment down to the process that gets launched
1239
1238
{
@@ -1246,10 +1245,10 @@ main (int argc, char *argv[])
1246
1245
break ;
1247
1246
}
1248
1247
}
1249
-
1248
+
1250
1249
if (arch_name.empty ())
1251
1250
{
1252
- #if defined (__arm__)
1251
+ #if defined (__arm__)
1253
1252
arch_name.assign (" arm" );
1254
1253
#endif
1255
1254
}
@@ -1278,7 +1277,7 @@ main (int argc, char *argv[])
1278
1277
}
1279
1278
1280
1279
remote->Context ().SetDetachOnError (g_detach_on_error);
1281
-
1280
+
1282
1281
remote->Initialize ();
1283
1282
1284
1283
// It is ok for us to set NULL as the logfile (this will disable any logging)
@@ -1603,7 +1602,7 @@ main (int argc, char *argv[])
1603
1602
1604
1603
case eRNBRunLoopModeInferiorLaunching:
1605
1604
{
1606
- mode = RNBRunLoopLaunchInferior (remote,
1605
+ mode = RNBRunLoopLaunchInferior (remote,
1607
1606
ctx.GetSTDINPath (),
1608
1607
ctx.GetSTDOUTPath (),
1609
1608
ctx.GetSTDERRPath (),
@@ -1653,7 +1652,7 @@ main (int argc, char *argv[])
1653
1652
if (remote->Comm ().OpenFile (str))
1654
1653
mode = eRNBRunLoopModeExit;
1655
1654
}
1656
-
1655
+
1657
1656
if (mode != eRNBRunLoopModeExit)
1658
1657
mode = RNBRunLoopPlatform (remote);
1659
1658
break ;
0 commit comments