@@ -174,6 +174,16 @@ static int poll_timeout = -1; // No value set.
174174static int cmd_disable_freelist = 0 ;
175175static bool signal_received[NSIG];
176176
177+ /*
178+ To be able to attach with a debugger to traffic_server running in an Au test case, temporarily add the
179+ parameter block_for_debug=True to the call to Test.MakeATSProcess(). This means Au test will wait
180+ effectively indefinitely (10 hours) for traffic_server to initialize itself. Run the modified Au test,
181+ attach the debugger to the traffic_server process, set one or more breakpoints, set the variable
182+ cmd_block to 0, then continue. On linux, the command 'ps -ef | fgrep -e --block' will help identify the
183+ PID of the traffic_server process (second column of output).
184+ */
185+ static int cmd_block = 0 ;
186+
177187// 1: the main thread delayed accepting, start accepting.
178188// 0: delay accept, wait for cache initialization.
179189// -1: cache is already initialized, don't delay.
@@ -217,6 +227,7 @@ static ArgumentDescription argument_descriptions[] = {
217227 {" bind_stderr" , ' -' , " Regular file to bind stderr to" , " S512" , &bind_stderr, " PROXY_BIND_STDERR" , nullptr },
218228 {" accept_mss" , ' -' , " MSS for client connections" , " I" , &accept_mss, nullptr , nullptr },
219229 {" poll_timeout" , ' t' , " poll timeout in milliseconds" , " I" , &poll_timeout, nullptr , nullptr },
230+ {" block" , ' -' , " block for debug attach" , " T" , &cmd_block, nullptr , nullptr },
220231 HELP_ARGUMENT_DESCRIPTION (),
221232 VERSION_ARGUMENT_DESCRIPTION (),
222233 RUNROOT_ARGUMENT_DESCRIPTION (),
@@ -1753,6 +1764,12 @@ main(int /* argc ATS_UNUSED */, const char **argv)
17531764 command_index = find_cmd_index (command_string);
17541765 command_valid = command_flag && command_index >= 0 ;
17551766
1767+ // Attach point when TS is blocked for debugging is in this loop.
1768+ //
1769+ while (cmd_block) {
1770+ sleep (1 );
1771+ }
1772+
17561773 ink_freelist_init_ops (cmd_disable_freelist, cmd_disable_pfreelist);
17571774
17581775#if TS_HAS_TESTS
0 commit comments