Changeset 90a5d194 in rtems


Ignore:
Timestamp:
Sep 6, 2007, 10:51:25 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
f6e2e97
Parents:
9af457f
Message:

2007-09-06 Joel Sherrill <joel.sherrill@…>

  • libcsupport/Makefile.am, libcsupport/src/printk.c:
  • libcsupport/src/printk_plugin.c: New file. include/rtems/bspIo.h, libmisc/cpuuse/cpuusagereport.c, libmisc/cpuuse/cpuuse.h, libmisc/stackchk/check.c, libmisc/stackchk/stackchk.h: rtems/include/rtems/rtems/ratemon.h, rtems/src/ratemonreportstatistics.c: Added capability to specify your own "printf" routine to various reporting functions. This added an XXX_with_plugin as the underlying implementation for + rtems_rate_monotonic_report_statistics + rtems_stack_checker_report_usage + rtems_cpu_usage_report As demonstration, the http netdemo can now print out stack and cpu usage reports.
Location:
cpukit
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r9af457f r90a5d194  
     12007-09-06      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libcsupport/Makefile.am, libcsupport/src/printk.c:
     4        * libcsupport/src/printk_plugin.c: New file.
     5        include/rtems/bspIo.h, libmisc/cpuuse/cpuusagereport.c,
     6        libmisc/cpuuse/cpuuse.h, libmisc/stackchk/check.c,
     7        libmisc/stackchk/stackchk.h: rtems/include/rtems/rtems/ratemon.h,
     8        rtems/src/ratemonreportstatistics.c: Added capability to specify
     9        your own "printf" routine to various reporting functions.  This
     10        added an XXX_with_plugin as the underlying implementation for
     11          + rtems_rate_monotonic_report_statistics
     12          + rtems_stack_checker_report_usage
     13          + rtems_cpu_usage_report
     14        As demonstration, the http netdemo can now print out stack
     15        and cpu usage reports.
     16
    1172007-09-06      Joel Sherrill <joel.sherrill@oarcorp.com>
    218
  • cpukit/include/rtems/bspIo.h

    r9af457f r90a5d194  
    3838 */
    3939#include <stdarg.h>
    40 extern void vprintk(char *fmt, va_list ap);
    41 extern void printk(char *fmt, ...);
     40
     41extern void vprintk(const char *fmt, va_list ap);
     42extern void printk(const char *fmt, ...);
     43
     44/*
     45 *  This routine is passed into RTEMS reporting functions
     46 *  that may have their output redirected.  In particular,
     47 *  the cpu usage, period usage, and stack usage reporting
     48 *  functions use this.  If the user provides their
     49 *  own "printf plugin", then they may redirect those reports
     50 *  as they see fit.
     51 */
     52extern int printk_plugin(void *context, const char *fmt, ...);
     53 
     54/*
     55 *  Type definition for function which can be plugged in to
     56 *  certain reporting routines to redirect the output
     57 */
     58typedef int (*rtems_printk_plugin_t)(void *, const char *format, ...);
    4259
    4360#ifdef __cplusplus
  • cpukit/libcsupport/Makefile.am

    r9af457f r90a5d194  
    8585BSD_LIBC_C_FILES = src/strlcpy.c src/strlcat.c
    8686
    87 libcsupport_a_SOURCES = src/gxx_wrappers.c src/printk.c $(BSD_LIBC_C_FILES) \
    88     $(BASE_FS_C_FILES) $(MALLOC_C_FILES) $(ERROR_C_FILES) \
    89     $(ASSOCIATION_C_FILES)
     87libcsupport_a_SOURCES = src/gxx_wrappers.c src/printk.c src/printk_plugin.c \
     88    $(BSD_LIBC_C_FILES) $(BASE_FS_C_FILES) $(MALLOC_C_FILES) \
     89    $(ERROR_C_FILES) $(ASSOCIATION_C_FILES)
    9090
    9191if UNIX
  • cpukit/libcsupport/src/printk.c

    r9af457f r90a5d194  
    1 /*-------------------------------------------------------------------------+
    2 | printk.c v1.1 - PC386 BSP - 1997/08/07
    3 +--------------------------------------------------------------------------+
    4 | (C) Copyright 1997 -
    5 | - NavIST Group - Real-Time Distributed Systems and Industrial Automation
    6 |
    7 | http://pandora.ist.utl.pt
    8 |
    9 | Instituto Superior Tecnico * Lisboa * PORTUGAL
    10 +--------------------------------------------------------------------------+
    11 | Disclaimer:
    12 |
    13 | This file is provided "AS IS" without warranty of any kind, either
    14 | expressed or implied.
    15 +--------------------------------------------------------------------------+
    16 | This code is based on code by: Jose Rufino - IST
    17 |
    18 |  $Id$
    19 +--------------------------------------------------------------------------*/
     1/*
     2 *
     3 * (C) Copyright 1997 -
     4 * - NavIST Group - Real-Time Distributed Systems and Industrial Automation
     5 *
     6 * http://pandora.ist.utl.pt
     7 *
     8 * Instituto Superior Tecnico * Lisboa * PORTUGAL
     9 *
     10 * Disclaimer:
     11 *
     12 * This file is provided "AS IS" without warranty of any kind, either
     13 * expressed or implied.
     14 *--------------------------------------------------------------------------+
     15 * This code is based on code by: Jose Rufino - IST
     16 *
     17 *  $Id$
     18 *--------------------------------------------------------------------------*/
    2019
    2120#if HAVE_CONFIG_H
     
    7271+--------------------------------------------------------------------------*/
    7372void
    74 vprintk(char *fmt, va_list ap)
     73vprintk(const char *fmt, va_list ap)
    7574{
    7675  char     c, *str;
     
    139138
    140139void
    141 printk(char *fmt, ...)
     140printk(const char *fmt, ...)
    142141{
    143142  va_list  ap;      /* points to each unnamed argument in turn */
  • cpukit/libmisc/cpuuse/cpuusagereport.c

    r9af457f r90a5d194  
    2828#include <rtems/bspIo.h>
    2929
    30 #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
    31     defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
     30#if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
    3231  #include <rtems/score/timespec.h>
    3332#endif
     
    4443 */
    4544
    46 void rtems_cpu_usage_report( void )
     45void rtems_cpu_usage_report_with_plugin(
     46  void                  *context,
     47  rtems_printk_plugin_t  print
     48)
    4749{
    4850  uint32_t             i;
     
    5759    uint32_t           total_units = 0;
    5860  #endif
     61
     62  if ( !print )
     63    return;
    5964
    6065  /*
     
    8287  #endif
    8388 
    84   printk( "CPU Usage by thread\n"
     89  #if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
     90    (*print)( context, "--- CPU Usage times are seconds:microseconds ---\n" );
     91  #endif
     92  (*print)( context, "CPU Usage by thread\n"
    8593    #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
    8694          "   ID        NAME     SECONDS  PERCENT\n"
     
    105113        rtems_object_get_name( the_thread->Object.id, sizeof(name), name );
    106114 
    107         printk( "0x%08" PRIx32 "   %4s    ", the_thread->Object.id, name );
     115        (*print)( context, "0x%08" PRIx32 "   %4s    ", the_thread->Object.id, name );
    108116
    109117        #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
     
    125133           * Print the information
    126134           */
    127           printk("%2" PRId32 ".%06" PRId32 " %3" PRId32 ".%02" PRId32 "\n",
     135
     136          (*print)( context,
     137            "%2" PRId32 ":%06" PRId32 " %3" PRId32 ".%02" PRId32 "\n",
    128138            ran.tv_sec, ran.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND,
    129139            ival, fval
     
    134144          fval = ival % 100;
    135145          ival /= 100;
    136           printk(
     146          (*print)( context,
    137147            "%8" PRId32 "     %3" PRId32 ".%02" PRId32"\n",
    138148            the_thread->ticks_executed,
     
    146156
    147157  #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
    148     printk( "Time since last CPU Usage reset %" PRId32
     158    (*print)( context, "Time since last CPU Usage reset %" PRId32
    149159            ".%06" PRId32 " seconds\n",
    150160       total.tv_sec,
     
    152162    );
    153163  #else
    154     printk(
     164    (*print)( context,
    155165      "Ticks since last reset = %" PRId32 "\n",
    156166      _Watchdog_Ticks_since_boot - CPU_usage_Ticks_at_last_reset
    157167    );
    158     printk( "Total Units = %" PRId32 "\n\n", total_units );
     168    (*print)( context, "Total Units = %" PRId32 "\n\n", total_units );
    159169  #endif
    160170}
     171
     172void rtems_cpu_usage_report( void )
     173{
     174  rtems_cpu_usage_report_with_plugin( NULL, printk_plugin );
     175}
  • cpukit/libmisc/cpuuse/cpuuse.h

    r9af457f r90a5d194  
    44 *  and install the cpu usage reporting mechanism.
    55 *
    6  *  COPYRIGHT (c) 1989-2006.
     6 *  COPYRIGHT (c) 1989-2007.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
     
    1717#define __RTEMS_CPUUSE_h
    1818
     19#include <rtems/bspIo.h>
     20
    1921#ifdef __cplusplus
    2022extern "C" {
    2123#endif
     24
     25/*
     26 * rtems_cpu_usage_report_with_handler
     27 */
     28
     29void rtems_cpu_usage_report_with_plugin(
     30  void                  *context,
     31  rtems_printk_plugin_t  handler
     32);
    2233
    2334/*
  • cpukit/libmisc/stackchk/check.c

    r9af457f r90a5d194  
    352352
    353353/*
    354  *  Stack_check_Dump_threads_usage(
     354 *  Stack_check_Dump_threads_usage
    355355 *
    356356 *  Try to print out how much stack was actually used by the task.
    357357 */
     358static void                   *print_context;
     359static rtems_printk_plugin_t   print_handler;
     360
    358361void Stack_check_Dump_threads_usage(
    359362  Thread_Control *the_thread
     
    367370
    368371  if ( !the_thread )
     372    return;
     373
     374  if ( !print_handler )
    369375    return;
    370376
     
    403409  }
    404410
    405   printk("0x%08" PRIx32 "  %4s  0x%p - 0x%p   %8" PRId32 "   %8" PRId32 "\n",
     411  (*print_handler)(
     412    print_context,
     413    "0x%08" PRIx32 "  %4s  0x%p - 0x%p   %8" PRId32 "   %8" PRId32 "\n",
    406414    the_thread ? the_thread->Object.id : ~0,
    407415    name,
     
    433441 */
    434442
    435 void rtems_stack_checker_report_usage( void )
     443void rtems_stack_checker_report_usage_with_plugin(
     444  void                  *context,
     445  rtems_printk_plugin_t  print
     446)
    436447{
    437448  if (Stack_check_Initialized == 0)
    438449      return;
    439450
    440   printk("Stack usage by thread\n");
    441   printk(
     451  print_context = context;
     452  print_handler = print;
     453
     454  (*print)( context, "Stack usage by thread\n");
     455  (*print)( context,
    442456    "    ID      NAME       LOW        HIGH     AVAILABLE      USED\n"
    443457  );
     
    448462  /* dump interrupt stack info if any */
    449463  Stack_check_Dump_threads_usage((Thread_Control *) -1);
    450 }
     464
     465  print_context = NULL;
     466  print_handler = NULL;
     467
     468}
     469
     470void rtems_stack_checker_report_usage( void )
     471{
     472  rtems_stack_checker_report_usage_with_plugin( NULL, printk_plugin );
     473}
  • cpukit/libmisc/stackchk/stackchk.h

    r9af457f r90a5d194  
    1818#ifndef __RTEMS_STACK_CHECKER_h
    1919#define __RTEMS_STACK_CHECKER_h
     20
     21#include <rtems/bspIo.h>
    2022
    2123#ifdef __cplusplus
     
    4244 */
    4345void rtems_stack_checker_report_usage( void );
     46
     47/** @brief Print Stack Usage Report
     48 *
     49 *  This method prints a stack usage report for the curently executing
     50 *  task.
     51 *
     52 *  @param[in] context is the context to pass to the print handler
     53 *  @param[in] print is the print handler
     54 *
     55 *  @note It uses the CALLER's routine to print the report.
     56 */
     57void rtems_stack_checker_report_usage_with_plugin(
     58  void                  *context,
     59  rtems_printk_plugin_t  print
     60);
    4461
    4562/*************************************************************
  • cpukit/rtems/include/rtems/rtems/ratemon.h

    r9af457f r90a5d194  
    3232#define RTEMS_RATEMON_EXTERN extern
    3333#endif
     34
     35#include <rtems/bspIo.h>
    3436
    3537#ifdef __cplusplus
     
    273275 */
    274276void rtems_rate_monotonic_reset_all_statistics( void );
     277
     278/*
     279 *  rtems_rate_monotonic_report_statistics
     280 *
     281 *  DESCRIPTION:
     282 *
     283 *  This directive allows a thread to print the statistics information
     284 *  on ALL period instances which have non-zero counts using printk.
     285 */
     286void rtems_rate_monotonic_report_statistics_with_plugin(
     287  void                  *context,
     288  rtems_printk_plugin_t  print
     289);
    275290
    276291/*
  • cpukit/rtems/src/ratemonreportstatistics.c

    r9af457f r90a5d194  
    4141 *  but actually uses other services of the Manager.
    4242 */
    43 void rtems_rate_monotonic_report_statistics( void )
     43void rtems_rate_monotonic_report_statistics_with_plugin(
     44  void                  *context,
     45  rtems_printk_plugin_t  print
     46)
    4447{
    4548  rtems_status_code                      status;
     
    4952  char                                   name[5];
    5053
    51   printk( "Period information by period\n" );
     54  if ( !print )
     55    return;
     56
     57  (*print)( context, "Period information by period\n" );
    5258#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS)
    53   printk( "--- Period times are seconds:microseconds ---\n" );
     59  (*print)( context, "--- Period times are seconds:microseconds ---\n" );
    5460#endif
    5561   
    5662#if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
    57   printk( "--- CPU Usage times are seconds:microseconds ---\n" );
     63  (*print)( context, "--- CPU Usage times are seconds:microseconds ---\n" );
    5864#endif
    5965/*
     
    6773  Be sure to test the various cases.
    6874*/
    69   printk("\
     75  (*print)( context,"\
    70761234567890123456789012345678901234567890123456789012345678901234567890123456789\
    7177\n");
    72   printk( "   ID     OWNER COUNT MISSED     CPU TIME     "
     78  (*print)( context, "   ID     OWNER COUNT MISSED     CPU TIME     "
    7379       #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
    7480          "    "
     
    109115     */
    110116
    111     printk(
     117    (*print)( context,
    112118      "0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
    113119      id, name,
     
    127133         &cpu_average
    128134      );
    129       printk(
     135      (*print)( context,
    130136        "%" PRId32 ":"  NANOSECONDS_FMT "/"        /* min cpu time */
    131137        "%" PRId32 ":"  NANOSECONDS_FMT "/"        /* max cpu time */
     
    145151      ival_cpu /= 100;
    146152
    147       printk(
     153      (*print)( context,
    148154        "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 " ",
    149155        the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu
     
    163169         &wall_average
    164170      );
    165       printk(
     171      (*print)( context,
    166172        "%" PRId32 ":" PERCENT_FMT "/"        /* min wall time */
    167173        "%" PRId32 ":" PERCENT_FMT "/"        /* max wall time */
     
    180186      fval_wall = ival_wall % 100;
    181187      ival_wall /= 100;
    182       printk(
     188      (*print)( context,
    183189        "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 "\n",
    184190        the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
     
    188194  }
    189195}
     196
     197void rtems_rate_monotonic_report_statistics( void )
     198{
     199  rtems_rate_monotonic_report_statistics_with_plugin( NULL, printk_plugin );
     200}
Note: See TracChangeset for help on using the changeset viewer.