Changeset a3730b38 in rtems


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()

Location:
cpukit
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/Makefile.am

    rb7f1fc3 ra3730b38  
    4040    src/assocremotebylocal.c src/assocremotebyname.c
    4141ASSOCIATION_C_FILES += src/assoc32tostring.c
     42ASSOCIATION_C_FILES += src/assocthreadstatestostring.c
    4243
    4344BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \
  • cpukit/libcsupport/include/rtems/assoc.h

    rb7f1fc3 ra3730b38  
    182182);
    183183
     184/**
     185 * @brief Converts the specified thread states into a text representation.
     186 *
     187 * @param[in] states The thread states to convert.
     188 * @param[in] buffer The buffer for the text representation.
     189 * @param[in] buffer_size The buffer size in characters.
     190 *
     191 * @retval The length of the text representation.  May be greater than the
     192 * buffer size if truncation occurred.
     193 */
     194size_t rtems_assoc_thread_states_to_string(
     195  uint32_t  states,
     196  char     *buffer,
     197  size_t    buffer_size
     198);
     199
    184200#ifdef __cplusplus
    185201}
  • 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}
  • cpukit/libmisc/monitor/mon-prmisc.c

    rb7f1fc3 ra3730b38  
    1313#include <rtems/monitor.h>
    1414#include <rtems/assoc.h>
    15 #include <rtems/score/statesimpl.h>
    1615
    1716#include <stdio.h>
     
    113112}
    114113
    115 #define WITH_ID(state) (STATES_THREAD_QUEUE_WITH_IDENTIFIER | state)
    116 
    117 static const rtems_assoc_t rtems_monitor_state_assoc[] = {
    118     { "DORM",   STATES_DORMANT, 0 },
    119     { "LIFE",   STATES_LIFE_IS_CHANGING, 0 },
    120     { "SUSP",   STATES_SUSPENDED, 0 },
    121     { "Wbar",   WITH_ID(STATES_WAITING_FOR_BARRIER), 0 },
    122     { "Wcvar",  WITH_ID(STATES_WAITING_FOR_CONDITION_VARIABLE), 0 },
    123     { "Wevnt",  STATES_WAITING_FOR_EVENT, 0 },
    124     { "Wisig",  STATES_INTERRUPTIBLE_BY_SIGNAL, 0 },
    125     { "Wjatx",  STATES_WAITING_FOR_JOIN_AT_EXIT, 0 },
    126     { "Wjoin",  STATES_WAITING_FOR_JOIN, 0 },
    127     { "Wmsg" ,  WITH_ID(STATES_WAITING_FOR_MESSAGE), 0 },
    128     { "Wmutex", WITH_ID(STATES_WAITING_FOR_MUTEX), 0 },
    129     { "WRATE",  STATES_WAITING_FOR_PERIOD, 0 },
    130     { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY, 0 },
    131     { "Wrwlk",  WITH_ID(STATES_WAITING_FOR_RWLOCK), 0 },
    132     { "Wseg",   STATES_WAITING_FOR_SEGMENT, 0 },
    133     { "Wsem",   WITH_ID(STATES_WAITING_FOR_SEMAPHORE), 0 },
    134     { "Wsig",   STATES_WAITING_FOR_SIGNAL, 0 },
    135     { "Wcvar",  STATES_WAITING_FOR_CONDITION_VARIABLE, 0 },
    136     { "Wfutex", STATES_WAITING_FOR_FUTEX, 0 },
    137     { "Wmutex", STATES_WAITING_FOR_MUTEX, 0 },
    138     { "Wsem",   STATES_WAITING_FOR_SEMAPHORE, 0 },
    139     { "Wsysev", STATES_WAITING_FOR_SYSTEM_EVENT, 0 },
    140     { "Wtime",  STATES_WAITING_FOR_TIME, 0 },
    141     { "Wwkup",  STATES_WAITING_FOR_BSD_WAKEUP, 0 },
    142     { "ZOMBI",  STATES_ZOMBIE, 0 },
    143     { 0, 0, 0 },
    144 };
    145 
    146114int
    147115rtems_monitor_dump_state(States_Control state)
    148116{
    149     int   length = 0;
     117    char buf[16];
    150118
    151     if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
    152         length += fprintf(stdout,"READY");
    153 
    154     length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc,
    155                                                 ":",
    156                                                 state);
    157     return length;
     119    rtems_assoc_thread_states_to_string(state, buf, sizeof(buf));
     120    return fprintf(stdout, "%s", buf);
    158121}
    159122
Note: See TracChangeset for help on using the changeset viewer.