Changeset 1cb2e748 in rtems


Ignore:
Timestamp:
Jun 20, 2018, 9:29:46 AM (12 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
c47ad8e
Parents:
8ff5916c
git-author:
Sebastian Huber <sebastian.huber@…> (06/20/18 09:29:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/20/18 10:07:07)
Message:

stackchk: Refactor Stack_check_Dump_threads_usage

Update #3459.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/stackchk/check.c

    r8ff5916c r1cb2e748  
    138138    ((_the_stack)->size - PATTERN_SIZE_BYTES)
    139139
    140 #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
    141   /*
    142    *  Did RTEMS allocate the interrupt stack? If so, put it in
    143    *  Stack_Control format.
    144    */
    145   Stack_Control Stack_check_Interrupt_stack;
    146 #endif
     140static Stack_Control Stack_check_Interrupt_stack;
    147141
    148142/*
     
    338332}
    339333
    340 /*
    341  *  Stack_check_Dump_threads_usage
    342  *
    343  *  Try to print out how much stack was actually used by the task.
    344  */
    345 static bool Stack_check_Dump_threads_usage(
    346   Thread_Control *the_thread,
    347   void           *arg
    348 )
    349 {
    350   uint32_t             size, used;
    351   void                *low;
    352   void                *high_water_mark;
    353   void                *current;
    354   Stack_Control       *stack;
    355   char                 name[ 22 ];
    356   const rtems_printer *printer;
    357   uint32_t             id;
    358 
    359   printer = arg;
    360 
    361   /*
    362    *  Obtain interrupt stack information
    363    */
    364   #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
    365     if (the_thread == (Thread_Control *) -1) {
    366       if (!Stack_check_Interrupt_stack.area)
    367         return false;
    368       stack = &Stack_check_Interrupt_stack;
    369       the_thread = 0;
    370       current = 0;
    371     } else
    372   #endif
    373     {
    374       stack  = &the_thread->Start.Initial_stack;
    375       current = (void *)_CPU_Context_Get_SP( &the_thread->Registers );
    376     }
     334static bool Stack_check_Dump_stack_usage(
     335  const Stack_Control *stack,
     336  const void          *current,
     337  const char          *name,
     338  uint32_t             id,
     339  const rtems_printer *printer
     340)
     341{
     342  uint32_t  size;
     343  uint32_t  used;
     344  void     *low;
     345  void     *high_water_mark;
    377346
    378347  low  = Stack_check_usable_stack_start(stack);
     
    385354  else
    386355    used = 0;
    387 
    388 #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
    389   if ( the_thread == NULL ) {
    390     id = 0xffffffff;
    391     strlcpy( name, "INTR", sizeof( name ) );
    392   } else
    393 #endif
    394   {
    395     id = the_thread->Object.id;
    396     _Thread_Get_name( the_thread, name, sizeof( name ) );
    397   }
    398356
    399357  rtems_printf(
     
    417375}
    418376
     377static bool Stack_check_Dump_threads_usage(
     378  Thread_Control *the_thread,
     379  void           *arg
     380)
     381{
     382  char                 name[ 22 ];
     383  const rtems_printer *printer;
     384
     385  printer = arg;
     386  _Thread_Get_name( the_thread, name, sizeof( name ) );
     387  Stack_check_Dump_stack_usage(
     388    &the_thread->Start.Initial_stack,
     389    (void *) _CPU_Context_Get_SP( &the_thread->Registers ),
     390    name,
     391    the_thread->Object.id,
     392    printer
     393  );
     394  return false;
     395}
     396
     397static void Stack_check_Dump_interrupt_stack_usage(
     398  const Stack_Control *stack,
     399  const rtems_printer *printer
     400)
     401{
     402  Stack_check_Dump_stack_usage(
     403    stack,
     404    NULL,
     405    "INTR",
     406    0xffffffff,
     407    printer
     408  );
     409}
     410
    419411/*
    420412 *  rtems_stack_checker_report_usage
     
    437429  );
    438430
    439   #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE)
    440     /* dump interrupt stack info if any */
    441     Stack_check_Dump_threads_usage(
    442       (Thread_Control *) -1,
    443       RTEMS_DECONST( rtems_printer *, printer )
    444     );
    445   #endif
     431  Stack_check_Dump_interrupt_stack_usage(
     432    &Stack_check_Interrupt_stack,
     433    printer
     434  );
    446435}
    447436
Note: See TracChangeset for help on using the changeset viewer.