File indexing completed on 2025-05-11 08:24:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifdef HAVE_CONFIG_H
0035 #include "config.h"
0036 #endif
0037
0038 #include <rtems.h>
0039 #include <rtems/monitor.h>
0040 #include <rtems/rtems/tasksdata.h>
0041 #include <rtems/score/threadimpl.h>
0042 #include <rtems/score/threadqimpl.h>
0043
0044 #include <inttypes.h>
0045 #include <stdio.h>
0046 #include <string.h> /* memcpy() */
0047
0048 static void
0049 rtems_monitor_task_wait_info(
0050 rtems_monitor_task_t *canonical_task,
0051 Thread_Control *rtems_thread
0052 )
0053 {
0054 Thread_queue_Context queue_context;
0055 const Thread_queue_Queue *queue;
0056
0057 canonical_task->wait[0] = '\0';
0058
0059 _Thread_queue_Context_initialize( &queue_context );
0060 _Thread_Wait_acquire( rtems_thread, &queue_context );
0061
0062 queue = rtems_thread->Wait.queue;
0063
0064 if ( queue != NULL ) {
0065 Objects_Id id;
0066
0067 _Thread_queue_Queue_get_name_and_id(
0068 queue,
0069 canonical_task->wait,
0070 sizeof(canonical_task->wait),
0071 &id
0072 );
0073
0074 if (id != 0) {
0075 snprintf(
0076 canonical_task->wait,
0077 sizeof(canonical_task->wait),
0078 "%08" PRIx32,
0079 id
0080 );
0081 }
0082 } else if (
0083 (rtems_thread->current_state & STATES_WAITING_FOR_BSD_WAKEUP) != 0
0084 ) {
0085 const char *wmesg;
0086
0087 wmesg = rtems_thread->Wait.return_argument_second.immutable_object;
0088
0089 if (wmesg != NULL) {
0090 strlcpy(
0091 canonical_task->wait,
0092 wmesg,
0093 sizeof(canonical_task->wait)
0094 );
0095 }
0096 }
0097
0098 _Thread_Wait_release( rtems_thread, &queue_context );
0099 }
0100
0101 void
0102 rtems_monitor_task_canonical(
0103 rtems_monitor_task_t *canonical_task,
0104 const void *thread_void
0105 )
0106 {
0107 Thread_Control *rtems_thread;
0108 RTEMS_API_Control *api;
0109 Objects_Name name;
0110
0111 rtems_thread =
0112 RTEMS_DECONST( Thread_Control *, (const Thread_Control *) thread_void );
0113
0114 api = rtems_thread->API_Extensions[ THREAD_API_RTEMS ];
0115
0116 _Objects_Name_to_string(
0117 rtems_thread->Object.name,
0118 false,
0119 canonical_task->short_name,
0120 sizeof( canonical_task->short_name )
0121 );
0122
0123 _Thread_Get_name(
0124 rtems_thread,
0125 canonical_task->long_name,
0126 sizeof( canonical_task->long_name )
0127 );
0128
0129 name.name_u32 = _Thread_Scheduler_get_home( rtems_thread )->name;
0130 _Objects_Name_to_string(
0131 name,
0132 false,
0133 canonical_task->scheduler_name,
0134 sizeof( canonical_task->scheduler_name )
0135 );
0136
0137 rtems_monitor_task_wait_info( canonical_task, rtems_thread );
0138
0139 canonical_task->state = rtems_thread->current_state;
0140 canonical_task->entry = rtems_thread->Start.Entry;
0141 canonical_task->stack = rtems_thread->Start.Initial_stack.area;
0142 canonical_task->stack_size = rtems_thread->Start.Initial_stack.size;
0143 canonical_task->priority = _Thread_Get_unmapped_priority( rtems_thread );
0144 canonical_task->events = api->Event.pending_events;
0145
0146
0147
0148 #if 0
0149 canonical_task->ticks = rtems_thread->cpu_time_executed;
0150 #else
0151 canonical_task->ticks = 0;
0152 #endif
0153
0154
0155
0156
0157 canonical_task->modes = 0;
0158 canonical_task->attributes = 0 ;
0159 }
0160
0161
0162 void
0163 rtems_monitor_task_dump_header(
0164 bool verbose RTEMS_UNUSED
0165 )
0166 {
0167 fprintf(stdout,"\
0168 ID NAME SHED PRI STATE MODES EVENTS WAITINFO\n");
0169
0170
0171 rtems_monitor_separator();
0172 }
0173
0174
0175
0176
0177 void
0178 rtems_monitor_task_dump(
0179 rtems_monitor_task_t *monitor_task,
0180 bool verbose RTEMS_UNUSED
0181 )
0182 {
0183 int length = 0;
0184
0185 length += rtems_monitor_dump_id(monitor_task->id);
0186 length += rtems_monitor_pad(9, length);
0187
0188 if (strcmp(monitor_task->short_name, monitor_task->long_name) == 0) {
0189 length += fprintf(stdout, "%s", monitor_task->short_name);
0190 } else {
0191 length += fprintf(
0192 stdout,
0193 "%s %s",
0194 monitor_task->short_name,
0195 monitor_task->long_name
0196 );
0197 }
0198
0199 length += rtems_monitor_pad(30, length);
0200 length += fprintf(stdout, "%s", monitor_task->scheduler_name);
0201 length += rtems_monitor_pad(35, length);
0202 length += rtems_monitor_dump_priority(monitor_task->priority);
0203 length += rtems_monitor_pad(39, length);
0204 length += rtems_monitor_dump_state(monitor_task->state);
0205 length += rtems_monitor_pad(46, length);
0206 length += rtems_monitor_dump_modes(monitor_task->modes);
0207 length += rtems_monitor_pad(53, length);
0208 length += rtems_monitor_dump_events(monitor_task->events);
0209 length += rtems_monitor_pad(62, length);
0210 length += fprintf(stdout, "%s", monitor_task->wait);
0211
0212 fprintf(stdout,"\n");
0213 }