[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 | |
---|
| 21 | void |
---|
| 22 | rtems_monitor_separator(void) |
---|
| 23 | { |
---|
[714f06c] | 24 | fprintf(stdout,"------------------------------------------------------------------------------\n"); |
---|
[b06e68ef] | 25 | } |
---|
| 26 | |
---|
[aed742c] | 27 | uint32_t |
---|
[b06e68ef] | 28 | rtems_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] | 43 | int |
---|
[3e08d4e] | 44 | rtems_monitor_dump_decimal(uint32_t num) |
---|
[b06e68ef] | 45 | { |
---|
[cbd849c] | 46 | return fprintf(stdout,"%4" PRId32, num); |
---|
[b06e68ef] | 47 | } |
---|
| 48 | |
---|
[5b331cc5] | 49 | int |
---|
[1f199799] | 50 | rtems_monitor_dump_addr(const void *addr) |
---|
[5b331cc5] | 51 | { |
---|
[1f199799] | 52 | return fprintf(stdout,"%08" PRIxPTR, (intptr_t) addr); |
---|
[5b331cc5] | 53 | } |
---|
| 54 | |
---|
[c182e2d] | 55 | int |
---|
[3e08d4e] | 56 | rtems_monitor_dump_hex(uint32_t num) |
---|
[b06e68ef] | 57 | { |
---|
[cbd849c] | 58 | return fprintf(stdout,"0x%" PRIx32, num); |
---|
[b06e68ef] | 59 | } |
---|
| 60 | |
---|
[6425dc5] | 61 | static int |
---|
[b06e68ef] | 62 | rtems_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] | 89 | int |
---|
[b06e68ef] | 90 | rtems_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] | 99 | int |
---|
[bd5762d] | 100 | rtems_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] | 109 | int |
---|
[b06e68ef] | 110 | rtems_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] | 117 | static const rtems_assoc_t rtems_monitor_state_assoc[] = { |
---|
[9780fa93] | 118 | { "DELAY", STATES_DELAYING, 0 }, |
---|
[bd5b34e5] | 119 | { "DORM", STATES_DORMANT, 0 }, |
---|
[862a0ee] | 120 | { "LIFE", STATES_LIFE_IS_CHANGING, 0 }, |
---|
[bd5b34e5] | 121 | { "SUSP", STATES_SUSPENDED, 0 }, |
---|
[9a448aab] | 122 | { "Wbar", WITH_ID(STATES_WAITING_FOR_BARRIER), 0 }, |
---|
| 123 | { "Wcvar", WITH_ID(STATES_WAITING_FOR_CONDITION_VARIABLE), 0 }, |
---|
[9780fa93] | 124 | { "Wevnt", STATES_WAITING_FOR_EVENT, 0 }, |
---|
| 125 | { "Wisig", STATES_INTERRUPTIBLE_BY_SIGNAL, 0 }, |
---|
[bd5b34e5] | 126 | { "Wjatx", STATES_WAITING_FOR_JOIN_AT_EXIT, 0 }, |
---|
[f329353] | 127 | { "Wjoin", STATES_WAITING_FOR_JOIN, 0 }, |
---|
[9a448aab] | 128 | { "Wmsg" , WITH_ID(STATES_WAITING_FOR_MESSAGE), 0 }, |
---|
| 129 | { "Wmutex", WITH_ID(STATES_WAITING_FOR_MUTEX), 0 }, |
---|
[bd5b34e5] | 130 | { "WRATE", STATES_WAITING_FOR_PERIOD, 0 }, |
---|
[9780fa93] | 131 | { "Wrpc", STATES_WAITING_FOR_RPC_REPLY, 0 }, |
---|
[9a448aab] | 132 | { "Wrwlk", WITH_ID(STATES_WAITING_FOR_RWLOCK), 0 }, |
---|
[9780fa93] | 133 | { "Wseg", STATES_WAITING_FOR_SEGMENT, 0 }, |
---|
[9a448aab] | 134 | { "Wsem", WITH_ID(STATES_WAITING_FOR_SEMAPHORE), 0 }, |
---|
[9780fa93] | 135 | { "Wsig", STATES_WAITING_FOR_SIGNAL, 0 }, |
---|
[9a448aab] | 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 }, |
---|
[9780fa93] | 140 | { "Wsysev", STATES_WAITING_FOR_SYSTEM_EVENT, 0 }, |
---|
| 141 | { "Wtime", STATES_WAITING_FOR_TIME, 0 }, |
---|
| 142 | { "Wwkup", STATES_WAITING_FOR_BSD_WAKEUP, 0 }, |
---|
[1b1be254] | 143 | { "ZOMBI", STATES_ZOMBIE, 0 }, |
---|
[b06e68ef] | 144 | { 0, 0, 0 }, |
---|
| 145 | }; |
---|
| 146 | |
---|
[c182e2d] | 147 | int |
---|
[b06e68ef] | 148 | rtems_monitor_dump_state(States_Control state) |
---|
| 149 | { |
---|
[c182e2d] | 150 | int length = 0; |
---|
[b06e68ef] | 151 | |
---|
| 152 | if (state == STATES_READY) /* assoc doesn't deal with this as it is 0 */ |
---|
[714f06c] | 153 | length += fprintf(stdout,"READY"); |
---|
[aed742c] | 154 | |
---|
[b06e68ef] | 155 | length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc, |
---|
| 156 | ":", |
---|
| 157 | state); |
---|
| 158 | return length; |
---|
| 159 | } |
---|
| 160 | |
---|
[e41eaa88] | 161 | static const rtems_assoc_t rtems_monitor_attribute_assoc[] = { |
---|
[bd5b34e5] | 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 }, |
---|
[b06e68ef] | 171 | { 0, 0, 0 }, |
---|
| 172 | }; |
---|
| 173 | |
---|
[c182e2d] | 174 | int |
---|
[b06e68ef] | 175 | rtems_monitor_dump_attributes(rtems_attribute attributes) |
---|
| 176 | { |
---|
[c182e2d] | 177 | int length = 0; |
---|
[b06e68ef] | 178 | |
---|
| 179 | if (attributes == RTEMS_DEFAULT_ATTRIBUTES) /* value is 0 */ |
---|
[714f06c] | 180 | length += fprintf(stdout,"DEFAULT"); |
---|
[aed742c] | 181 | |
---|
[b06e68ef] | 182 | length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc, |
---|
| 183 | ":", |
---|
| 184 | attributes); |
---|
| 185 | return length; |
---|
| 186 | } |
---|
| 187 | |
---|
[e41eaa88] | 188 | static const rtems_assoc_t rtems_monitor_modes_assoc[] = { |
---|
[bd5b34e5] | 189 | { "nP", RTEMS_NO_PREEMPT, 0 }, |
---|
| 190 | { "T", RTEMS_TIMESLICE, 0 }, |
---|
| 191 | { "nA", RTEMS_NO_ASR, 0 }, |
---|
[b06e68ef] | 192 | { 0, 0, 0 }, |
---|
| 193 | }; |
---|
| 194 | |
---|
[c182e2d] | 195 | int |
---|
[b06e68ef] | 196 | rtems_monitor_dump_modes(rtems_mode modes) |
---|
| 197 | { |
---|
[3e08d4e] | 198 | uint32_t length = 0; |
---|
[b06e68ef] | 199 | |
---|
| 200 | if (modes == RTEMS_DEFAULT_MODES) /* value is 0 */ |
---|
[714f06c] | 201 | length += fprintf(stdout,"P:T:nA"); |
---|
[aed742c] | 202 | |
---|
[b06e68ef] | 203 | length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc, |
---|
| 204 | ":", |
---|
| 205 | modes); |
---|
| 206 | return length; |
---|
| 207 | } |
---|
| 208 | |
---|
[c182e2d] | 209 | int |
---|
[b06e68ef] | 210 | rtems_monitor_dump_events(rtems_event_set events) |
---|
| 211 | { |
---|
[e151eb1] | 212 | if (events == 0) |
---|
[bd5762d] | 213 | return fprintf(stdout," NONE "); |
---|
[aed742c] | 214 | |
---|
[bd5762d] | 215 | return fprintf(stdout,"%08" PRIx32, events); |
---|
[b06e68ef] | 216 | } |
---|