MINOR: flags/task: use flag dumping for task state
The new function is task_show_state().
This commit is contained in:
parent
e9d1283cc5
commit
92a2d3c02b
@ -84,33 +84,8 @@ void show_strm_et(unsigned int f)
|
||||
|
||||
void show_task_state(unsigned int f)
|
||||
{
|
||||
printf("task->state = ");
|
||||
|
||||
if (!f) {
|
||||
printf("TASK_SLEEPING\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SHOW_FLAG(f, TASK_F_USR1);
|
||||
SHOW_FLAG(f, TASK_F_TASKLET);
|
||||
SHOW_FLAG(f, TASK_WOKEN_OTHER);
|
||||
SHOW_FLAG(f, TASK_WOKEN_RES);
|
||||
SHOW_FLAG(f, TASK_WOKEN_MSG);
|
||||
SHOW_FLAG(f, TASK_WOKEN_SIGNAL);
|
||||
SHOW_FLAG(f, TASK_WOKEN_IO);
|
||||
SHOW_FLAG(f, TASK_WOKEN_TIMER);
|
||||
SHOW_FLAG(f, TASK_WOKEN_INIT);
|
||||
SHOW_FLAG(f, TASK_HEAVY);
|
||||
SHOW_FLAG(f, TASK_IN_LIST);
|
||||
SHOW_FLAG(f, TASK_KILLED);
|
||||
SHOW_FLAG(f, TASK_SELF_WAKING);
|
||||
SHOW_FLAG(f, TASK_QUEUED);
|
||||
SHOW_FLAG(f, TASK_RUNNING);
|
||||
|
||||
if (f) {
|
||||
printf("EXTRA(0x%08x)", f);
|
||||
}
|
||||
putchar('\n');
|
||||
task_show_state(tmpbuf, sizeof(tmpbuf), " | ", f);
|
||||
printf("task->state = %s\n", tmpbuf);
|
||||
}
|
||||
|
||||
void show_txn_flags(unsigned int f)
|
||||
|
@ -27,9 +27,12 @@
|
||||
#include <import/ebtree-t.h>
|
||||
|
||||
#include <haproxy/api-t.h>
|
||||
#include <haproxy/show_flags-t.h>
|
||||
#include <haproxy/thread-t.h>
|
||||
|
||||
/* values for task->state (32 bits) */
|
||||
/* values for task->state (32 bits).
|
||||
* Please also update the task_show_state() function below in case of changes.
|
||||
*/
|
||||
#define TASK_SLEEPING 0x00000000 /* task sleeping */
|
||||
#define TASK_RUNNING 0x00000001 /* the task is currently running */
|
||||
/* unused 0x00000002 */
|
||||
@ -61,6 +64,27 @@
|
||||
#define TASK_PERSISTENT (TASK_SELF_WAKING | TASK_KILLED | \
|
||||
TASK_HEAVY | TASK_F_TASKLET | TASK_F_USR1)
|
||||
|
||||
/* This function is used to report state in debugging tools. Please reflect
|
||||
* below any single-bit flag addition above in the same order via the
|
||||
* __APPEND_FLAG macro. The new end of the buffer is returned.
|
||||
*/
|
||||
static forceinline char *task_show_state(char *buf, size_t len, const char *delim, uint flg)
|
||||
{
|
||||
#define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__)
|
||||
/* prologue */
|
||||
_(0);
|
||||
/* flags */
|
||||
_(TASK_RUNNING, _(TASK_QUEUED, _(TASK_SELF_WAKING,
|
||||
_(TASK_KILLED, _(TASK_IN_LIST, _(TASK_HEAVY, _(TASK_WOKEN_INIT,
|
||||
_(TASK_WOKEN_TIMER, _(TASK_WOKEN_IO, _(TASK_WOKEN_SIGNAL,
|
||||
_(TASK_WOKEN_MSG, _(TASK_WOKEN_RES, _(TASK_WOKEN_OTHER,
|
||||
_(TASK_F_TASKLET, _(TASK_F_USR1)))))))))))))));
|
||||
/* epilogue */
|
||||
_(~0U);
|
||||
return buf;
|
||||
#undef _
|
||||
}
|
||||
|
||||
/* these wakeup types are used to indicate how a task/tasklet was woken up, for
|
||||
* debugging purposes.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user