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

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

score: Add STATES_THREAD_QUEUE_WITH_IDENTIFIER

Add thread state bit to identify thread queues that are embedded in an
object with identifier.

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