add option --T_dont_fork to tracee (lte-softmodem, oaisim)
The T has 2 processes: the tracee and the local tracer if the tracee dies (segfault or whatever) the tracee may still be running. So there is a third process that monitors those two others and kill everything when one dies. The problem is that this third process has to be the parent of the two others. That makes debugging the tracee with gdb impossible. This new option disables the third monitor process.
This commit is contained in:
+8
-6
@@ -107,7 +107,7 @@ static void monitor_and_kill(int child1, int child2)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void T_init(int remote_port, int wait_for_tracer)
|
||||
void T_init(int remote_port, int wait_for_tracer, int dont_fork)
|
||||
{
|
||||
int socket_pair[2];
|
||||
int s;
|
||||
@@ -117,7 +117,7 @@ void T_init(int remote_port, int wait_for_tracer)
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair))
|
||||
{ perror("socketpair"); abort(); }
|
||||
|
||||
/* child1 runs the local tracer and child2 runs the tracee */
|
||||
/* child1 runs the local tracer and child2 (or main) runs the tracee */
|
||||
|
||||
child1 = fork(); if (child1 == -1) abort();
|
||||
if (child1 == 0) {
|
||||
@@ -127,10 +127,12 @@ void T_init(int remote_port, int wait_for_tracer)
|
||||
}
|
||||
close(socket_pair[0]);
|
||||
|
||||
child2 = fork(); if (child2 == -1) abort();
|
||||
if (child2 != 0) {
|
||||
close(socket_pair[1]);
|
||||
monitor_and_kill(child1, child2);
|
||||
if (dont_fork == 0) {
|
||||
child2 = fork(); if (child2 == -1) abort();
|
||||
if (child2 != 0) {
|
||||
close(socket_pair[1]);
|
||||
monitor_and_kill(child1, child2);
|
||||
}
|
||||
}
|
||||
|
||||
s = socket_pair[1];
|
||||
|
||||
+1
-1
@@ -562,7 +562,7 @@ extern T_cache_t *T_cache;
|
||||
|
||||
extern int *T_active;
|
||||
|
||||
void T_init(int remote_port, int wait_for_tracer);
|
||||
void T_init(int remote_port, int wait_for_tracer, int dont_fork);
|
||||
|
||||
#else /* T_TRACER */
|
||||
|
||||
|
||||
@@ -490,6 +490,7 @@ void help (void) {
|
||||
#if T_TRACER
|
||||
printf(" --T_port [port] use given port\n");
|
||||
printf(" --T_nowait don't wait for tracer, start immediately\n");
|
||||
printf(" --T_dont_fork to ease debugging with gdb\n");
|
||||
#endif
|
||||
printf(RESET);
|
||||
fflush(stdout);
|
||||
@@ -2332,6 +2333,7 @@ static void get_options (int argc, char **argv)
|
||||
#if T_TRACER
|
||||
LONG_OPTION_T_PORT,
|
||||
LONG_OPTION_T_NOWAIT,
|
||||
LONG_OPTION_T_DONT_FORK,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -2355,6 +2357,7 @@ static void get_options (int argc, char **argv)
|
||||
#if T_TRACER
|
||||
{"T_port", required_argument, 0, LONG_OPTION_T_PORT},
|
||||
{"T_nowait", no_argument, 0, LONG_OPTION_T_NOWAIT},
|
||||
{"T_dont_fork", no_argument, 0, LONG_OPTION_T_DONT_FORK},
|
||||
#endif
|
||||
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -2457,6 +2460,12 @@ static void get_options (int argc, char **argv)
|
||||
T_wait = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case LONG_OPTION_T_DONT_FORK: {
|
||||
extern int T_dont_fork;
|
||||
T_dont_fork = 1;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case 'A':
|
||||
@@ -2822,6 +2831,7 @@ static void get_options (int argc, char **argv)
|
||||
#if T_TRACER
|
||||
int T_wait = 1; /* by default we wait for the tracer */
|
||||
int T_port = 2021; /* default port to listen to to wait for the tracer */
|
||||
int T_dont_fork = 0; /* default is to fork, see 'T_init' to understand */
|
||||
#endif
|
||||
|
||||
int main( int argc, char **argv )
|
||||
@@ -2894,7 +2904,7 @@ int main( int argc, char **argv )
|
||||
openair0_cfg[0].configFilename = rf_config_file;
|
||||
|
||||
#if T_TRACER
|
||||
T_init(T_port, T_wait);
|
||||
T_init(T_port, T_wait, T_dont_fork);
|
||||
#endif
|
||||
|
||||
// initialize the log (see log.h for details)
|
||||
|
||||
@@ -250,6 +250,7 @@ help (void)
|
||||
#if T_TRACER
|
||||
printf ("--T_port [port] use given port\n");
|
||||
printf ("--T_nowait don't wait for tracer, start immediately\n");
|
||||
printf ("--T_dont_fork to ease debugging with gdb\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1258,6 +1259,7 @@ l2l1_task (void *args_p)
|
||||
#if T_TRACER
|
||||
int T_wait = 1; /* by default we wait for the tracer */
|
||||
int T_port = 2021; /* default port to listen to to wait for the tracer */
|
||||
int T_dont_fork = 0; /* default is to fork, see 'T_init' to understand */
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
@@ -1294,7 +1296,7 @@ main (int argc, char **argv)
|
||||
get_simulation_options (argc, argv); //Command-line options
|
||||
|
||||
#if T_TRACER
|
||||
T_init(T_port, T_wait);
|
||||
T_init(T_port, T_wait, T_dont_fork);
|
||||
#endif
|
||||
|
||||
// Initialize VCD LOG module
|
||||
|
||||
@@ -216,6 +216,7 @@ void get_simulation_options(int argc, char *argv[])
|
||||
#if T_TRACER
|
||||
LONG_OPTION_T_PORT,
|
||||
LONG_OPTION_T_NOWAIT,
|
||||
LONG_OPTION_T_DONT_FORK,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -254,6 +255,7 @@ void get_simulation_options(int argc, char *argv[])
|
||||
#if T_TRACER
|
||||
{"T_port", required_argument, 0, LONG_OPTION_T_PORT},
|
||||
{"T_nowait", no_argument, 0, LONG_OPTION_T_NOWAIT},
|
||||
{"T_dont_fork", no_argument, 0, LONG_OPTION_T_DONT_FORK},
|
||||
#endif
|
||||
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -436,6 +438,12 @@ void get_simulation_options(int argc, char *argv[])
|
||||
T_wait = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case LONG_OPTION_T_DONT_FORK: {
|
||||
extern int T_dont_fork;
|
||||
T_dont_fork = 1;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case 'a':
|
||||
|
||||
Reference in New Issue
Block a user