Ignore:
Timestamp:
Jan 11, 2017, 10:04:35 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
96bb2e4b
Parents:
b7f1fc3
git-author:
Sebastian Huber <sebastian.huber@…> (01/11/17 10:04:35)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/12/17 06:44:37)
Message:

Add and use rtems_assoc_thread_states_to_string()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libdebugger/rtems-debugger-threads.c

    rb7f1fc3 ra3730b38  
    2929
    3030#include <rtems.h>
    31 #include <rtems/score/statesimpl.h>
     31#include <rtems/assoc.h>
    3232#include <rtems/score/threadimpl.h>
    3333
     
    507507int
    508508rtems_debugger_thread_state_str(rtems_debugger_thread* thread,
    509                                 char*                  buffer,
     509                                char*                  buf,
    510510                                size_t                 size)
    511511{
    512   struct mapper {
    513     const char const* label;
    514     DB_UINT           mask;
    515   };
    516   const struct mapper map[] = {
    517     { "DORM",   STATES_DORMANT },
    518     { "LIFE",   STATES_LIFE_IS_CHANGING },
    519     { "SUSP",   STATES_SUSPENDED },
    520     { "Wbar",   STATES_WAITING_FOR_BARRIER },
    521     { "Wcvar",  STATES_WAITING_FOR_CONDITION_VARIABLE },
    522     { "Wevnt",  STATES_WAITING_FOR_EVENT },
    523     { "ISIG" ,  STATES_INTERRUPTIBLE_BY_SIGNAL },
    524     { "Wjatx",  STATES_WAITING_FOR_JOIN_AT_EXIT },
    525     { "Wjoin",  STATES_WAITING_FOR_JOIN },
    526     { "Wmsg" ,  STATES_WAITING_FOR_MESSAGE },
    527     { "Wmutex", STATES_WAITING_FOR_MUTEX },
    528     { "WRATE",  STATES_WAITING_FOR_PERIOD },
    529     { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY },
    530     { "Wrwlk",  STATES_WAITING_FOR_RWLOCK },
    531     { "Wseg",   STATES_WAITING_FOR_SEGMENT },
    532     { "Wsem",   STATES_WAITING_FOR_SEMAPHORE },
    533     { "Wsig",   STATES_WAITING_FOR_SIGNAL },
    534     { "Wfutex", STATES_WAITING_FOR_FUTEX },
    535     { "TQID",   STATES_THREAD_QUEUE_WITH_IDENTIFIER },
    536     { "Wsysev", STATES_WAITING_FOR_SYSTEM_EVENT },
    537     { "Wtime",  STATES_WAITING_FOR_TIME },
    538     { "Wwkup",  STATES_WAITING_FOR_BSD_WAKEUP },
    539     { "ZOMBI",  STATES_ZOMBIE },
    540   };
    541   DB_UINT state = thread->tcb->current_state;
    542   if (state == STATES_READY) {
    543     strcpy(buffer, "READY");
    544   }
    545   else {
    546     char*  start = buffer;
    547     size_t i;
    548     buffer[0] = '\0';
    549     buffer[size - 1] = '\0';
    550     for (i = 0; size > 0 && i < RTEMS_DEBUGGER_NUMOF(map); ++i) {
    551       if ((map[i].mask & state) != 0) {
    552         size_t l = snprintf(buffer, size - 1, "%s ", map[i].label);
    553         buffer += l;
    554         size -= l;
    555       }
    556     }
    557     if (buffer != start)
    558       *(buffer - 1) = '\0';
    559   }
     512  rtems_assoc_thread_states_to_string(thread->tcb->current_state, buf, size);
    560513  return 0;
    561514}
Note: See TracChangeset for help on using the changeset viewer.