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

5
Last change on this file since c6000d2b was c6000d2b, checked in by Sebastian Huber <sebastian.huber@…>, on 12/23/16 at 06:09:02

score: Delete STATES_WAITING_FOR_BUFFER

  • 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
115static const rtems_assoc_t rtems_monitor_state_assoc[] = {
116    { "DELAY",  STATES_DELAYING, 0 },
117    { "DORM",   STATES_DORMANT, 0 },
118    { "LIFE",   STATES_LIFE_IS_CHANGING, 0 },
119    { "SUSP",   STATES_SUSPENDED, 0 },
120    { "Wbar",   STATES_WAITING_FOR_BARRIER, 0 },
121    { "Wcvar",  STATES_WAITING_FOR_CONDITION_VARIABLE, 0 },
122    { "Wevnt",  STATES_WAITING_FOR_EVENT, 0 },
123    { "Wisig",  STATES_INTERRUPTIBLE_BY_SIGNAL, 0 },
124    { "Wjatx",  STATES_WAITING_FOR_JOIN_AT_EXIT, 0 },
125    { "Wjoin",  STATES_WAITING_FOR_JOIN, 0 },
126    { "Wmsg" ,  STATES_WAITING_FOR_MESSAGE, 0 },
127    { "Wmutex", STATES_WAITING_FOR_MUTEX, 0 },
128    { "WRATE",  STATES_WAITING_FOR_PERIOD, 0 },
129    { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY, 0 },
130    { "Wrwlk",  STATES_WAITING_FOR_RWLOCK, 0 },
131    { "Wseg",   STATES_WAITING_FOR_SEGMENT, 0 },
132    { "Wsem",   STATES_WAITING_FOR_SEMAPHORE, 0 },
133    { "Wsig",   STATES_WAITING_FOR_SIGNAL, 0 },
134    { "Wslcnd", STATES_WAITING_FOR_SYS_LOCK_CONDITION, 0 },
135    { "Wslftx", STATES_WAITING_FOR_SYS_LOCK_FUTEX, 0 },
136    { "Wslmtx", STATES_WAITING_FOR_SYS_LOCK_MUTEX, 0 },
137    { "Wslsem", STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE, 0 },
138    { "Wsysev", STATES_WAITING_FOR_SYSTEM_EVENT, 0 },
139    { "Wtime",  STATES_WAITING_FOR_TIME, 0 },
140    { "Wwkup",  STATES_WAITING_FOR_BSD_WAKEUP, 0 },
141    { "ZOMBI",  STATES_ZOMBIE, 0 },
142    { 0, 0, 0 },
143};
144
145int
146rtems_monitor_dump_state(States_Control state)
147{
148    int   length = 0;
149
150    if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
151        length += fprintf(stdout,"READY");
152
153    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc,
154                                                ":",
155                                                state);
156    return length;
157}
158
159static const rtems_assoc_t rtems_monitor_attribute_assoc[] = {
160    { "GL",  RTEMS_GLOBAL, 0 },
161    { "PR",  RTEMS_PRIORITY, 0 },
162    { "FL",  RTEMS_FLOATING_POINT, 0 },
163    { "BI",  RTEMS_BINARY_SEMAPHORE, 0 },
164    { "SB",  RTEMS_SIMPLE_BINARY_SEMAPHORE, 0 },
165    { "IN",  RTEMS_INHERIT_PRIORITY, 0 },
166    { "CE",  RTEMS_PRIORITY_CEILING, 0 },
167    { "AR",  RTEMS_BARRIER_AUTOMATIC_RELEASE, 0 },
168    { "ST",  RTEMS_SYSTEM_TASK, 0 },
169    { 0, 0, 0 },
170};
171
172int
173rtems_monitor_dump_attributes(rtems_attribute attributes)
174{
175    int   length = 0;
176
177    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
178        length += fprintf(stdout,"DEFAULT");
179
180    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
181                                                ":",
182                                                attributes);
183    return length;
184}
185
186static const rtems_assoc_t rtems_monitor_modes_assoc[] = {
187    { "nP",     RTEMS_NO_PREEMPT, 0 },
188    { "T",      RTEMS_TIMESLICE, 0 },
189    { "nA",     RTEMS_NO_ASR, 0 },
190    { 0, 0, 0 },
191};
192
193int
194rtems_monitor_dump_modes(rtems_mode modes)
195{
196    uint32_t   length = 0;
197
198    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
199        length += fprintf(stdout,"P:T:nA");
200
201    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
202                                                ":",
203                                                modes);
204    return length;
205}
206
207int
208rtems_monitor_dump_events(rtems_event_set events)
209{
210    if (events == 0)
211        return fprintf(stdout,"  NONE  ");
212
213    return fprintf(stdout,"%08" PRIx32, events);
214}
Note: See TracBrowser for help on using the repository browser.