Changeset 11b3ba1 in rtems


Ignore:
Timestamp:
Oct 3, 2014, 1:47:14 PM (6 years ago)
Author:
Jennifer Averett <jennifer.averett@…>
Branches:
4.11, 5, master
Children:
44da98f
Parents:
c577500
git-author:
Jennifer Averett <jennifer.averett@…> (10/03/14 13:47:14)
git-committer:
Jennifer Averett <jennifer.averett@…> (11/24/14 20:04:54)
Message:

capture01: Use capture engine print methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/libtests/capture01/init.c

    rc577500 r11b3ba1  
    2323#include <rtems.h>
    2424#include <rtems/capture-cli.h>
     25#include <rtems/captureimpl.h>
    2526#include <rtems/monitor.h>
    2627#include <rtems/shell.h>
     
    3334
    3435const char rtems_test_name[] = "CAPTURE 1";
    35 
    36 static void cwlist(void);
    37 static void ctrace(void);
    38 
    39 static void cwlist ()
    40 {
    41   rtems_capture_control_t* control = rtems_capture_get_control_list ();
    42   rtems_task_priority      ceiling = rtems_capture_watch_get_ceiling ();
    43   rtems_task_priority      floor = rtems_capture_watch_get_floor ();
    44 
    45   fprintf (stdout, "watch priority ceiling is %" PRId32 "\n", ceiling);
    46   fprintf (stdout, "watch priority floor is %" PRId32 "\n", floor);
    47   fprintf (stdout, "global watch is %s\n",
    48           rtems_capture_watch_global_on () ? "enabled" : "disabled");
    49   fprintf (stdout, "total %" PRId32 "\n", rtems_capture_control_count ());
    50 
    51   while (control)
    52   {
    53     uint32_t flags;
    54     int      f;
    55     int      fshowed;
    56     int      lf;
    57 
    58     fprintf (stdout, " ");
    59     rtems_monitor_dump_id (rtems_capture_control_id (control));
    60     fprintf (stdout, " ");
    61     rtems_monitor_dump_name (rtems_capture_control_name (control));
    62     flags = rtems_capture_control_flags (control);
    63     fprintf (stdout, " %c%c ",
    64              rtems_capture_watch_global_on () ? 'g' : '-',
    65              flags & RTEMS_CAPTURE_WATCH ? 'w' : '-');
    66     flags = rtems_capture_control_to_triggers (control);
    67     fprintf (stdout, " T:%c%c%c%c%c%c%c",
    68              flags & RTEMS_CAPTURE_SWITCH    ? 'S' : '-',
    69              flags & RTEMS_CAPTURE_CREATE ? 'C' : '-',
    70              flags & RTEMS_CAPTURE_START ? 'S' : '-',
    71              flags & RTEMS_CAPTURE_RESTART ? 'R' : '-',
    72              flags & RTEMS_CAPTURE_DELETE ? 'D' : '-',
    73              flags & RTEMS_CAPTURE_BEGIN ? 'B' : '-',
    74              flags & RTEMS_CAPTURE_EXITTED ? 'E' : '-');
    75     flags = rtems_capture_control_from_triggers (control);
    76     fprintf (stdout, " F:%c%c%c%c%c",
    77              flags & RTEMS_CAPTURE_SWITCH  ? 'S' : '-',
    78              flags & RTEMS_CAPTURE_CREATE  ? 'C' : '-',
    79              flags & RTEMS_CAPTURE_START   ? 'S' : '-',
    80              flags & RTEMS_CAPTURE_RESTART ? 'R' : '-',
    81              flags & RTEMS_CAPTURE_DELETE  ? 'D' : '-');
    82 
    83     for (f = 0, fshowed = 0, lf = 1; f < RTEMS_CAPTURE_TRIGGER_TASKS; f++)
    84     {
    85       if (rtems_capture_control_by_valid (control, f))
    86       {
    87         if (lf && ((fshowed % 3) == 0))
    88         {
    89           fprintf (stdout, "\n");
    90           lf = 0;
    91         }
    92 
    93         fprintf (stdout, "  %2i:", f);
    94         rtems_monitor_dump_name (rtems_capture_control_by_name (control, f));
    95         fprintf (stdout, "/");
    96         rtems_monitor_dump_id (rtems_capture_control_by_id (control, f));
    97         flags = rtems_capture_control_by_triggers (control, f);
    98         fprintf (stdout, ":%c%c%c%c%c",
    99                  flags & RTEMS_CAPTURE_SWITCH  ? 'S' : '-',
    100                  flags & RTEMS_CAPTURE_CREATE  ? 'C' : '-',
    101                  flags & RTEMS_CAPTURE_START   ? 'S' : '-',
    102                  flags & RTEMS_CAPTURE_RESTART ? 'R' : '-',
    103                  flags & RTEMS_CAPTURE_DELETE  ? 'D' : '-');
    104         fshowed++;
    105         lf = 1;
    106       }
    107     }
    108 
    109     if (lf)
    110       fprintf (stdout, "\n");
    111 
    112     control = rtems_capture_next_control (control);
    113   }
    114 }
    115 
    116 /*
    117  * rtems_catpure_cli_print_uptime
    118  *
    119  *  DESCRIPTION::148
    120  *
    121  *
    122  * This function prints the nanosecond uptime to stdout.
    123  */
    124 static void
    125 rtems_capture_cli_print_timestamp (uint64_t uptime)
    126 {
    127   uint32_t hours;
    128   uint32_t minutes;
    129   uint32_t seconds;
    130   uint32_t nanosecs;
    131 
    132   seconds  = uptime / 1000000000LLU;
    133   minutes  = seconds / 60;
    134   hours    = minutes / 60;
    135   minutes  = minutes % 60;
    136   seconds  = seconds % 60;
    137   nanosecs = uptime % 1000000000;
    138 
    139   fprintf (stdout, "%5lu:%02lu:%02lu.%09lu", hours, minutes, seconds, nanosecs);
    140 }
    141 static void
    142 rtems_caputre_cli_print_record_task(rtems_capture_record_t* rec)
    143 {
    144   rtems_capture_task_record_t* task_rec = (rtems_capture_task_record_t*) rec;
    145 
    146   rtems_capture_cli_print_timestamp (rec->time);
    147   fprintf (stdout, "           ");
    148   rtems_monitor_dump_id (rec->task_id);
    149    fprintf (stdout, " %c%c%c%c",
    150             (char) (task_rec->name >> 24) & 0xff,
    151             (char) (task_rec->name >> 16) & 0xff,
    152             (char) (task_rec->name >> 8) & 0xff,
    153             (char) (task_rec->name >> 0) & 0xff);
    154    fprintf (stdout, " %3" PRId32   " %3" PRId32 "\n",
    155             task_rec->start_priority,
    156             task_rec->stack_size);
    157 }
    158 
    159 static void
    160 rtems_caputure_cli_print_record_std(rtems_capture_record_t* rec, uint64_t diff)
    161 {
    162   uint32_t                     event;
    163   int                          e;
    164 
    165   event = rec->events >> RTEMS_CAPTURE_EVENT_START;
    166 
    167   for (e = RTEMS_CAPTURE_EVENT_START; e < RTEMS_CAPTURE_EVENT_END; e++)
    168   {
    169     if (event & 1)
    170     {
    171       rtems_capture_cli_print_timestamp (rec->time);
    172       fprintf (stdout, " %9" PRId64 " ", diff);
    173       rtems_monitor_dump_id (rec->task_id);
    174       fprintf(stdout, "      %3" PRId32 " %3" PRId32 " %s\n",
    175              (rec->events >> RTEMS_CAPTURE_REAL_PRIORITY_EVENT) & 0xff,
    176              (rec->events >> RTEMS_CAPTURE_CURR_PRIORITY_EVENT) & 0xff,
    177              rtems_capture_event_text (e));
    178     }
    179     event >>= 1;
    180   }
    181 }
    182 
    183 static void ctrace()
    184 {
    185   rtems_status_code       sc;
    186   bool                    csv = false;
    187   static int              dump_total = 22;
    188   int                     total;
    189   int                     count;
    190   uint32_t                read;
    191   rtems_capture_record_t* rec;
    192   uint8_t*                ptr;
    193   rtems_capture_time_t    last_t = 0;
    194 
    195   total = dump_total;
    196 
    197   while (total)
    198   {
    199     sc = rtems_capture_read (0, 0, &read, &rec);
    200 
    201     if (sc != RTEMS_SUCCESSFUL)
    202     {
    203       fprintf (stdout, "error: trace read failed: %s\n", rtems_status_text (sc));
    204       rtems_capture_flush (0);
    205       return;
    206     }
    207 
    208     /*
    209      * If we have no records then just exist. We still need to release
    210      * the reader lock.
    211      */
    212 
    213     if (read == 0)
    214     {
    215       rtems_capture_release (read);
    216       break;
    217     }
    218 
    219     count = total < read ? total : read;
    220     ptr = (uint8_t *) rec;
    221     while (count--)
    222     {
    223       rec = (rtems_capture_record_t*) ptr;
    224 
    225       if (csv)
    226         fprintf (stdout, "%08" PRIu32 ",%03" PRIu32
    227                    ",%03" PRIu32 ",%04" PRIx32 ",%" PRId64 "\n",
    228                  rec->task_id,
    229                  (rec->events >> RTEMS_CAPTURE_REAL_PRIORITY_EVENT) & 0xff,
    230                  (rec->events >> RTEMS_CAPTURE_CURR_PRIORITY_EVENT) & 0xff,
    231                  (rec->events >> RTEMS_CAPTURE_EVENT_START),
    232                  (uint64_t) rec->time);
    233       else {
    234         if ((rec->events >> RTEMS_CAPTURE_EVENT_START) == 0)
    235           rtems_caputre_cli_print_record_task( rec );
    236         else {
    237           uint64_t diff = 0;
    238           if (last_t)
    239             diff = rec->time - last_t;
    240           last_t = rec->time;
    241 
    242           rtems_caputure_cli_print_record_std( rec, diff );
    243         }
    244       }
    245       ptr += rec->size;
    246     }
    247 
    248     count = total < read ? total : read;
    249 
    250     if (count < total)
    251       total -= count;
    252     else
    253       total = 0;
    254 
    255     rtems_capture_release (count);
    256   }
    257 }
    25836
    25937rtems_task Init(
     
    27048
    27149  rtems_test_begin();
    272 
    273 #ifdef RTEMS_SMP
    274   printf("Capture Engine is broken due to recursive interrupt lock usage\n");
    275   assert(0);
    276 #endif
    27750
    27851  rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
     
    29265
    29366  sc = rtems_capture_set_trigger (
    294     0, 
    295     0, 
    296     to_name, 
    297     0, 
    298     rtems_capture_from_any, 
     67    0,
     68    0,
     69    to_name,
     70    0,
     71    rtems_capture_from_any,
    29972    rtems_capture_switch
    30073  );
    30174  ASSERT_SC(sc);
    30275
    303   cwlist();
     76  rtems_capture_print_watch_list();
    30477
    30578  sc = rtems_capture_control (true);
     
    30780
    30881  capture_test_1();
    309  
    310   ctrace();
    311   ctrace();
     82
     83  sc = rtems_capture_control (false);
     84  ASSERT_SC(sc);
     85
     86  rtems_capture_print_trace_records ( 22, false );
     87  rtems_capture_print_trace_records ( 22, false );
    31288
    31389  rtems_test_end();
Note: See TracChangeset for help on using the changeset viewer.