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

5
Last change on this file since d063e7b3 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
RevLine 
[b06e68ef]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
[550c3df7]8#ifdef HAVE_CONFIG_H
9#include "config.h"
10#endif
11
[b06e68ef]12#include <rtems.h>
[5beb562]13#include <rtems/monitor.h>
[b06e68ef]14#include <rtems/assoc.h>
[fe6c170c]15#include <rtems/score/statesimpl.h>
[b06e68ef]16
17#include <stdio.h>
18#include <ctype.h>
[cbd849c]19#include <inttypes.h>
[b06e68ef]20
21void
22rtems_monitor_separator(void)
23{
[714f06c]24    fprintf(stdout,"------------------------------------------------------------------------------\n");
[b06e68ef]25}
26
[aed742c]27uint32_t
[b06e68ef]28rtems_monitor_pad(
[3e08d4e]29    uint32_t    destination_column,
30    uint32_t    current_column
[b06e68ef]31)
32{
33    int pad_length;
[aed742c]34
[b06e68ef]35    if (destination_column <= current_column)
36        pad_length = 1;
37    else
38        pad_length = destination_column - current_column;
39
[714f06c]40    return fprintf(stdout,"%*s", pad_length, "");
[b06e68ef]41}
42
[c182e2d]43int
[3e08d4e]44rtems_monitor_dump_decimal(uint32_t   num)
[b06e68ef]45{
[cbd849c]46    return fprintf(stdout,"%4" PRId32, num);
[b06e68ef]47}
48
[5b331cc5]49int
[1f199799]50rtems_monitor_dump_addr(const void *addr)
[5b331cc5]51{
[1f199799]52    return fprintf(stdout,"%08" PRIxPTR, (intptr_t) addr);
[5b331cc5]53}
54
[c182e2d]55int
[3e08d4e]56rtems_monitor_dump_hex(uint32_t   num)
[b06e68ef]57{
[cbd849c]58    return fprintf(stdout,"0x%" PRIx32, num);
[b06e68ef]59}
60
[6425dc5]61static int
[b06e68ef]62rtems_monitor_dump_assoc_bitfield(
[e41eaa88]63    const rtems_assoc_t *ap,
64    const char          *separator,
[6425dc5]65    uint32_t             value
[b06e68ef]66  )
[aed742c]67{
[3e08d4e]68    uint32_t   b;
69    uint32_t   length = 0;
[c64e4ed4]70    const char *name;
[b06e68ef]71
72    for (b = 1; b; b <<= 1)
73        if (b & value)
74        {
75            if (length)
[714f06c]76                length += fprintf(stdout,"%s", separator);
[b06e68ef]77
78            name = rtems_assoc_name_by_local(ap, b);
[aed742c]79
[b06e68ef]80            if (name)
[714f06c]81                length += fprintf(stdout,"%s", name);
[b06e68ef]82            else
[cbd849c]83                length += fprintf(stdout,"0x%" PRIx32, b);
[b06e68ef]84        }
[aed742c]85
[b06e68ef]86    return length;
87}
88
[c182e2d]89int
[b06e68ef]90rtems_monitor_dump_id(rtems_id id)
91{
[aac23ec7]92#if defined(RTEMS_USE_16_BIT_OBJECT)
93    return fprintf(stdout,"%08" PRIx16, id);
94#else
[cbd849c]95    return fprintf(stdout,"%08" PRIx32, id);
[aac23ec7]96#endif
[b06e68ef]97}
98
[c182e2d]99int
[bd5762d]100rtems_monitor_dump_name(rtems_id id)
[b06e68ef]101{
[babaede]102    char name_buffer[18] = "????";
[bd5762d]103
[0893220]104    rtems_object_get_name( id, sizeof(name_buffer), name_buffer );
[bd5762d]105
[8905201]106    return fprintf(stdout, "%s", name_buffer);
[b06e68ef]107}
108
[c182e2d]109int
[b06e68ef]110rtems_monitor_dump_priority(rtems_task_priority priority)
111{
[cbd849c]112    return fprintf(stdout,"%3" PRId32, priority);
[b06e68ef]113}
114
[9a448aab]115#define WITH_ID(state) (STATES_THREAD_QUEUE_WITH_IDENTIFIER | state)
116
[e41eaa88]117static const rtems_assoc_t rtems_monitor_state_assoc[] = {
[bd5b34e5]118    { "DORM",   STATES_DORMANT, 0 },
[862a0ee]119    { "LIFE",   STATES_LIFE_IS_CHANGING, 0 },
[bd5b34e5]120    { "SUSP",   STATES_SUSPENDED, 0 },
[9a448aab]121    { "Wbar",   WITH_ID(STATES_WAITING_FOR_BARRIER), 0 },
122    { "Wcvar",  WITH_ID(STATES_WAITING_FOR_CONDITION_VARIABLE), 0 },
[9780fa93]123    { "Wevnt",  STATES_WAITING_FOR_EVENT, 0 },
124    { "Wisig",  STATES_INTERRUPTIBLE_BY_SIGNAL, 0 },
[bd5b34e5]125    { "Wjatx",  STATES_WAITING_FOR_JOIN_AT_EXIT, 0 },
[f329353]126    { "Wjoin",  STATES_WAITING_FOR_JOIN, 0 },
[9a448aab]127    { "Wmsg" ,  WITH_ID(STATES_WAITING_FOR_MESSAGE), 0 },
128    { "Wmutex", WITH_ID(STATES_WAITING_FOR_MUTEX), 0 },
[bd5b34e5]129    { "WRATE",  STATES_WAITING_FOR_PERIOD, 0 },
[9780fa93]130    { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY, 0 },
[9a448aab]131    { "Wrwlk",  WITH_ID(STATES_WAITING_FOR_RWLOCK), 0 },
[9780fa93]132    { "Wseg",   STATES_WAITING_FOR_SEGMENT, 0 },
[9a448aab]133    { "Wsem",   WITH_ID(STATES_WAITING_FOR_SEMAPHORE), 0 },
[9780fa93]134    { "Wsig",   STATES_WAITING_FOR_SIGNAL, 0 },
[9a448aab]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 },
[9780fa93]139    { "Wsysev", STATES_WAITING_FOR_SYSTEM_EVENT, 0 },
140    { "Wtime",  STATES_WAITING_FOR_TIME, 0 },
141    { "Wwkup",  STATES_WAITING_FOR_BSD_WAKEUP, 0 },
[1b1be254]142    { "ZOMBI",  STATES_ZOMBIE, 0 },
[b06e68ef]143    { 0, 0, 0 },
144};
145
[c182e2d]146int
[b06e68ef]147rtems_monitor_dump_state(States_Control state)
148{
[c182e2d]149    int   length = 0;
[b06e68ef]150
151    if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
[714f06c]152        length += fprintf(stdout,"READY");
[aed742c]153
[b06e68ef]154    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc,
155                                                ":",
156                                                state);
157    return length;
158}
159
[e41eaa88]160static const rtems_assoc_t rtems_monitor_attribute_assoc[] = {
[bd5b34e5]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 },
[b06e68ef]170    { 0, 0, 0 },
171};
172
[c182e2d]173int
[b06e68ef]174rtems_monitor_dump_attributes(rtems_attribute attributes)
175{
[c182e2d]176    int   length = 0;
[b06e68ef]177
178    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
[714f06c]179        length += fprintf(stdout,"DEFAULT");
[aed742c]180
[b06e68ef]181    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
182                                                ":",
183                                                attributes);
184    return length;
185}
186
[e41eaa88]187static const rtems_assoc_t rtems_monitor_modes_assoc[] = {
[bd5b34e5]188    { "nP",     RTEMS_NO_PREEMPT, 0 },
189    { "T",      RTEMS_TIMESLICE, 0 },
190    { "nA",     RTEMS_NO_ASR, 0 },
[b06e68ef]191    { 0, 0, 0 },
192};
193
[c182e2d]194int
[b06e68ef]195rtems_monitor_dump_modes(rtems_mode modes)
196{
[3e08d4e]197    uint32_t   length = 0;
[b06e68ef]198
199    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
[714f06c]200        length += fprintf(stdout,"P:T:nA");
[aed742c]201
[b06e68ef]202    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
203                                                ":",
204                                                modes);
205    return length;
206}
207
[c182e2d]208int
[b06e68ef]209rtems_monitor_dump_events(rtems_event_set events)
210{
[e151eb1]211    if (events == 0)
[bd5762d]212        return fprintf(stdout,"  NONE  ");
[aed742c]213
[bd5762d]214    return fprintf(stdout,"%08" PRIx32, events);
[b06e68ef]215}
Note: See TracBrowser for help on using the repository browser.