source: rtems/cpukit/libmisc/monitor/mon-prmisc.c @ 0c43130

5
Last change on this file since 0c43130 was d063e7b3, checked in by Sebastian Huber <sebastian.huber@…>, on 01/11/17 at 07:42:04

score: Replace STATES_DELAYING

Replace STATES_DELAYING with STATES_WAITING_FOR_TIME.

There is no need for separate timeout thread states. The
Thread_Control::Timer::header and Watchdog_Control::cpu members can be
used to figure out the kind of timeout.

  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 * Print misc stuff for the monitor dump routines
3 * Each routine returns the number of characters it output.
4 *
5 * TODO:
6 */
7
8#ifdef HAVE_CONFIG_H
9#include "config.h"
10#endif
11
12#include <rtems.h>
13#include <rtems/monitor.h>
14#include <rtems/assoc.h>
15#include <rtems/score/statesimpl.h>
16
17#include <stdio.h>
18#include <ctype.h>
19#include <inttypes.h>
20
21void
22rtems_monitor_separator(void)
23{
24    fprintf(stdout,"------------------------------------------------------------------------------\n");
25}
26
27uint32_t
28rtems_monitor_pad(
29    uint32_t    destination_column,
30    uint32_t    current_column
31)
32{
33    int pad_length;
34
35    if (destination_column <= current_column)
36        pad_length = 1;
37    else
38        pad_length = destination_column - current_column;
39
40    return fprintf(stdout,"%*s", pad_length, "");
41}
42
43int
44rtems_monitor_dump_decimal(uint32_t   num)
45{
46    return fprintf(stdout,"%4" PRId32, num);
47}
48
49int
50rtems_monitor_dump_addr(const void *addr)
51{
52    return fprintf(stdout,"%08" PRIxPTR, (intptr_t) addr);
53}
54
55int
56rtems_monitor_dump_hex(uint32_t   num)
57{
58    return fprintf(stdout,"0x%" PRIx32, num);
59}
60
61static int
62rtems_monitor_dump_assoc_bitfield(
63    const rtems_assoc_t *ap,
64    const char          *separator,
65    uint32_t             value
66  )
67{
68    uint32_t   b;
69    uint32_t   length = 0;
70    const char *name;
71
72    for (b = 1; b; b <<= 1)
73        if (b & value)
74        {
75            if (length)
76                length += fprintf(stdout,"%s", separator);
77
78            name = rtems_assoc_name_by_local(ap, b);
79
80            if (name)
81                length += fprintf(stdout,"%s", name);
82            else
83                length += fprintf(stdout,"0x%" PRIx32, b);
84        }
85
86    return length;
87}
88
89int
90rtems_monitor_dump_id(rtems_id id)
91{
92#if defined(RTEMS_USE_16_BIT_OBJECT)
93    return fprintf(stdout,"%08" PRIx16, id);
94#else
95    return fprintf(stdout,"%08" PRIx32, id);
96#endif
97}
98
99int
100rtems_monitor_dump_name(rtems_id id)
101{
102    char name_buffer[18] = "????";
103
104    rtems_object_get_name( id, sizeof(name_buffer), name_buffer );
105
106    return fprintf(stdout, "%s", name_buffer);
107}
108
109int
110rtems_monitor_dump_priority(rtems_task_priority priority)
111{
112    return fprintf(stdout,"%3" PRId32, priority);
113}
114
115#define WITH_ID(state) (STATES_THREAD_QUEUE_WITH_IDENTIFIER | state)
116
117static 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
146int
147rtems_monitor_dump_state(States_Control state)
148{
149    int   length = 0;
150
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;
158}
159
160static const rtems_assoc_t rtems_monitor_attribute_assoc[] = {
161    { "GL",  RTEMS_GLOBAL, 0 },
162    { "PR",  RTEMS_PRIORITY, 0 },
163    { "FL",  RTEMS_FLOATING_POINT, 0 },
164    { "BI",  RTEMS_BINARY_SEMAPHORE, 0 },
165    { "SB",  RTEMS_SIMPLE_BINARY_SEMAPHORE, 0 },
166    { "IN",  RTEMS_INHERIT_PRIORITY, 0 },
167    { "CE",  RTEMS_PRIORITY_CEILING, 0 },
168    { "AR",  RTEMS_BARRIER_AUTOMATIC_RELEASE, 0 },
169    { "ST",  RTEMS_SYSTEM_TASK, 0 },
170    { 0, 0, 0 },
171};
172
173int
174rtems_monitor_dump_attributes(rtems_attribute attributes)
175{
176    int   length = 0;
177
178    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
179        length += fprintf(stdout,"DEFAULT");
180
181    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
182                                                ":",
183                                                attributes);
184    return length;
185}
186
187static const rtems_assoc_t rtems_monitor_modes_assoc[] = {
188    { "nP",     RTEMS_NO_PREEMPT, 0 },
189    { "T",      RTEMS_TIMESLICE, 0 },
190    { "nA",     RTEMS_NO_ASR, 0 },
191    { 0, 0, 0 },
192};
193
194int
195rtems_monitor_dump_modes(rtems_mode modes)
196{
197    uint32_t   length = 0;
198
199    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
200        length += fprintf(stdout,"P:T:nA");
201
202    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
203                                                ":",
204                                                modes);
205    return length;
206}
207
208int
209rtems_monitor_dump_events(rtems_event_set events)
210{
211    if (events == 0)
212        return fprintf(stdout,"  NONE  ");
213
214    return fprintf(stdout,"%08" PRIx32, events);
215}
Note: See TracBrowser for help on using the repository browser.