Changeset b06e68ef in rtems for cpukit/libmisc/monitor
- Timestamp:
- 08/17/95 19:51:51 (28 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 95fbca1
- Parents:
- 3b438fa
- Location:
- cpukit/libmisc/monitor
- Files:
-
- 13 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libmisc/monitor/README
r3b438fa rb06e68ef 3 3 # 4 4 5 This is a snapshot of a work in process. It is the beginnings of a 6 debug monitor task and trap handler which is tasking aware. 5 monitor task 7 6 7 The monitor task is an optional task that knows about RTEMS 8 data structures and can print out information about them. 9 It is a work-in-progress and needs many more commands, but 10 is useful now. 11 12 The monitor works best when it is the highest priority task, 13 so all your other tasks should ideally be at some priority 14 greater than 1. 15 16 To use the monitor: 17 ------------------- 18 19 #include <rtems/monitor.h> 20 21 ... 22 23 rtems_monitor_init(0); 24 25 The parameter to rtems_monitor_init() tells the monitor whether 26 to suspend itself on startup. A value of 0 causes the monitor 27 to immediately enter command mode; a non-zero value causes the 28 monitor to suspend itself after creation and wait for explicit 29 wakeup. 30 31 32 rtems_monitor_wakeup(); 33 34 wakes up a suspended monitor and causes it to reenter command mode. 35 36 Monitor commands 37 ---------------- 38 39 The monitor prompt is 'rtems> '. 40 Can abbreviate commands to "uniquity" 41 There is a 'help' command. Here is the output from various 42 help commands: 43 44 Commands (may be abbreviated) 45 46 help -- get this message or command specific help 47 task -- show task information 48 queue -- show message queue information 49 symbol -- show entries from symbol table 50 pause -- pause monitor for a specified number of ticks 51 fatal -- invoke a fatal RTEMS error 52 53 task [id [id ...] ] 54 display information about the specified tasks. 55 Default is to display information about all tasks on this node 56 57 queue [id [id ... ] ] 58 display information about the specified message queues 59 Default is to display information about all queues on this node 60 61 symbol [ symbolname [symbolname ... ] ] 62 display value associated with specified symbol. 63 Defaults to displaying all known symbols. 64 65 pause [ticks] 66 monitor goes to "sleep" for specified ticks (default is 1) 67 monitor will resume at end of period or if explicitly awakened 68 69 fatal [status] 70 Invoke 'rtems_fatal_error_occurred' with 'status' 71 (default is RTEMS_INTERNAL_ERROR) 72 73 continue 74 put the monitor to sleep waiting for an explicit wakeup from the 75 program running. 76 77 78 Sample output from 'task' command 79 --------------------------------- 80 81 rtems> task 82 ID NAME PRIO STAT MODES EVENTS WAITID WAITARG NOTES 83 ------------------------------------------------------------------------ 84 00010001 UI1 2 READY P:T:nA NONE15: 0x40606348 85 00010002 RMON 1 READY nP NONE15: 0x40604110 86 87 'RMON' is the monitor itself, so we have 1 "user" task. 88 Its modes are P:T:nA which translate to: 89 90 preemptable 91 timesliced 92 no ASRS 93 94 It has no events. 95 It has a notepad value for notepad 15 which is 0x40606348 96 (this is the libc thread state) 97 -
cpukit/libmisc/monitor/mon-monitor.c
r3b438fa rb06e68ef 1 1 /* 2 * @(#)monitor.c 1. 6 - 95/04/242 * @(#)monitor.c 1.18 - 95/08/02 3 3 * 4 */ 5 6 /* 7 * mon-task.c 8 * 9 * Description: 10 * RTEMS monitor task 11 * 12 * 4 * 5 * RTEMS monitor main body 13 6 * 14 7 * TODO: 15 * add pause command (monitor sleeps for 'n' ticks, then wakes up) 16 * 8 * add stuff to RTEMS api 9 * rtems_get_name(id) 10 * rtems_get_type(id) 11 * rtems_build_id(node, type, num) 12 * Add a command to dump out info about an arbitrary id when 13 * types are added to id's 14 * rtems> id idnum 15 * idnum: node n, object: whatever, id: whatever 16 * allow id's to be specified as n:t:id, where 'n:t' is optional 17 * should have a separate monitor FILE stream (ala the debugger) 18 * remote request/response stuff should be cleaned up 19 * maybe we can use real rpc?? 20 * 21 * $Id$ 17 22 */ 18 23 19 24 #include <rtems.h> 20 /* #include <bsp.h> */21 22 #include "symbols.h"23 #include "monitor.h"24 25 25 26 #include <stdio.h> … … 28 29 #include <unistd.h> 29 30 30 # define STREQ(a,b) (strcmp(a,b) == 0)31 #include "monitor.h" 31 32 32 33 /* set by trap handler */ … … 35 36 extern rtems_unsigned32 debugger_trap; 36 37 37 /* our task id needs to be public so any debugger can resume us */ 38 rtems_unsigned32 rtems_monitor_task_id; 39 38 /* 39 * Various id's for the monitor 40 * They need to be public variables for access by other agencies 41 * such as debugger and remote servers' 42 */ 43 44 rtems_id rtems_monitor_task_id; 45 46 unsigned32 rtems_monitor_node; /* our node number */ 47 unsigned32 rtems_monitor_default_node; /* current default for commands */ 48 49 /* 50 * The rtems symbol table 51 */ 40 52 41 53 rtems_symbol_table_t *rtems_monitor_symbols; 42 54 43 44 #ifndef MONITOR_PROMPT 45 #define MONITOR_PROMPT "rtems> " 55 /* 56 * The top-level commands 57 */ 58 59 rtems_monitor_command_entry_t rtems_monitor_commands[] = { 60 { "--usage--", 61 "\n" 62 "RTEMS monitor\n" 63 "\n" 64 "Commands (may be abbreviated)\n" 65 "\n" 66 " help -- get this message or command specific help\n" 67 " pause -- pause monitor for a specified number of ticks\n" 68 " exit -- invoke a fatal RTEMS error\n" 69 " symbol -- show entries from symbol table\n" 70 " continue -- put monitor to sleep waiting for explicit wakeup\n" 71 " config -- show system configuration\n" 72 " itask -- list init tasks\n" 73 " mpci -- list mpci config\n" 74 " task -- show task information\n" 75 " queue -- show message queue information\n" 76 " extension -- user extensions\n" 77 " driver -- show information about named drivers\n" 78 " object -- generic object information\n" 79 " node -- specify default node for commands that take id's\n" 80 #ifdef CPU_INVOKE_DEBUGGER 81 " debugger -- invoke system debugger\n" 46 82 #endif 47 48 #define MONITOR_WAKEUP_EVENT RTEMS_EVENT_0 49 50 /* 51 * Function: rtems_monitor_init 52 * 53 * Description: 54 * Create the RTEMS monitor task 55 * 56 * Parameters: 57 * 'monitor_suspend' arg is passed as initial arg to monitor task 58 * If TRUE, monitor will suspend itself as it starts up. Otherwise 59 * it will begin its command loop. 60 * 61 * Returns: 62 * 63 * 64 * Side Effects: 65 * 66 * 67 * Notes: 68 * 69 * 70 * Deficiencies/ToDo: 71 * 72 * 73 */ 74 75 /* 76 * make_argv(cp): token-count 77 * Break up the command line in 'cp' into global argv[] and argc (return 78 * value). 79 */ 80 81 int 82 rtems_monitor_make_argv( 83 char *cp, 84 int *argc_p, 85 char **argv) 86 { 87 int argc = 0; 88 89 while ((cp = strtok(cp, " \t\n\r"))) 90 { 91 argv[argc++] = cp; 92 cp = (char *) NULL; 93 } 94 argv[argc] = (char *) NULL; /* end of argv */ 95 96 return *argc_p = argc; 97 } 98 99 void 100 rtems_monitor_init(rtems_boolean monitor_suspend) 101 { 102 rtems_status_code status; 103 104 status = rtems_task_create(rtems_build_name('R', 'M', 'O', 'N'), 105 1, 0/*stack*/, RTEMS_NO_PREEMPT | RTEMS_INTERRUPT_LEVEL(0), RTEMS_DEFAULT_ATTRIBUTES, &rtems_monitor_task_id); 106 if (status != RTEMS_SUCCESSFUL) 107 { 108 printf("could not create monitor task\n"); 109 goto done; 110 } 111 112 rtems_monitor_symbols_loadup(); 113 114 status = rtems_task_start(rtems_monitor_task_id, rtems_monitor_task, monitor_suspend); 115 if (status != RTEMS_SUCCESSFUL) 116 { 117 printf("could not start monitor!\n"); 118 goto done; 119 } 120 121 done: 122 } 83 , 84 0, 85 0, 86 (unsigned32) rtems_monitor_commands, 87 }, 88 { "config", 89 "config\n" 90 " Show the system configuration.\n", 91 0, 92 rtems_monitor_object_cmd, 93 RTEMS_OBJECT_CONFIG, 94 }, 95 { "itask", 96 "itask\n" 97 " List init tasks for the system\n", 98 0, 99 rtems_monitor_object_cmd, 100 RTEMS_OBJECT_INIT_TASK, 101 }, 102 { "mpci", 103 "mpci\n" 104 " Show the MPCI system configuration, if configured.\n", 105 0, 106 rtems_monitor_object_cmd, 107 RTEMS_OBJECT_MPCI, 108 }, 109 { "pause", 110 "pause [ticks]\n" 111 " monitor goes to \"sleep\" for specified ticks (default is 1)\n" 112 " monitor will resume at end of period or if explicitly awakened\n", 113 0, 114 rtems_monitor_pause_cmd, 115 0, 116 }, 117 { "continue", 118 "continue\n" 119 " put the monitor to sleep waiting for an explicit wakeup from the\n" 120 " program running.\n", 121 0, 122 rtems_monitor_continue_cmd, 123 0, 124 }, 125 { "go", 126 "go\n" 127 " Alias for 'continue'\n", 128 0, 129 rtems_monitor_continue_cmd, 130 0, 131 }, 132 { "node", 133 "node [ node number ]\n" 134 " Specify default node number for commands that take id's\n", 135 0, 136 rtems_monitor_node_cmd, 137 0, 138 }, 139 { "symbol", 140 "symbol [ symbolname [symbolname ... ] ]\n" 141 " display value associated with specified symbol.\n" 142 " Defaults to displaying all known symbols.\n", 143 0, 144 rtems_monitor_symbol_cmd, 145 (unsigned32) &rtems_monitor_symbols, 146 }, 147 { "extension", 148 "extension [id [id ...] ]\n" 149 " display information about specified extensions.\n" 150 " Default is to display information about all extensions on this node\n", 151 0, 152 rtems_monitor_object_cmd, 153 RTEMS_OBJECT_EXTENSION, 154 }, 155 { "task", 156 "task [id [id ...] ]\n" 157 " display information about the specified tasks.\n" 158 " Default is to display information about all tasks on this node\n", 159 0, 160 rtems_monitor_object_cmd, 161 RTEMS_OBJECT_TASK, 162 }, 163 { "queue", 164 "queue [id [id ... ] ]\n" 165 " display information about the specified message queues\n" 166 " Default is to display information about all queues on this node\n", 167 0, 168 rtems_monitor_object_cmd, 169 RTEMS_OBJECT_QUEUE, 170 }, 171 { "object", 172 "object [id [id ...] ]\n" 173 " display information about specified RTEMS objects.\n" 174 " Object id's must include 'type' information.\n" 175 " (which may normally be defaulted)\n", 176 0, 177 rtems_monitor_object_cmd, 178 RTEMS_OBJECT_INVALID, 179 }, 180 { "driver", 181 "driver [ major [ major ... ] ]\n" 182 " Display the RTEMS device driver table.\n", 183 0, 184 rtems_monitor_object_cmd, 185 RTEMS_OBJECT_DRIVER, 186 }, 187 { "dname", 188 "dname\n" 189 " Displays information about named drivers.\n", 190 0, 191 rtems_monitor_object_cmd, 192 RTEMS_OBJECT_DNAME, 193 }, 194 { "exit", 195 "exit [status]\n" 196 " Invoke 'rtems_fatal_error_occurred' with 'status'\n" 197 " (default is RTEMS_SUCCESSFUL)\n", 198 0, 199 rtems_monitor_fatal_cmd, 200 RTEMS_SUCCESSFUL, 201 }, 202 { "fatal", 203 "fatal [status]\n" 204 " 'exit' with fatal error; default error is RTEMS_TASK_EXITTED\n", 205 0, 206 rtems_monitor_fatal_cmd, 207 RTEMS_TASK_EXITTED, /* exit value */ 208 }, 209 { "quit", 210 "quit [status]\n" 211 " Alias for 'exit'\n", 212 0, 213 rtems_monitor_fatal_cmd, 214 RTEMS_SUCCESSFUL, /* exit value */ 215 }, 216 { "help", 217 "help [ command [ command ] ]\n" 218 " provide information about commands\n" 219 " Default is show basic command summary.\n", 220 0, 221 rtems_monitor_help_cmd, 222 (unsigned32) rtems_monitor_commands, 223 }, 224 #ifdef CPU_INVOKE_DEBUGGER 225 { "debugger", 226 "debugger\n" 227 " Enter the debugger, if possible.\n" 228 " A continue from the debugger will return to the monitor.\n", 229 0, 230 CPU_INVOKE_DEBUGGER, 231 0, 232 }, 233 #endif 234 { 0, 0, 0, 0, 0 }, 235 }; 236 123 237 124 238 rtems_status_code … … 128 242 rtems_status_code status; 129 243 130 status = rtems_event_receive(MONITOR_WAKEUP_EVENT, RTEMS_DEFAULT_OPTIONS, timeout, &event_set); 244 status = rtems_event_receive(MONITOR_WAKEUP_EVENT, 245 RTEMS_DEFAULT_OPTIONS, 246 timeout, 247 &event_set); 131 248 return status; 132 249 } … … 141 258 142 259 143 /* 144 * Read and break up a monitor command 145 * 146 * We have to loop on the gets call, since it will return NULL under UNIX 147 * RTEMS when we get a signal (eg: SIGALRM). 148 */ 149 150 int 151 rtems_monitor_read_command(char *command, 152 int *argc, 153 char **argv) 154 { 155 printf("%s", MONITOR_PROMPT); fflush(stdout); 156 while (gets(command) == (char *) 0) 157 ; 158 return rtems_monitor_make_argv(command, argc, argv); 159 } 160 161 void 162 rtems_monitor_task(rtems_task_argument monitor_suspend) 163 { 164 rtems_tcb *debugee = 0; 165 char command[513]; 166 rtems_context *rp; 167 rtems_context_fp *fp; 168 char *cp; 169 int argc; 170 char *argv[64]; 171 172 if ((rtems_boolean) monitor_suspend) 173 (void) rtems_monitor_suspend(RTEMS_NO_TIMEOUT); 174 175 for (;;) 260 void 261 rtems_monitor_pause_cmd( 262 int argc, 263 char **argv, 264 unsigned32 command_arg, 265 boolean verbose 266 ) 267 { 268 if (argc == 1) 269 rtems_monitor_suspend(1); 270 else 271 rtems_monitor_suspend(strtoul(argv[1], 0, 0)); 272 } 273 274 void 275 rtems_monitor_fatal_cmd( 276 int argc, 277 char **argv, 278 unsigned32 command_arg, 279 boolean verbose 280 ) 281 { 282 if (argc == 1) 283 rtems_fatal_error_occurred(command_arg); 284 else 285 rtems_fatal_error_occurred(strtoul(argv[1], 0, 0)); 286 } 287 288 void 289 rtems_monitor_continue_cmd( 290 int argc, 291 char **argv, 292 unsigned32 command_arg, 293 boolean verbose 294 ) 295 { 296 rtems_monitor_suspend(RTEMS_NO_TIMEOUT); 297 } 298 299 300 void 301 rtems_monitor_node_cmd( 302 int argc, 303 char **argv, 304 unsigned32 command_arg, 305 boolean verbose 306 ) 307 { 308 unsigned32 new_node = rtems_monitor_default_node; 309 310 switch (argc) 176 311 { 177 extern rtems_tcb * _Thread_Executing; 178 debugee = _Thread_Executing; 179 rp = &debugee->Registers; 180 fp = (rtems_context_fp *) debugee->fp_context; /* possibly 0 */ 181 182 if (0 == rtems_monitor_read_command(command, &argc, argv)) 183 continue; 184 185 if (STREQ(argv[0], "quit")) 186 rtems_monitor_suspend(RTEMS_NO_TIMEOUT); 187 else if (STREQ(argv[0], "pause")) 188 rtems_monitor_suspend(1); 189 190 #ifdef CPU_INVOKE_DEBUGGER 191 else if (STREQ(argv[0], "debug")) 192 { 193 CPU_INVOKE_DEBUGGER; 194 } 195 #endif 196 else if (STREQ(argv[0], "symbol")) 197 { 198 char *symbol; 199 char *value; 200 201 if (argc != 3) 202 { 203 printf("usage: symbol symname symvalue\n"); 204 continue; 205 } 206 207 symbol = argv[1]; 208 value = argv[2]; 209 if (symbol && value) 210 { 211 rtems_symbol_t *sp; 212 sp = rtems_symbol_create(rtems_monitor_symbols, 213 symbol, 214 (rtems_unsigned32) strtoul(value, 0, 16)); 215 if (sp) 216 printf("symbol defined is at %p\n", sp); 217 else 218 printf("could not define symbol\n"); 219 } 220 else 221 printf("parsing error\n"); 222 } 223 else 224 { 225 printf("Unrecognized command: '%s'\n", argv[0]); 226 } 312 case 1: /* no node, just set back to ours */ 313 new_node = rtems_monitor_node; 314 break; 315 316 case 2: 317 new_node = strtoul(argv[1], 0, 0); 318 break; 319 320 default: 321 printf("invalid syntax, try 'help node'\n"); 322 break; 227 323 } 228 } 324 325 if ((new_node >= 1) && (new_node <= _Configuration_MP_table->maximum_nodes)) 326 rtems_monitor_default_node = new_node; 327 } 328 229 329 230 330 /* … … 267 367 char buffer[128]; 268 368 369 if (rtems_monitor_symbols) 370 rtems_symbol_table_destroy(rtems_monitor_symbols); 371 269 372 rtems_monitor_symbols = rtems_symbol_table_create(10); 270 373 if (rtems_monitor_symbols == 0) 271 374 return; 272 375 273 fp = fdopen(8, "r"); 376 #ifdef simhppa 377 fp = fdopen(8, "r"); /* don't ask; don't tell */ 378 #else 379 fp = fopen("symbols", "r"); 380 #endif 381 274 382 if (fp == 0) 275 383 return; … … 293 401 if (sp == 0) 294 402 { 295 printf("could not define symbol \n");403 printf("could not define symbol '%s'\n", symbol); 296 404 goto done; 297 405 } … … 299 407 else 300 408 { 301 printf("parsing error \n");409 printf("parsing error on '%s'\n", buffer); 302 410 goto done; 303 411 } … … 306 414 done: 307 415 } 416 417 418 /* 419 * Main monitor command loop 420 */ 421 422 void 423 rtems_monitor_task( 424 rtems_task_argument monitor_flags 425 ) 426 { 427 rtems_tcb *debugee = 0; 428 rtems_context *rp; 429 rtems_context_fp *fp; 430 char command_buffer[513]; 431 int argc; 432 char *argv[64]; 433 boolean verbose = FALSE; 434 435 if (monitor_flags & RTEMS_MONITOR_SUSPEND) 436 (void) rtems_monitor_suspend(RTEMS_NO_TIMEOUT); 437 438 for (;;) 439 { 440 extern rtems_tcb * _Thread_Executing; 441 rtems_monitor_command_entry_t *command; 442 443 debugee = _Thread_Executing; 444 rp = &debugee->Registers; 445 fp = (rtems_context_fp *) debugee->fp_context; /* possibly 0 */ 446 447 if (0 == rtems_monitor_command_read(command_buffer, &argc, argv)) 448 continue; 449 if ((command = rtems_monitor_command_lookup(rtems_monitor_commands, 450 argc, 451 argv)) == 0) 452 continue; 453 454 command->command_function(argc, argv, command->command_arg, verbose); 455 456 fflush(stdout); 457 } 458 } 459 460 461 void 462 rtems_monitor_kill(void) 463 { 464 if (rtems_monitor_task_id) 465 rtems_task_delete(rtems_monitor_task_id); 466 rtems_monitor_task_id = 0; 467 468 rtems_monitor_server_kill(); 469 } 470 471 void 472 rtems_monitor_init( 473 unsigned32 monitor_flags 474 ) 475 { 476 rtems_status_code status; 477 478 rtems_monitor_kill(); 479 480 status = rtems_task_create(RTEMS_MONITOR_NAME, 481 1, 482 0 /* default stack */, 483 RTEMS_INTERRUPT_LEVEL(0), 484 RTEMS_DEFAULT_ATTRIBUTES, 485 &rtems_monitor_task_id); 486 if (status != RTEMS_SUCCESSFUL) 487 { 488 rtems_error(status, "could not create monitor task"); 489 goto done; 490 } 491 492 rtems_monitor_node = rtems_get_node(rtems_monitor_task_id); 493 rtems_monitor_default_node = rtems_monitor_node; 494 495 rtems_monitor_symbols_loadup(); 496 497 if (monitor_flags & RTEMS_MONITOR_GLOBAL) 498 rtems_monitor_server_init(monitor_flags); 499 500 /* 501 * Start the monitor task itself 502 */ 503 504 status = rtems_task_start(rtems_monitor_task_id, 505 rtems_monitor_task, 506 monitor_flags); 507 if (status != RTEMS_SUCCESSFUL) 508 { 509 rtems_error(status, "could not start monitor"); 510 goto done; 511 } 512 513 done: 514 } -
cpukit/libmisc/monitor/mon-symbols.c
r3b438fa rb06e68ef 1 1 /* 2 * @(#)symbols.c 1. 3 - 95/04/242 * @(#)symbols.c 1.10 - 95/08/02 3 3 * 4 * $Id$ 4 5 */ 5 6 … … 22 23 #include <string.h> 23 24 25 #include "monitor.h" 24 26 #include "symbols.h" 25 27 26 extern rtems_symbol_table_t *rtems_monitor_symbols;27 28 #ifdef RTEMS_DEBUG29 #define CHK_ADR_PTR(p) \30 do { \31 if (((p) < rtems_monitor_symbols->addresses) || \32 ((p) >= (rtems_monitor_symbols->addresses + rtems_monitor_symbols->next))) \33 { \34 printf("bad address pointer %p\n", (p)); \35 rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS); \36 } \37 } while (0)38 39 #define CHK_NAME_PTR(p) \40 do { \41 if (((p) < rtems_monitor_symbols->symbols) || \42 ((p) >= (rtems_monitor_symbols->symbols + rtems_monitor_symbols->next))) \43 { \44 printf("bad symbol pointer %p\n", (p)); \45 rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS); \46 } \47 } while (0)48 #else49 #define CHK_ADR_PTR(p)50 #define CHK_NAME_PTR(p)51 #endif52 28 53 29 rtems_symbol_table_t * … … 179 155 s2 = (rtems_symbol_t *) e2; 180 156 181 CHK_ADR_PTR(s1);182 CHK_ADR_PTR(s2);183 184 157 if (s1->value < s2->value) 185 158 return -1; … … 200 173 s1 = (rtems_symbol_t *) e1; 201 174 s2 = (rtems_symbol_t *) e2; 202 203 CHK_NAME_PTR(s1);204 CHK_NAME_PTR(s2);205 175 206 176 return strcasecmp(s1->name, s2->name); … … 252 222 rtems_unsigned32 best_distance = ~0; 253 223 rtems_unsigned32 elements; 224 225 if (table == 0) 226 table = rtems_monitor_symbols; 254 227 255 228 if ((table == 0) || (table->size == 0)) … … 301 274 rtems_symbol_t key; 302 275 276 if (table == 0) 277 table = rtems_monitor_symbols; 278 303 279 if ((table == 0) || (name == 0)) 304 280 goto done; 305 281 306 282 if (table->sorted == 0) 307 {308 283 rtems_symbol_sort(table); 309 }310 284 311 285 /* … … 326 300 } 327 301 302 void * 303 rtems_monitor_symbol_next( 304 void *object_info, 305 rtems_monitor_symbol_t *canonical, 306 rtems_id *next_id 307 ) 308 { 309 rtems_symbol_table_t *table; 310 int n = rtems_get_index(*next_id); 311 312 table = *(rtems_symbol_table_t **) object_info; 313 if (table == 0) 314 goto failed; 315 316 if (n >= table->next) 317 goto failed; 318 319 /* NOTE: symbols do not have id and name fields */ 320 321 if (table->sorted == 0) 322 rtems_symbol_sort(table); 323 324 _Thread_Disable_dispatch(); 325 326 *next_id += 1; 327 return (void *) (table->symbols + n); 328 329 failed: 330 *next_id = RTEMS_OBJECT_ID_FINAL; 331 return 0; 332 } 333 334 void 335 rtems_monitor_symbol_canonical( 336 rtems_monitor_symbol_t *canonical_symbol, 337 rtems_symbol_t *sp 338 ) 339 { 340 canonical_symbol->value = sp->value; 341 canonical_symbol->offset = 0; 342 strncpy(canonical_symbol->name, sp->name, sizeof(canonical_symbol->name)); 343 } 344 345 346 void 347 rtems_monitor_symbol_canonical_by_name( 348 rtems_monitor_symbol_t *canonical_symbol, 349 char *name 350 ) 351 { 352 rtems_symbol_t *sp; 353 354 sp = rtems_symbol_name_lookup(0, name); 355 356 canonical_symbol->value = sp ? sp->value : 0; 357 358 strncpy(canonical_symbol->name, name, sizeof(canonical_symbol->name)); 359 canonical_symbol->offset = 0; 360 } 361 362 void 363 rtems_monitor_symbol_canonical_by_value( 364 rtems_monitor_symbol_t *canonical_symbol, 365 void *value_void_p 366 ) 367 { 368 unsigned32 value = (unsigned32) value_void_p; 369 rtems_symbol_t *sp; 370 371 sp = rtems_symbol_value_lookup(0, value); 372 if (sp) 373 { 374 canonical_symbol->value = sp->value; 375 canonical_symbol->offset = value - sp->value; 376 strncpy(canonical_symbol->name, sp->name, sizeof(canonical_symbol->name)); 377 } 378 else 379 { 380 canonical_symbol->value = value; 381 canonical_symbol->offset = 0; 382 canonical_symbol->name[0] = '\0'; 383 } 384 } 385 386 387 unsigned32 388 rtems_monitor_symbol_dump( 389 rtems_monitor_symbol_t *canonical_symbol, 390 boolean verbose 391 ) 392 { 393 unsigned32 length = 0; 394 395 /* 396 * print the name if it exists AND if value is non-zero 397 * Ie: don't print some garbage symbol for address 0 398 */ 399 400 if (canonical_symbol->name[0] && (canonical_symbol->value != 0)) 401 { 402 if (canonical_symbol->offset == 0) 403 length += printf("%.*s", 404 sizeof(canonical_symbol->name), 405 canonical_symbol->name); 406 else 407 length += printf("<%.*s+0x%x>", 408 sizeof(canonical_symbol->name), 409 canonical_symbol->name, 410 canonical_symbol->offset); 411 if (verbose) 412 length += printf(" [0x%x]", canonical_symbol->value); 413 } 414 else 415 length += printf("[0x%x]", canonical_symbol->value); 416 417 return length; 418 } 419 420 421 void 422 rtems_monitor_symbol_dump_all( 423 rtems_symbol_table_t *table, 424 boolean verbose 425 ) 426 { 427 int s; 428 rtems_symbol_t *sp; 429 430 if (table == 0) 431 { 432 table = rtems_monitor_symbols; 433 if (table == 0) 434 return; 435 } 436 437 if (table->sorted == 0) 438 rtems_symbol_sort(table); 439 440 for (s = 0, sp = table->symbols; s < table->next; s++, sp++) 441 { 442 rtems_monitor_symbol_t canonical_symbol; 443 444 rtems_monitor_symbol_canonical(&canonical_symbol, sp); 445 rtems_monitor_symbol_dump(&canonical_symbol, TRUE); 446 printf("\n"); 447 } 448 } 449 450 451 /* 452 * 'symbol' command 453 */ 454 455 void 456 rtems_monitor_symbol_cmd( 457 int argc, 458 char **argv, 459 unsigned32 command_arg, 460 boolean verbose 461 ) 462 { 463 int arg; 464 rtems_symbol_table_t *table; 465 466 table = *(rtems_symbol_table_t **) command_arg; 467 if (table == 0) 468 { 469 table = rtems_monitor_symbols; 470 if (table == 0) 471 return; 472 } 473 474 /* 475 * Use object command to dump out whole symbol table 476 */ 477 if (argc == 1) 478 rtems_monitor_symbol_dump_all(table, verbose); 479 else 480 { 481 rtems_monitor_symbol_t canonical_symbol; 482 483 for (arg=1; argv[arg]; arg++) 484 { 485 rtems_monitor_symbol_canonical_by_name(&canonical_symbol, argv[arg]); 486 rtems_monitor_symbol_dump(&canonical_symbol, verbose); 487 printf("\n"); 488 } 489 } 490 } -
cpukit/libmisc/monitor/monitor.h
r3b438fa rb06e68ef 1 1 /* 2 * @(#)monitor.h 1. 2 - 95/04/242 * @(#)monitor.h 1.14 - 95/08/02 3 3 * 4 * $Id$ 4 5 */ 5 6 … … 10 11 * The RTEMS monitor task include file. 11 12 * 12 *13 *14 13 * TODO: 15 *16 14 */ 17 15 18 16 #ifndef __MONITOR_H 19 17 #define __MONITOR_H 18 19 #include "symbols.h" 20 #include <rtems/error.h> /* rtems_error() */ 20 21 21 22 #ifdef __cplusplus … … 23 24 #endif 24 25 25 void rtems_monitor_init(rtems_boolean monitor_suspend); 26 /* 27 * XXX this should be in rtems proper when type becomes part of id 28 */ 29 30 typedef enum { 31 RTEMS_OBJECT_INVALID = 0, 32 RTEMS_OBJECT_TASK = 1, 33 RTEMS_OBJECT_EXTENSION = 2, 34 RTEMS_OBJECT_QUEUE = 3, 35 RTEMS_OBJECT_SEMAPHORE = 4, 36 RTEMS_OBJECT_DRIVER = 5, 37 RTEMS_OBJECT_DNAME = 6, 38 RTEMS_OBJECT_CONFIG = 7, 39 RTEMS_OBJECT_INIT_TASK = 8, 40 RTEMS_OBJECT_MPCI = 9, 41 RTEMS_OBJECT_PARTITION = 10, 42 RTEMS_OBJECT_REGION = 11, 43 RTEMS_OBJECT_PORT = 12, 44 RTEMS_OBJECT_SYMBOL = 13, 45 } rtems_object_type_t; 46 47 /* 48 * rtems_monitor_init() flags 49 */ 50 51 #define RTEMS_MONITOR_SUSPEND 0x0001 /* suspend monitor on startup */ 52 #define RTEMS_MONITOR_GLOBAL 0x0002 /* monitor should be global */ 53 54 55 /* 56 * Public interfaces for RTEMS data structures monitor is aware of. 57 * These are only used by the monitor. 58 * 59 * NOTE: 60 * All the canonical objects that correspond to RTEMS managed "objects" 61 * must have an identical first portion with 'id' and 'name' fields. 62 * 63 * Others do not have that restriction, even tho we would like them to. 64 * This is because some of the canonical structures are almost too big 65 * for shared memory driver (eg: mpci) and we are nickel and diming it. 66 */ 67 68 /* 69 * Type of a pointer that may be a symbol 70 */ 71 72 #define MONITOR_SYMBOL_LEN 20 73 typedef struct { 74 char name[MONITOR_SYMBOL_LEN]; 75 unsigned32 value; 76 unsigned32 offset; 77 } rtems_monitor_symbol_t; 78 79 typedef struct { 80 rtems_id id; 81 rtems_name name; 82 /* end of common portion */ 83 } rtems_monitor_generic_t; 84 85 /* 86 * Task 87 */ 88 typedef struct { 89 rtems_id id; 90 rtems_name name; 91 /* end of common portion */ 92 Thread_Entry entry; 93 unsigned32 argument; 94 void *stack; 95 unsigned32 stack_size; 96 rtems_task_priority priority; 97 States_Control state; 98 rtems_event_set events; 99 rtems_mode modes; 100 rtems_attribute attributes; 101 unsigned32 notepad[RTEMS_NUMBER_NOTEPADS]; 102 rtems_id wait_id; 103 unsigned32 wait_args; 104 } rtems_monitor_task_t; 105 106 /* 107 * Init task 108 */ 109 110 typedef struct { 111 rtems_id id; /* not really an id */ 112 rtems_name name; 113 /* end of common portion */ 114 rtems_monitor_symbol_t entry; 115 unsigned32 argument; 116 unsigned32 stack_size; 117 rtems_task_priority priority; 118 rtems_mode modes; 119 rtems_attribute attributes; 120 } rtems_monitor_init_task_t; 121 122 123 /* 124 * Message queue 125 */ 126 typedef struct { 127 rtems_id id; 128 rtems_name name; 129 /* end of common portion */ 130 rtems_attribute attributes; 131 unsigned32 number_of_pending_messages; 132 unsigned32 maximum_pending_messages; 133 unsigned32 maximum_message_size; 134 } rtems_monitor_queue_t; 135 136 /* 137 * Extension 138 */ 139 typedef struct { 140 rtems_id id; 141 rtems_name name; 142 /* end of common portion */ 143 rtems_monitor_symbol_t create; 144 rtems_monitor_symbol_t start; 145 rtems_monitor_symbol_t restart; 146 rtems_monitor_symbol_t delete; 147 rtems_monitor_symbol_t tswitch; 148 rtems_monitor_symbol_t begin; 149 rtems_monitor_symbol_t exitted; 150 rtems_monitor_symbol_t fatal; 151 } rtems_monitor_extension_t; 152 153 /* 154 * Device driver 155 */ 156 157 typedef struct { 158 rtems_id id; /* not really an id (should be tho) */ 159 rtems_name name; /* ditto */ 160 /* end of common portion */ 161 rtems_monitor_symbol_t initialization; /* initialization procedure */ 162 rtems_monitor_symbol_t open; /* open request procedure */ 163 rtems_monitor_symbol_t close; /* close request procedure */ 164 rtems_monitor_symbol_t read; /* read request procedure */ 165 rtems_monitor_symbol_t write; /* write request procedure */ 166 rtems_monitor_symbol_t control; /* special functions procedure */ 167 } rtems_monitor_driver_t; 168 169 typedef struct { 170 rtems_id id; /* not used for drivers (yet) */ 171 rtems_name name; /* not used for drivers (yet) */ 172 /* end of common portion */ 173 unsigned32 major; 174 unsigned32 minor; 175 char name_string[64]; 176 } rtems_monitor_dname_t; 177 178 /* 179 * System config 180 */ 181 182 typedef struct { 183 void *work_space_start; 184 unsigned32 work_space_size; 185 unsigned32 maximum_tasks; 186 unsigned32 maximum_timers; 187 unsigned32 maximum_semaphores; 188 unsigned32 maximum_message_queues; 189 unsigned32 maximum_partitions; 190 unsigned32 maximum_regions; 191 unsigned32 maximum_ports; 192 unsigned32 maximum_periods; 193 unsigned32 maximum_extensions; 194 unsigned32 microseconds_per_tick; 195 unsigned32 ticks_per_timeslice; 196 unsigned32 number_of_initialization_tasks; 197 } rtems_monitor_config_t; 198 199 /* 200 * MPCI config 201 */ 202 203 typedef struct { 204 unsigned32 node; /* local node number */ 205 unsigned32 maximum_nodes; /* maximum # nodes in system */ 206 unsigned32 maximum_global_objects; /* maximum # global objects */ 207 unsigned32 maximum_proxies; /* maximum # proxies */ 208 209 unsigned32 default_timeout; /* in ticks */ 210 unsigned32 maximum_packet_size; 211 rtems_monitor_symbol_t initialization; 212 rtems_monitor_symbol_t get_packet; 213 rtems_monitor_symbol_t return_packet; 214 rtems_monitor_symbol_t send_packet; 215 rtems_monitor_symbol_t receive_packet; 216 } rtems_monitor_mpci_t; 217 218 /* 219 * The generic canonical information union 220 */ 221 222 typedef union { 223 rtems_monitor_generic_t generic; 224 rtems_monitor_task_t task; 225 rtems_monitor_queue_t queue; 226 rtems_monitor_extension_t extension; 227 rtems_monitor_driver_t driver; 228 rtems_monitor_dname_t dname; 229 rtems_monitor_config_t config; 230 rtems_monitor_mpci_t mpci; 231 rtems_monitor_init_task_t itask; 232 } rtems_monitor_union_t; 233 234 /* 235 * Support for talking to other monitors 236 */ 237 238 /* 239 * Names of other monitors 240 */ 241 242 #define RTEMS_MONITOR_NAME (rtems_build_name('R', 'M', 'O', 'N')) 243 #define RTEMS_MONITOR_SERVER_NAME (rtems_build_name('R', 'M', 'S', 'V')) 244 #define RTEMS_MONITOR_QUEUE_NAME (rtems_build_name('R', 'M', 'S', 'Q')) 245 #define RTEMS_MONITOR_RESPONSE_QUEUE_NAME (rtems_build_name('R', 'M', 'R', 'Q')) 246 247 #define RTEMS_MONITOR_SERVER_RESPONSE 0x0001 248 #define RTEMS_MONITOR_SERVER_CANONICAL 0x0002 249 250 typedef struct 251 { 252 unsigned32 command; 253 rtems_id return_id; 254 unsigned32 argument0; 255 unsigned32 argument1; 256 unsigned32 argument2; 257 unsigned32 argument3; 258 unsigned32 argument4; 259 unsigned32 argument5; 260 } rtems_monitor_server_request_t; 261 262 typedef struct 263 { 264 unsigned32 command; 265 unsigned32 result0; 266 unsigned32 result1; 267 rtems_monitor_union_t payload; 268 } rtems_monitor_server_response_t; 269 270 extern rtems_id rtems_monitor_task_id; 271 272 extern unsigned32 rtems_monitor_node; /* our node number */ 273 extern unsigned32 rtems_monitor_default_node; /* current default for commands */ 274 275 /* 276 * Monitor command function and table entry 277 */ 278 279 typedef struct rtems_monitor_command_entry_s rtems_monitor_command_entry_t; 280 281 typedef void ( *rtems_monitor_command_function_t )( 282 int argc, 283 char **argv, 284 unsigned32 command_arg, 285 boolean verbose 286 ); 287 288 struct rtems_monitor_command_entry_s { 289 char *command; /* command name */ 290 char *usage; /* usage string for the command */ 291 unsigned32 arguments_required; /* # of required args */ 292 rtems_monitor_command_function_t command_function; 293 294 /* Some argument for the command */ 295 unsigned32 command_arg; 296 }; 297 298 typedef void *(*rtems_monitor_object_next_fn)(void *, void *, rtems_id *); 299 typedef void (*rtems_monitor_object_canonical_fn)(void *, void *); 300 typedef void (*rtems_monitor_object_dump_header_fn)(boolean); 301 typedef void (*rtems_monitor_object_dump_fn)(void *, boolean); 302 303 typedef struct { 304 rtems_object_type_t type; 305 void *object_information; 306 int size; /* of canonical object */ 307 rtems_monitor_object_next_fn next; 308 rtems_monitor_object_canonical_fn canonical; 309 rtems_monitor_object_dump_header_fn dump_header; 310 rtems_monitor_object_dump_fn dump; 311 } rtems_monitor_object_info_t; 312 313 314 /* monitor.c */ 315 void rtems_monitor_kill(void); 316 void rtems_monitor_init(rtems_boolean); 26 317 void rtems_monitor_wakeup(void); 27 void rtems_monitor_task(rtems_task_argument monitor_suspend); 318 void rtems_monitor_pause_cmd(int, char **, unsigned32, boolean); 319 void rtems_monitor_fatal_cmd(int, char **, unsigned32, boolean); 320 void rtems_monitor_continue_cmd(int, char **, unsigned32, boolean); 321 void rtems_monitor_node_cmd(int, char **, unsigned32, boolean); 28 322 void rtems_monitor_symbols_loadup(void); 29 30 extern rtems_unsigned32 rtems_monitor_task_id; 323 void rtems_monitor_task(rtems_task_argument); 324 325 /* server.c */ 326 void rtems_monitor_server_kill(void); 327 rtems_status_code rtems_monitor_server_request(unsigned32, rtems_monitor_server_request_t *, rtems_monitor_server_response_t *); 328 void rtems_monitor_server_task(rtems_task_argument); 329 void rtems_monitor_server_init(unsigned32); 330 331 /* command.c */ 332 int rtems_monitor_make_argv(char *, int *, char **); 333 int rtems_monitor_command_read(char *, int *, char **); 334 rtems_monitor_command_entry_t *rtems_monitor_command_lookup( 335 rtems_monitor_command_entry_t * table, int argc, char **argv); 336 void rtems_monitor_command_usage(rtems_monitor_command_entry_t *, char *); 337 void rtems_monitor_help_cmd(int, char **, unsigned32, boolean); 338 339 /* prmisc.c */ 340 void rtems_monitor_separator(void); 341 unsigned32 rtems_monitor_pad(unsigned32 dest_col, unsigned32 curr_col); 342 unsigned32 rtems_monitor_dump_char(unsigned8 ch); 343 unsigned32 rtems_monitor_dump_decimal(unsigned32 num); 344 unsigned32 rtems_monitor_dump_hex(unsigned32 num); 345 unsigned32 rtems_monitor_dump_id(rtems_id id); 346 unsigned32 rtems_monitor_dump_name(rtems_name name); 347 unsigned32 rtems_monitor_dump_priority(rtems_task_priority priority); 348 unsigned32 rtems_monitor_dump_state(States_Control state); 349 unsigned32 rtems_monitor_dump_modes(rtems_mode modes); 350 unsigned32 rtems_monitor_dump_attributes(rtems_attribute attributes); 351 unsigned32 rtems_monitor_dump_events(rtems_event_set events); 352 unsigned32 rtems_monitor_dump_notepad(unsigned32 *notepad); 353 354 /* object.c */ 355 rtems_id rtems_monitor_id_fixup(rtems_id, unsigned32, rtems_object_type_t); 356 rtems_id rtems_monitor_object_canonical_get(rtems_object_type_t, rtems_id, void *, unsigned32 *size_p); 357 rtems_id rtems_monitor_object_canonical_next(rtems_monitor_object_info_t *, rtems_id, void *); 358 void *rtems_monitor_object_next(void *, void *, rtems_id, rtems_id *); 359 rtems_id rtems_monitor_object_canonical(rtems_id, void *); 360 void rtems_monitor_object_cmd(int, char **, unsigned32, boolean); 361 362 /* manager.c */ 363 void *rtems_monitor_manager_next(void *, void *, rtems_id *); 364 365 /* config.c */ 366 void rtems_monitor_config_canonical(rtems_monitor_config_t *, void *); 367 void *rtems_monitor_config_next(void *, rtems_monitor_config_t *, rtems_id *); 368 void rtems_monitor_config_dump_header(boolean); 369 void rtems_monitor_config_dump(rtems_monitor_config_t *, boolean verbose); 370 371 /* mpci.c */ 372 void rtems_monitor_mpci_canonical(rtems_monitor_mpci_t *, void *); 373 void *rtems_monitor_mpci_next(void *, rtems_monitor_mpci_t *, rtems_id *); 374 void rtems_monitor_mpci_dump_header(boolean); 375 void rtems_monitor_mpci_dump(rtems_monitor_mpci_t *, boolean verbose); 376 377 /* itask.c */ 378 void rtems_monitor_init_task_canonical(rtems_monitor_init_task_t *, void *); 379 void *rtems_monitor_init_task_next(void *, rtems_monitor_init_task_t *, rtems_id *); 380 void rtems_monitor_init_task_dump_header(boolean); 381 void rtems_monitor_init_task_dump(rtems_monitor_init_task_t *, boolean verbose); 382 383 /* extension.c */ 384 void rtems_monitor_extension_canonical(rtems_monitor_extension_t *, void *); 385 void rtems_monitor_extension_dump_header(boolean verbose); 386 void rtems_monitor_extension_dump(rtems_monitor_extension_t *, boolean); 387 388 /* task.c */ 389 void rtems_monitor_task_canonical(rtems_monitor_task_t *, void *); 390 void rtems_monitor_task_dump_header(boolean verbose); 391 void rtems_monitor_task_dump(rtems_monitor_task_t *, boolean); 392 393 /* queue.c */ 394 void rtems_monitor_queue_canonical(rtems_monitor_queue_t *, void *); 395 void rtems_monitor_queue_dump_header(boolean verbose); 396 void rtems_monitor_queue_dump(rtems_monitor_queue_t *, boolean); 397 398 /* driver.c */ 399 void *rtems_monitor_driver_next(void *, rtems_monitor_driver_t *, rtems_id *); 400 void rtems_monitor_driver_canonical(rtems_monitor_driver_t *, void *); 401 void rtems_monitor_driver_dump_header(boolean); 402 void rtems_monitor_driver_dump(rtems_monitor_driver_t *, boolean); 403 404 /* dname.c */ 405 void *rtems_monitor_dname_next(void *, rtems_monitor_dname_t *, rtems_id *); 406 void rtems_monitor_dname_canonical(rtems_monitor_dname_t *, void *); 407 void rtems_monitor_dname_dump_header(boolean); 408 void rtems_monitor_dname_dump(rtems_monitor_dname_t *, boolean); 409 410 /* symbols.c */ 411 rtems_symbol_table_t *rtems_symbol_table_create(); 412 void rtems_symbol_table_destroy(rtems_symbol_table_t *table); 413 414 rtems_symbol_t *rtems_symbol_create(rtems_symbol_table_t *, char *, unsigned32); 415 rtems_symbol_t *rtems_symbol_value_lookup(rtems_symbol_table_t *, unsigned32); 416 rtems_symbol_t *rtems_symbol_name_lookup(rtems_symbol_table_t *, char *); 417 void *rtems_monitor_symbol_next(void *object_info, rtems_monitor_symbol_t *, rtems_id *); 418 void rtems_monitor_symbol_canonical(rtems_monitor_symbol_t *, rtems_symbol_t *); 419 void rtems_monitor_symbol_canonical_by_name(rtems_monitor_symbol_t *, char *); 420 void rtems_monitor_symbol_canonical_by_value(rtems_monitor_symbol_t *, void *); 421 unsigned32 rtems_monitor_symbol_dump(rtems_monitor_symbol_t *, boolean); 422 void rtems_monitor_symbol_cmd(int, char **, unsigned32, boolean); 423 31 424 32 425 extern rtems_symbol_table_t *rtems_monitor_symbols; 426 427 #ifndef MONITOR_PROMPT 428 #define MONITOR_PROMPT "rtems" /* will have '> ' appended */ 429 #endif 430 431 #define MONITOR_WAKEUP_EVENT RTEMS_EVENT_0 432 433 434 #define STREQ(a,b) (strcmp(a,b) == 0) 435 #define STRNEQ(a,b,n) (strncmp(a,b,n) == 0) 33 436 34 437 #ifdef __cplusplus -
cpukit/libmisc/monitor/symbols.h
r3b438fa rb06e68ef 1 1 /* 2 * File: symbols.h 2 * @(#)symbols.h 1.3 - 95/06/09 3 * 4 * 5 * RTEMS monitor symbol table functions 3 6 * 4 7 * Description: … … 9 12 * TODO: 10 13 * 14 * $Id$ 11 15 */ 12 16 … … 62 66 } rtems_symbol_table_t; 63 67 64 void rtems_symbol_table_destroy(rtems_symbol_table_t *table);65 rtems_symbol_table_t *rtems_symbol_table_create();66 rtems_symbol_t *rtems_symbol_create(rtems_symbol_table_t *,67 char *, rtems_unsigned32);68 rtems_symbol_t *rtems_symbol_value_lookup(rtems_symbol_table_t *,69 rtems_unsigned32);70 rtems_symbol_t *rtems_symbol_name_lookup(rtems_symbol_table_t *,71 char *);72 73 68 #define rtems_symbol_name(sp) ((sp)->name) 74 69 #define rtems_symbol_value(sp) ((sp)->value)
Note: See TracChangeset
for help on using the changeset viewer.