Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Process debugging functions. |
| 3 | * |
| 4 | * Copyright 2000-2019 Willy Tarreau <willy@haproxy.org>. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <signal.h> |
| 14 | #include <time.h> |
| 15 | #include <stdio.h> |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 16 | #include <stdlib.h> |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 17 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 18 | #include <common/buf.h> |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 19 | #include <common/config.h> |
| 20 | #include <common/debug.h> |
| 21 | #include <common/hathreads.h> |
| 22 | #include <common/initcall.h> |
Willy Tarreau | 68680bb | 2019-10-23 17:23:25 +0200 | [diff] [blame] | 23 | #include <common/ist.h> |
| 24 | #include <common/net_helper.h> |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 25 | #include <common/standard.h> |
| 26 | |
| 27 | #include <types/global.h> |
| 28 | |
| 29 | #include <proto/cli.h> |
| 30 | #include <proto/fd.h> |
Willy Tarreau | 78a7cb6 | 2019-08-21 14:16:02 +0200 | [diff] [blame] | 31 | #include <proto/hlua.h> |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 32 | #include <proto/stream_interface.h> |
| 33 | #include <proto/task.h> |
| 34 | |
Willy Tarreau | a37cb18 | 2019-07-31 19:20:39 +0200 | [diff] [blame] | 35 | /* mask of threads still having to dump, used to respect ordering. Only used |
| 36 | * when USE_THREAD_DUMP is set. |
| 37 | */ |
| 38 | volatile unsigned long threads_to_dump = 0; |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 39 | unsigned int debug_commands_issued = 0; |
Willy Tarreau | a37cb18 | 2019-07-31 19:20:39 +0200 | [diff] [blame] | 40 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 41 | /* Dumps to the buffer some known information for the desired thread, and |
| 42 | * optionally extra info for the current thread. The dump will be appended to |
| 43 | * the buffer, so the caller is responsible for preliminary initializing it. |
| 44 | * The calling thread ID needs to be passed in <calling_tid> to display a star |
Willy Tarreau | e6a02fa | 2019-05-22 07:06:44 +0200 | [diff] [blame] | 45 | * in front of the calling thread's line (usually it's tid). Any stuck thread |
| 46 | * is also prefixed with a '>'. |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 47 | */ |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 48 | void ha_thread_dump(struct buffer *buf, int thr, int calling_tid) |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 49 | { |
| 50 | unsigned long thr_bit = 1UL << thr; |
David Carlier | a92c5ce | 2019-09-13 05:03:12 +0100 | [diff] [blame] | 51 | unsigned long long p = ha_thread_info[thr].prev_cpu_time; |
| 52 | unsigned long long n = now_cpu_time_thread(&ha_thread_info[thr]); |
| 53 | int stuck = !!(ha_thread_info[thr].flags & TI_FL_STUCK); |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 54 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 55 | chunk_appendf(buf, |
Willy Tarreau | e6a02fa | 2019-05-22 07:06:44 +0200 | [diff] [blame] | 56 | "%c%cThread %-2u: act=%d glob=%d wq=%d rq=%d tl=%d tlsz=%d rqsz=%d\n" |
Olivier Houchard | 305d5ab | 2019-07-24 18:07:06 +0200 | [diff] [blame] | 57 | " stuck=%d prof=%d", |
Willy Tarreau | e6a02fa | 2019-05-22 07:06:44 +0200 | [diff] [blame] | 58 | (thr == calling_tid) ? '*' : ' ', stuck ? '>' : ' ', thr + 1, |
Olivier Houchard | cfbb3e6 | 2019-05-29 19:22:43 +0200 | [diff] [blame] | 59 | thread_has_tasks(), |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 60 | !!(global_tasks_mask & thr_bit), |
| 61 | !eb_is_empty(&task_per_thread[thr].timers), |
| 62 | !eb_is_empty(&task_per_thread[thr].rqueue), |
Olivier Houchard | 0691046 | 2019-10-11 16:35:01 +0200 | [diff] [blame] | 63 | !(LIST_ISEMPTY(&task_per_thread[thr].task_list) | |
| 64 | MT_LIST_ISEMPTY(&task_per_thread[thr].shared_tasklet_list)), |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 65 | task_per_thread[thr].task_list_size, |
| 66 | task_per_thread[thr].rqueue_size, |
Willy Tarreau | e6a02fa | 2019-05-22 07:06:44 +0200 | [diff] [blame] | 67 | stuck, |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 68 | !!(task_profiling_mask & thr_bit)); |
| 69 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 70 | chunk_appendf(buf, |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 71 | " harmless=%d wantrdv=%d", |
| 72 | !!(threads_harmless_mask & thr_bit), |
| 73 | !!(threads_want_rdv_mask & thr_bit)); |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 74 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 75 | chunk_appendf(buf, "\n"); |
Willy Tarreau | 9c8800a | 2019-05-20 20:52:20 +0200 | [diff] [blame] | 76 | chunk_appendf(buf, " cpu_ns: poll=%llu now=%llu diff=%llu\n", p, n, n-p); |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 77 | |
| 78 | /* this is the end of what we can dump from outside the thread */ |
| 79 | |
| 80 | if (thr != tid) |
| 81 | return; |
| 82 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 83 | chunk_appendf(buf, " curr_task="); |
Willy Tarreau | d022e9c | 2019-09-24 08:25:15 +0200 | [diff] [blame] | 84 | ha_task_dump(buf, sched->current, " "); |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 88 | /* dumps into the buffer some information related to task <task> (which may |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 89 | * either be a task or a tasklet, and prepend each line except the first one |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 90 | * with <pfx>. The buffer is only appended and the first output starts by the |
| 91 | * pointer itself. The caller is responsible for making sure the task is not |
| 92 | * going to vanish during the dump. |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 93 | */ |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 94 | void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx) |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 95 | { |
Willy Tarreau | 578ea8b | 2019-05-22 09:43:09 +0200 | [diff] [blame] | 96 | const struct stream *s = NULL; |
Willy Tarreau | a512b02 | 2019-08-21 14:12:19 +0200 | [diff] [blame] | 97 | const struct appctx __maybe_unused *appctx = NULL; |
Willy Tarreau | 78a7cb6 | 2019-08-21 14:16:02 +0200 | [diff] [blame] | 98 | struct hlua __maybe_unused *hlua = NULL; |
Willy Tarreau | 578ea8b | 2019-05-22 09:43:09 +0200 | [diff] [blame] | 99 | |
Willy Tarreau | 14a1ab7 | 2019-05-17 10:34:25 +0200 | [diff] [blame] | 100 | if (!task) { |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 101 | chunk_appendf(buf, "0\n"); |
Willy Tarreau | 231ec39 | 2019-05-17 10:39:47 +0200 | [diff] [blame] | 102 | return; |
| 103 | } |
| 104 | |
Willy Tarreau | 20db911 | 2019-05-17 14:14:35 +0200 | [diff] [blame] | 105 | if (TASK_IS_TASKLET(task)) |
| 106 | chunk_appendf(buf, |
| 107 | "%p (tasklet) calls=%u\n", |
| 108 | task, |
| 109 | task->calls); |
| 110 | else |
| 111 | chunk_appendf(buf, |
| 112 | "%p (task) calls=%u last=%llu%s\n", |
| 113 | task, |
| 114 | task->calls, |
| 115 | task->call_date ? (unsigned long long)(now_mono_time() - task->call_date) : 0, |
| 116 | task->call_date ? " ns ago" : ""); |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 117 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 118 | chunk_appendf(buf, "%s" |
Willy Tarreau | a512b02 | 2019-08-21 14:12:19 +0200 | [diff] [blame] | 119 | " fct=%p (%s) ctx=%p", |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 120 | pfx, |
Willy Tarreau | 14a1ab7 | 2019-05-17 10:34:25 +0200 | [diff] [blame] | 121 | task->process, |
| 122 | task->process == process_stream ? "process_stream" : |
| 123 | task->process == task_run_applet ? "task_run_applet" : |
| 124 | task->process == si_cs_io_cb ? "si_cs_io_cb" : |
Willy Tarreau | 78a7cb6 | 2019-08-21 14:16:02 +0200 | [diff] [blame] | 125 | #ifdef USE_LUA |
| 126 | task->process == hlua_process_task ? "hlua_process_task" : |
| 127 | #endif |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 128 | "?", |
Willy Tarreau | 14a1ab7 | 2019-05-17 10:34:25 +0200 | [diff] [blame] | 129 | task->context); |
Willy Tarreau | 578ea8b | 2019-05-22 09:43:09 +0200 | [diff] [blame] | 130 | |
Willy Tarreau | a512b02 | 2019-08-21 14:12:19 +0200 | [diff] [blame] | 131 | if (task->process == task_run_applet && (appctx = task->context)) |
| 132 | chunk_appendf(buf, "(%s)\n", appctx->applet->name); |
| 133 | else |
| 134 | chunk_appendf(buf, "\n"); |
| 135 | |
Willy Tarreau | 578ea8b | 2019-05-22 09:43:09 +0200 | [diff] [blame] | 136 | if (task->process == process_stream && task->context) |
| 137 | s = (struct stream *)task->context; |
| 138 | else if (task->process == task_run_applet && task->context) |
| 139 | s = si_strm(((struct appctx *)task->context)->owner); |
| 140 | else if (task->process == si_cs_io_cb && task->context) |
| 141 | s = si_strm((struct stream_interface *)task->context); |
| 142 | |
| 143 | if (s) |
| 144 | stream_dump(buf, s, pfx, '\n'); |
Willy Tarreau | 78a7cb6 | 2019-08-21 14:16:02 +0200 | [diff] [blame] | 145 | |
| 146 | #ifdef USE_LUA |
| 147 | hlua = NULL; |
| 148 | if (s && (hlua = s->hlua)) { |
| 149 | chunk_appendf(buf, "%sCurrent executing Lua from a stream analyser -- ", pfx); |
| 150 | } |
| 151 | else if (task->process == hlua_process_task && (hlua = task->context)) { |
| 152 | chunk_appendf(buf, "%sCurrent executing a Lua task -- ", pfx); |
| 153 | } |
| 154 | else if (task->process == task_run_applet && (appctx = task->context) && |
| 155 | (appctx->applet->fct == hlua_applet_tcp_fct && (hlua = appctx->ctx.hlua_apptcp.hlua))) { |
| 156 | chunk_appendf(buf, "%sCurrent executing a Lua TCP service -- ", pfx); |
| 157 | } |
| 158 | else if (task->process == task_run_applet && (appctx = task->context) && |
| 159 | (appctx->applet->fct == hlua_applet_http_fct && (hlua = appctx->ctx.hlua_apphttp.hlua))) { |
| 160 | chunk_appendf(buf, "%sCurrent executing a Lua HTTP service -- ", pfx); |
| 161 | } |
| 162 | |
| 163 | if (hlua) { |
| 164 | luaL_traceback(hlua->T, hlua->T, NULL, 0); |
| 165 | if (!append_prefixed_str(buf, lua_tostring(hlua->T, -1), pfx, '\n', 1)) |
| 166 | b_putchr(buf, '\n'); |
| 167 | } |
| 168 | #endif |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 169 | } |
| 170 | |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 171 | /* This function dumps all profiling settings. It returns 0 if the output |
| 172 | * buffer is full and it needs to be called again, otherwise non-zero. |
| 173 | */ |
| 174 | static int cli_io_handler_show_threads(struct appctx *appctx) |
| 175 | { |
| 176 | struct stream_interface *si = appctx->owner; |
| 177 | int thr; |
| 178 | |
| 179 | if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW))) |
| 180 | return 1; |
| 181 | |
| 182 | if (appctx->st0) |
| 183 | thr = appctx->st1; |
| 184 | else |
| 185 | thr = 0; |
| 186 | |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 187 | chunk_reset(&trash); |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 188 | ha_thread_dump_all_to_trash(); |
Willy Tarreau | 5cf64dd | 2019-05-17 10:36:08 +0200 | [diff] [blame] | 189 | |
| 190 | if (ci_putchk(si_ic(si), &trash) == -1) { |
| 191 | /* failed, try again */ |
| 192 | si_rx_room_blk(si); |
| 193 | appctx->st1 = thr; |
| 194 | return 0; |
| 195 | } |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 196 | return 1; |
| 197 | } |
| 198 | |
Willy Tarreau | 56131ca | 2019-05-20 13:48:29 +0200 | [diff] [blame] | 199 | /* dumps a state of all threads into the trash and on fd #2, then aborts. */ |
| 200 | void ha_panic() |
| 201 | { |
| 202 | chunk_reset(&trash); |
Willy Tarreau | a9f9fc9 | 2019-05-20 17:45:35 +0200 | [diff] [blame] | 203 | chunk_appendf(&trash, "Thread %u is about to kill the process.\n", tid + 1); |
Willy Tarreau | 56131ca | 2019-05-20 13:48:29 +0200 | [diff] [blame] | 204 | ha_thread_dump_all_to_trash(); |
Tim Duesterhus | dda1155 | 2019-06-12 20:47:30 +0200 | [diff] [blame] | 205 | shut_your_big_mouth_gcc(write(2, trash.area, trash.data)); |
Willy Tarreau | 56131ca | 2019-05-20 13:48:29 +0200 | [diff] [blame] | 206 | for (;;) |
| 207 | abort(); |
| 208 | } |
| 209 | |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 210 | /* parse a "debug dev exit" command. It always returns 1, though it should never return. */ |
| 211 | static int debug_parse_cli_exit(char **args, char *payload, struct appctx *appctx, void *private) |
| 212 | { |
| 213 | int code = atoi(args[3]); |
| 214 | |
| 215 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 216 | return 1; |
| 217 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 218 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 219 | exit(code); |
| 220 | return 1; |
| 221 | } |
| 222 | |
| 223 | /* parse a "debug dev close" command. It always returns 1. */ |
| 224 | static int debug_parse_cli_close(char **args, char *payload, struct appctx *appctx, void *private) |
| 225 | { |
| 226 | int fd; |
| 227 | |
| 228 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 229 | return 1; |
| 230 | |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 231 | if (!*args[3]) |
| 232 | return cli_err(appctx, "Missing file descriptor number.\n"); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 233 | |
| 234 | fd = atoi(args[3]); |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 235 | if (fd < 0 || fd >= global.maxsock) |
| 236 | return cli_err(appctx, "File descriptor out of range.\n"); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 237 | |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 238 | if (!fdtab[fd].owner) |
| 239 | return cli_msg(appctx, LOG_INFO, "File descriptor was already closed.\n"); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 240 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 241 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 242 | fd_delete(fd); |
| 243 | return 1; |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /* parse a "debug dev delay" command. It always returns 1. */ |
| 247 | static int debug_parse_cli_delay(char **args, char *payload, struct appctx *appctx, void *private) |
| 248 | { |
| 249 | int delay = atoi(args[3]); |
| 250 | |
| 251 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 252 | return 1; |
| 253 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 254 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 255 | usleep((long)delay * 1000); |
| 256 | return 1; |
| 257 | } |
| 258 | |
| 259 | /* parse a "debug dev log" command. It always returns 1. */ |
| 260 | static int debug_parse_cli_log(char **args, char *payload, struct appctx *appctx, void *private) |
| 261 | { |
| 262 | int arg; |
| 263 | |
| 264 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 265 | return 1; |
| 266 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 267 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 268 | chunk_reset(&trash); |
| 269 | for (arg = 3; *args[arg]; arg++) { |
| 270 | if (arg > 3) |
| 271 | chunk_strcat(&trash, " "); |
| 272 | chunk_strcat(&trash, args[arg]); |
| 273 | } |
| 274 | |
| 275 | send_log(NULL, LOG_INFO, "%s\n", trash.area); |
| 276 | return 1; |
| 277 | } |
| 278 | |
| 279 | /* parse a "debug dev loop" command. It always returns 1. */ |
| 280 | static int debug_parse_cli_loop(char **args, char *payload, struct appctx *appctx, void *private) |
| 281 | { |
| 282 | struct timeval deadline, curr; |
| 283 | int loop = atoi(args[3]); |
| 284 | |
| 285 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 286 | return 1; |
| 287 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 288 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 289 | gettimeofday(&curr, NULL); |
| 290 | tv_ms_add(&deadline, &curr, loop); |
| 291 | |
| 292 | while (tv_ms_cmp(&curr, &deadline) < 0) |
| 293 | gettimeofday(&curr, NULL); |
| 294 | |
| 295 | return 1; |
| 296 | } |
| 297 | |
| 298 | /* parse a "debug dev panic" command. It always returns 1, though it should never return. */ |
| 299 | static int debug_parse_cli_panic(char **args, char *payload, struct appctx *appctx, void *private) |
| 300 | { |
| 301 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 302 | return 1; |
| 303 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 304 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 305 | ha_panic(); |
| 306 | return 1; |
| 307 | } |
| 308 | |
| 309 | /* parse a "debug dev exec" command. It always returns 1. */ |
Willy Tarreau | b24ab22 | 2019-10-24 18:03:39 +0200 | [diff] [blame] | 310 | #if defined(DEBUG_DEV) |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 311 | static int debug_parse_cli_exec(char **args, char *payload, struct appctx *appctx, void *private) |
| 312 | { |
| 313 | FILE *f; |
| 314 | int arg; |
| 315 | |
| 316 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 317 | return 1; |
| 318 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 319 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 320 | chunk_reset(&trash); |
| 321 | for (arg = 3; *args[arg]; arg++) { |
| 322 | if (arg > 3) |
| 323 | chunk_strcat(&trash, " "); |
| 324 | chunk_strcat(&trash, args[arg]); |
| 325 | } |
| 326 | |
| 327 | f = popen(trash.area, "re"); |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 328 | if (!f) |
| 329 | return cli_err(appctx, "Failed to execute command.\n"); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 330 | |
| 331 | chunk_reset(&trash); |
| 332 | while (1) { |
| 333 | size_t ret = fread(trash.area + trash.data, 1, trash.size - 20 - trash.data, f); |
| 334 | if (!ret) |
| 335 | break; |
| 336 | trash.data += ret; |
| 337 | if (trash.data + 20 == trash.size) { |
| 338 | chunk_strcat(&trash, "\n[[[TRUNCATED]]]\n"); |
| 339 | break; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | fclose(f); |
| 344 | trash.area[trash.data] = 0; |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 345 | return cli_msg(appctx, LOG_INFO, trash.area); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 346 | } |
Willy Tarreau | b24ab22 | 2019-10-24 18:03:39 +0200 | [diff] [blame] | 347 | #endif |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 348 | |
| 349 | /* parse a "debug dev hex" command. It always returns 1. */ |
| 350 | static int debug_parse_cli_hex(char **args, char *payload, struct appctx *appctx, void *private) |
| 351 | { |
| 352 | unsigned long start, len; |
| 353 | |
| 354 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 355 | return 1; |
| 356 | |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 357 | if (!*args[3]) |
| 358 | return cli_err(appctx, "Missing memory address to dump from.\n"); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 359 | |
| 360 | start = strtoul(args[3], NULL, 0); |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 361 | if (!start) |
| 362 | return cli_err(appctx, "Will not dump from NULL address.\n"); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 363 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 364 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
| 365 | |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 366 | /* by default, dump ~128 till next block of 16 */ |
| 367 | len = strtoul(args[4], NULL, 0); |
| 368 | if (!len) |
| 369 | len = ((start + 128) & -16) - start; |
| 370 | |
| 371 | chunk_reset(&trash); |
Willy Tarreau | 3710105 | 2019-05-20 16:48:20 +0200 | [diff] [blame] | 372 | dump_hex(&trash, " ", (const void *)start, len, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 373 | trash.area[trash.data] = 0; |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 374 | return cli_msg(appctx, LOG_INFO, trash.area); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | /* parse a "debug dev tkill" command. It always returns 1. */ |
| 378 | static int debug_parse_cli_tkill(char **args, char *payload, struct appctx *appctx, void *private) |
| 379 | { |
| 380 | int thr = 0; |
| 381 | int sig = SIGABRT; |
| 382 | |
| 383 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 384 | return 1; |
| 385 | |
| 386 | if (*args[3]) |
| 387 | thr = atoi(args[3]); |
| 388 | |
Willy Tarreau | 9d00869 | 2019-08-09 11:21:01 +0200 | [diff] [blame] | 389 | if (thr < 0 || thr > global.nbthread) |
| 390 | return cli_err(appctx, "Thread number out of range (use 0 for current).\n"); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 391 | |
| 392 | if (*args[4]) |
| 393 | sig = atoi(args[4]); |
| 394 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 395 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 396 | if (thr) |
Willy Tarreau | fade80d | 2019-05-22 08:46:59 +0200 | [diff] [blame] | 397 | ha_tkill(thr - 1, sig); |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 398 | else |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 399 | raise(sig); |
| 400 | return 1; |
| 401 | } |
| 402 | |
Willy Tarreau | 68680bb | 2019-10-23 17:23:25 +0200 | [diff] [blame] | 403 | /* parse a "debug dev stream" command */ |
| 404 | /* |
| 405 | * debug dev stream [strm=<ptr>] [strm.f[{+-=}<flags>]] [txn.f[{+-=}<flags>]] \ |
| 406 | * [req.f[{+-=}<flags>]] [res.f[{+-=}<flags>]] \ |
| 407 | * [sif.f[{+-=<flags>]] [sib.f[{+-=<flags>]] \ |
| 408 | * [sif.s[=<state>]] [sib.s[=<state>]] |
| 409 | */ |
| 410 | static int debug_parse_cli_stream(char **args, char *payload, struct appctx *appctx, void *private) |
| 411 | { |
| 412 | struct stream *s = si_strm(appctx->owner); |
| 413 | int arg; |
| 414 | void *ptr; |
| 415 | int size; |
| 416 | const char *word, *end; |
| 417 | struct ist name; |
| 418 | char *msg = NULL; |
| 419 | char *endarg; |
| 420 | unsigned long long old, new; |
| 421 | |
| 422 | if (!cli_has_level(appctx, ACCESS_LVL_ADMIN)) |
| 423 | return 1; |
| 424 | |
| 425 | ptr = NULL; size = 0; |
| 426 | |
| 427 | if (!*args[3]) { |
| 428 | return cli_err(appctx, |
| 429 | "Usage: debug dev stream { <obj> <op> <value> | wake }*\n" |
| 430 | " <obj> = {strm | strm.f | sif.f | sif.s | sif.x | sib.f | sib.s | sib.x |\n" |
| 431 | " txn.f | req.f | req.r | req.w | res.f | res.r | res.w}\n" |
| 432 | " <op> = {'' (show) | '=' (assign) | '^' (xor) | '+' (or) | '-' (andnot)}\n" |
| 433 | " <value> = 'now' | 64-bit dec/hex integer (0x prefix supported)\n" |
| 434 | " 'wake' wakes the stream asssigned to 'strm' (default: current)\n" |
| 435 | ); |
| 436 | } |
| 437 | |
Willy Tarreau | 9b01370 | 2019-10-24 18:18:02 +0200 | [diff] [blame^] | 438 | _HA_ATOMIC_ADD(&debug_commands_issued, 1); |
Willy Tarreau | 68680bb | 2019-10-23 17:23:25 +0200 | [diff] [blame] | 439 | for (arg = 3; *args[arg]; arg++) { |
| 440 | old = 0; |
| 441 | end = word = args[arg]; |
| 442 | while (*end && *end != '=' && *end != '^' && *end != '+' && *end != '-') |
| 443 | end++; |
| 444 | name = ist2(word, end - word); |
| 445 | if (isteq(name, ist("strm"))) { |
| 446 | ptr = &s; size = sizeof(s); |
| 447 | } else if (isteq(name, ist("strm.f"))) { |
| 448 | ptr = &s->flags; size = sizeof(s->flags); |
| 449 | } else if (isteq(name, ist("txn.f"))) { |
| 450 | ptr = &s->txn->flags; size = sizeof(s->txn->flags); |
| 451 | } else if (isteq(name, ist("req.f"))) { |
| 452 | ptr = &s->req.flags; size = sizeof(s->req.flags); |
| 453 | } else if (isteq(name, ist("res.f"))) { |
| 454 | ptr = &s->res.flags; size = sizeof(s->res.flags); |
| 455 | } else if (isteq(name, ist("req.r"))) { |
| 456 | ptr = &s->req.rex; size = sizeof(s->req.rex); |
| 457 | } else if (isteq(name, ist("res.r"))) { |
| 458 | ptr = &s->res.rex; size = sizeof(s->res.rex); |
| 459 | } else if (isteq(name, ist("req.w"))) { |
| 460 | ptr = &s->req.wex; size = sizeof(s->req.wex); |
| 461 | } else if (isteq(name, ist("res.w"))) { |
| 462 | ptr = &s->res.wex; size = sizeof(s->res.wex); |
| 463 | } else if (isteq(name, ist("sif.f"))) { |
| 464 | ptr = &s->si[0].flags; size = sizeof(s->si[0].flags); |
| 465 | } else if (isteq(name, ist("sib.f"))) { |
| 466 | ptr = &s->si[1].flags; size = sizeof(s->si[1].flags); |
| 467 | } else if (isteq(name, ist("sif.x"))) { |
| 468 | ptr = &s->si[0].exp; size = sizeof(s->si[0].exp); |
| 469 | } else if (isteq(name, ist("sib.x"))) { |
| 470 | ptr = &s->si[1].exp; size = sizeof(s->si[1].exp); |
| 471 | } else if (isteq(name, ist("sif.s"))) { |
| 472 | ptr = &s->si[0].state; size = sizeof(s->si[0].state); |
| 473 | } else if (isteq(name, ist("sib.s"))) { |
| 474 | ptr = &s->si[1].state; size = sizeof(s->si[1].state); |
| 475 | } else if (isteq(name, ist("wake"))) { |
Willy Tarreau | 2b5520d | 2019-10-24 18:28:23 +0200 | [diff] [blame] | 476 | if (s && may_access(s) && may_access((void *)s + sizeof(*s) - 1)) |
Willy Tarreau | 68680bb | 2019-10-23 17:23:25 +0200 | [diff] [blame] | 477 | task_wakeup(s->task, TASK_WOKEN_TIMER|TASK_WOKEN_IO|TASK_WOKEN_MSG); |
| 478 | continue; |
| 479 | } else |
| 480 | return cli_dynerr(appctx, memprintf(&msg, "Unsupported field name: '%s'.\n", word)); |
| 481 | |
| 482 | /* read previous value */ |
Willy Tarreau | 2b5520d | 2019-10-24 18:28:23 +0200 | [diff] [blame] | 483 | if ((s || ptr == &s) && ptr && may_access(ptr) && may_access(ptr + size - 1)) { |
Willy Tarreau | 68680bb | 2019-10-23 17:23:25 +0200 | [diff] [blame] | 484 | if (size == 8) |
| 485 | old = read_u64(ptr); |
| 486 | else if (size == 4) |
| 487 | old = read_u32(ptr); |
| 488 | else if (size == 2) |
| 489 | old = read_u16(ptr); |
| 490 | else |
| 491 | old = *(const uint8_t *)ptr; |
Willy Tarreau | 2b5520d | 2019-10-24 18:28:23 +0200 | [diff] [blame] | 492 | } else { |
| 493 | memprintf(&msg, |
| 494 | "%sSkipping inaccessible pointer %p for field '%.*s'.\n", |
| 495 | msg ? msg : "", ptr, (int)(end - word), word); |
| 496 | continue; |
Willy Tarreau | 68680bb | 2019-10-23 17:23:25 +0200 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | /* parse the new value . */ |
| 500 | new = strtoll(end + 1, &endarg, 0); |
| 501 | if (end[1] && *endarg) { |
| 502 | if (strcmp(end + 1, "now") == 0) |
| 503 | new = now_ms; |
| 504 | else { |
| 505 | memprintf(&msg, |
| 506 | "%sIgnoring unparsable value '%s' for field '%.*s'.\n", |
| 507 | msg ? msg : "", end + 1, (int)(end - word), word); |
| 508 | continue; |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | switch (*end) { |
| 513 | case '\0': /* show */ |
| 514 | memprintf(&msg, "%s%.*s=%#llx ", msg ? msg : "", (int)(end - word), word, old); |
| 515 | new = old; // do not change the value |
| 516 | break; |
| 517 | |
| 518 | case '=': /* set */ |
| 519 | break; |
| 520 | |
| 521 | case '^': /* XOR */ |
| 522 | new = old ^ new; |
| 523 | break; |
| 524 | |
| 525 | case '+': /* OR */ |
| 526 | new = old | new; |
| 527 | break; |
| 528 | |
| 529 | case '-': /* AND NOT */ |
| 530 | new = old & ~new; |
| 531 | break; |
| 532 | |
| 533 | default: |
| 534 | break; |
| 535 | } |
| 536 | |
| 537 | /* write the new value */ |
Willy Tarreau | 2b5520d | 2019-10-24 18:28:23 +0200 | [diff] [blame] | 538 | if (new != old) { |
Willy Tarreau | 68680bb | 2019-10-23 17:23:25 +0200 | [diff] [blame] | 539 | if (size == 8) |
| 540 | write_u64(ptr, new); |
| 541 | else if (size == 4) |
| 542 | write_u32(ptr, new); |
| 543 | else if (size == 2) |
| 544 | write_u16(ptr, new); |
| 545 | else |
| 546 | *(uint8_t *)ptr = new; |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | if (msg && *msg) |
| 551 | return cli_dynmsg(appctx, LOG_INFO, msg); |
| 552 | return 1; |
| 553 | } |
| 554 | |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 555 | #ifndef USE_THREAD_DUMP |
| 556 | |
| 557 | /* This function dumps all threads' state to the trash. This version is the |
| 558 | * most basic one, which doesn't inspect other threads. |
| 559 | */ |
| 560 | void ha_thread_dump_all_to_trash() |
| 561 | { |
| 562 | unsigned int thr; |
| 563 | |
| 564 | for (thr = 0; thr < global.nbthread; thr++) |
| 565 | ha_thread_dump(&trash, thr, tid); |
| 566 | } |
| 567 | |
| 568 | #else /* below USE_THREAD_DUMP is set */ |
| 569 | |
Willy Tarreau | ddd8533 | 2019-05-22 06:28:54 +0200 | [diff] [blame] | 570 | /* The signal to trigger a debug dump on a thread is SIGURG. It has the benefit |
| 571 | * of not stopping gdb by default, so that issuing "show threads" in a process |
| 572 | * being debugged has no adverse effect. |
| 573 | */ |
| 574 | #define DEBUGSIG SIGURG |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 575 | |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 576 | /* ID of the thread requesting the dump */ |
| 577 | static unsigned int thread_dump_tid; |
| 578 | |
| 579 | /* points to the buffer where the dump functions should write. It must |
| 580 | * have already been initialized by the requester. Nothing is done if |
| 581 | * it's NULL. |
| 582 | */ |
| 583 | struct buffer *thread_dump_buffer = NULL; |
| 584 | |
| 585 | void ha_thread_dump_all_to_trash() |
| 586 | { |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 587 | unsigned long old; |
| 588 | |
| 589 | while (1) { |
| 590 | old = 0; |
| 591 | if (HA_ATOMIC_CAS(&threads_to_dump, &old, all_threads_mask)) |
| 592 | break; |
| 593 | ha_thread_relax(); |
| 594 | } |
| 595 | |
| 596 | thread_dump_buffer = &trash; |
| 597 | thread_dump_tid = tid; |
Willy Tarreau | fade80d | 2019-05-22 08:46:59 +0200 | [diff] [blame] | 598 | ha_tkillall(DEBUGSIG); |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /* handles DEBUGSIG to dump the state of the thread it's working on */ |
| 602 | void debug_handler(int sig, siginfo_t *si, void *arg) |
| 603 | { |
| 604 | /* There are 4 phases in the dump process: |
| 605 | * 1- wait for our turn, i.e. when all lower bits are gone. |
| 606 | * 2- perform the action if our bit is set |
| 607 | * 3- remove our bit to let the next one go, unless we're |
Willy Tarreau | c077362 | 2019-07-31 19:15:45 +0200 | [diff] [blame] | 608 | * the last one and have to put them all as a signal |
| 609 | * 4- wait out bit to re-appear, then clear it and quit. |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 610 | */ |
| 611 | |
| 612 | /* wait for all previous threads to finish first */ |
| 613 | while (threads_to_dump & (tid_bit - 1)) |
| 614 | ha_thread_relax(); |
| 615 | |
| 616 | /* dump if needed */ |
| 617 | if (threads_to_dump & tid_bit) { |
| 618 | if (thread_dump_buffer) |
| 619 | ha_thread_dump(thread_dump_buffer, tid, thread_dump_tid); |
| 620 | if ((threads_to_dump & all_threads_mask) == tid_bit) { |
| 621 | /* last one */ |
Willy Tarreau | c077362 | 2019-07-31 19:15:45 +0200 | [diff] [blame] | 622 | HA_ATOMIC_STORE(&threads_to_dump, all_threads_mask); |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 623 | thread_dump_buffer = NULL; |
| 624 | } |
| 625 | else |
| 626 | HA_ATOMIC_AND(&threads_to_dump, ~tid_bit); |
| 627 | } |
| 628 | |
| 629 | /* now wait for all others to finish dumping. The last one will set all |
Willy Tarreau | c077362 | 2019-07-31 19:15:45 +0200 | [diff] [blame] | 630 | * bits again to broadcast the leaving condition so we'll see ourselves |
| 631 | * present again. This way the threads_to_dump variable never passes to |
| 632 | * zero until all visitors have stopped waiting. |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 633 | */ |
Willy Tarreau | c077362 | 2019-07-31 19:15:45 +0200 | [diff] [blame] | 634 | while (!(threads_to_dump & tid_bit)) |
| 635 | ha_thread_relax(); |
| 636 | HA_ATOMIC_AND(&threads_to_dump, ~tid_bit); |
Willy Tarreau | e6a02fa | 2019-05-22 07:06:44 +0200 | [diff] [blame] | 637 | |
| 638 | /* mark the current thread as stuck to detect it upon next invocation |
| 639 | * if it didn't move. |
| 640 | */ |
| 641 | if (!((threads_harmless_mask|sleeping_thread_mask) & tid_bit)) |
| 642 | ti->flags |= TI_FL_STUCK; |
Willy Tarreau | c7091d8 | 2019-05-17 10:08:49 +0200 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | static int init_debug_per_thread() |
| 646 | { |
| 647 | sigset_t set; |
| 648 | |
| 649 | /* unblock the DEBUGSIG signal we intend to use */ |
| 650 | sigemptyset(&set); |
| 651 | sigaddset(&set, DEBUGSIG); |
| 652 | ha_sigmask(SIG_UNBLOCK, &set, NULL); |
| 653 | return 1; |
| 654 | } |
| 655 | |
| 656 | static int init_debug() |
| 657 | { |
| 658 | struct sigaction sa; |
| 659 | |
| 660 | sa.sa_handler = NULL; |
| 661 | sa.sa_sigaction = debug_handler; |
| 662 | sigemptyset(&sa.sa_mask); |
| 663 | sa.sa_flags = SA_SIGINFO; |
| 664 | sigaction(DEBUGSIG, &sa, NULL); |
| 665 | return 0; |
| 666 | } |
| 667 | |
| 668 | REGISTER_POST_CHECK(init_debug); |
| 669 | REGISTER_PER_THREAD_INIT(init_debug_per_thread); |
| 670 | |
| 671 | #endif /* USE_THREAD_DUMP */ |
| 672 | |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 673 | /* register cli keywords */ |
| 674 | static struct cli_kw_list cli_kws = {{ },{ |
Willy Tarreau | b24ab22 | 2019-10-24 18:03:39 +0200 | [diff] [blame] | 675 | {{ "debug", "dev", "close", NULL }, "debug dev close <fd> : close this file descriptor", debug_parse_cli_close, NULL, NULL, NULL, ACCESS_EXPERT }, |
| 676 | {{ "debug", "dev", "delay", NULL }, "debug dev delay [ms] : sleep this long", debug_parse_cli_delay, NULL, NULL, NULL, ACCESS_EXPERT }, |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 677 | #if defined(DEBUG_DEV) |
Willy Tarreau | b24ab22 | 2019-10-24 18:03:39 +0200 | [diff] [blame] | 678 | {{ "debug", "dev", "exec", NULL }, "debug dev exec [cmd] ... : show this command's output", debug_parse_cli_exec, NULL, NULL, NULL, ACCESS_EXPERT }, |
Willy Tarreau | 6bdf3e9 | 2019-05-20 14:25:05 +0200 | [diff] [blame] | 679 | #endif |
Willy Tarreau | b24ab22 | 2019-10-24 18:03:39 +0200 | [diff] [blame] | 680 | {{ "debug", "dev", "exit", NULL }, "debug dev exit [code] : immediately exit the process", debug_parse_cli_exit, NULL, NULL, NULL, ACCESS_EXPERT }, |
| 681 | {{ "debug", "dev", "hex", NULL }, "debug dev hex <addr> [len]: dump a memory area", debug_parse_cli_hex, NULL, NULL, NULL, ACCESS_EXPERT }, |
| 682 | {{ "debug", "dev", "log", NULL }, "debug dev log [msg] ... : send this msg to global logs", debug_parse_cli_log, NULL, NULL, NULL, ACCESS_EXPERT }, |
| 683 | {{ "debug", "dev", "loop", NULL }, "debug dev loop [ms] : loop this long", debug_parse_cli_loop, NULL, NULL, NULL, ACCESS_EXPERT }, |
| 684 | {{ "debug", "dev", "panic", NULL }, "debug dev panic : immediately trigger a panic", debug_parse_cli_panic, NULL, NULL, NULL, ACCESS_EXPERT }, |
| 685 | {{ "debug", "dev", "stream",NULL }, "debug dev stream ... : show/manipulate stream flags", debug_parse_cli_stream,NULL, NULL, NULL, ACCESS_EXPERT }, |
| 686 | {{ "debug", "dev", "tkill", NULL }, "debug dev tkill [thr] [sig] : send signal to thread", debug_parse_cli_tkill, NULL, NULL, NULL, ACCESS_EXPERT }, |
| 687 | {{ "show", "threads", NULL, NULL }, "show threads : show some threads debugging information", NULL, cli_io_handler_show_threads, NULL }, |
Willy Tarreau | 4e2b646 | 2019-05-16 17:44:30 +0200 | [diff] [blame] | 688 | {{},} |
| 689 | }}; |
| 690 | |
| 691 | INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); |