[PATCH 2/4] capture: Fix capture engine to handle new extensions.

Chris Johns chrisj at rtems.org
Fri Jul 11 01:43:40 UTC 2014



On 10/07/2014 11:44 pm, Jennifer Averett wrote:
> ---
>   cpukit/libmisc/capture/capture.c | 96 ++++++++++++++++++++++++++++------------
>   cpukit/libmisc/capture/capture.h | 17 ++++---
>   2 files changed, 78 insertions(+), 35 deletions(-)
>
> diff --git a/cpukit/libmisc/capture/capture.c b/cpukit/libmisc/capture/capture.c
> index 6f8e0a2..ec5e408 100644
> --- a/cpukit/libmisc/capture/capture.c
> +++ b/cpukit/libmisc/capture/capture.c
> @@ -51,11 +51,41 @@
>                                         RTEMS_CAPTURE_DELETED_BY_EVENT | \
>                                         RTEMS_CAPTURE_DELETED_EVENT | \
>                                         RTEMS_CAPTURE_BEGIN_EVENT | \
> -                                      RTEMS_CAPTURE_EXITTED_EVENT)
> +                                      RTEMS_CAPTURE_EXITTED_EVENT | \
> +                                      RTEMS_CAPTURE_TERMINATED_EVENT)
>   #else
>   #define RTEMS_CAPTURE_RECORD_EVENTS  (0)
>   #endif
>
> +static bool
> +rtems_capture_create_task (rtems_tcb* current_task,
> +                           rtems_tcb* new_task);
> +
> +static void
> +rtems_capture_start_task (rtems_tcb* current_task,
> +                          rtems_tcb* started_task);
> +
> +static void
> +rtems_capture_restart_task (rtems_tcb* current_task,
> +                            rtems_tcb* restarted_task);
> +
> +static void
> +rtems_capture_delete_task (rtems_tcb* current_task,
> +                           rtems_tcb* deleted_task);
> +
> +static void
> +rtems_capture_switch_task (rtems_tcb* current_task,
> +                           rtems_tcb* heir_task);
> +
> +static void
> +rtems_capture_begin_task (rtems_tcb* begin_task);
> +
> +static void
> +rtems_capture_exitted_task (rtems_tcb* exitted_task);
> +
> +static void
> +rtems_capture_terminated_task (rtems_tcb* terminated_task);
> +
>   /*
>    * Global capture flags.
>    */
> @@ -88,6 +118,18 @@ static rtems_id                 capture_reader;
>   static rtems_interrupt_lock     capture_lock =
>     RTEMS_INTERRUPT_LOCK_INITIALIZER("capture");
>
> +static rtems_extensions_table capture_extensions = {
> +  .thread_create    = rtems_capture_create_task,
> +  .thread_start     = rtems_capture_start_task,
> +  .thread_restart   = rtems_capture_restart_task,
> +  .thread_delete    = rtems_capture_delete_task,
> +  .thread_switch    = rtems_capture_switch_task,
> +  .thread_begin     = rtems_capture_begin_task,
> +  .thread_exitted   = rtems_capture_exitted_task,
> +  .fatal            = NULL,
> +  .thread_terminate = rtems_capture_terminated_task
> +};
> +

This should be const so it lives in the program text. A requirement has 
always been to not use any RAM if not enabled and linked in and the 
requirement is mostly met with just a few pointers plus the lock.

>   /*
>    * RTEMS Event text.
>    */
> @@ -101,6 +143,7 @@ static const char* capture_event_text[] =
>     "RESTARTED",
>     "DELETED_BY",
>     "DELETED",
> +  "TERMINATED",
>     "BEGIN",
>     "EXITTED",
>     "SWITCHED_OUT",
> @@ -787,21 +830,28 @@ rtems_capture_exitted_task (rtems_tcb* exitted_task)
>   static void
>   rtems_capture_terminated_task (rtems_tcb* terminated_task)
>   {
> -  rtems_capture_delete_task (terminated_task, terminated_task);
> -}
> +  /*
> +   * Get the capture task control block so we can trace this
> +   * event.
> +   */
> +  rtems_capture_task_t* tt;
>
> -/*
> - * This function is called when a fatal error occurs.
> - */
> -static void
> -rtems_capture_fatal(
> -  Internal_errors_Source source,
> -  bool                   is_internal,
> -  Internal_errors_t      code
> -)
> -{
> +  tt = terminated_task->extensions[capture_extension_index];
> +
> +  /*
> +   * The task pointers may not be known as the task may have
> +   * been created before the capture engine was open. Add them.
> +   */
> +
> +  if (tt == NULL)
> +    tt = rtems_capture_create_capture_task (terminated_task);
> +
> +  if (rtems_capture_trigger (NULL, tt, RTEMS_CAPTURE_TERMINATED))
> +    rtems_capture_record (tt, RTEMS_CAPTURE_TERMINATED_EVENT);
> +
> +  rtems_capture_task_stack_usage (tt);
>   }
> -
> +
>   /*
>    * This function is called when a context is switched.
>    */
> @@ -887,7 +937,6 @@ rtems_capture_switch_task (rtems_tcb* current_task,
>   rtems_status_code
>   rtems_capture_open (uint32_t   size, rtems_capture_timestamp timestamp __attribute__((unused)))
>   {
> -  rtems_extensions_table capture_extensions;
>     rtems_name             name;
>     rtems_status_code      sc;
>
> @@ -913,19 +962,6 @@ rtems_capture_open (uint32_t   size, rtems_capture_timestamp timestamp __attribu
>     capture_floor   = 255;
>
>     /*
> -   * Create the extension table. This is copied so we
> -   * can create it as a local.
> -   */
> -  capture_extensions.thread_create  = rtems_capture_create_task;
> -  capture_extensions.thread_start   = rtems_capture_start_task;
> -  capture_extensions.thread_restart = rtems_capture_restart_task;
> -  capture_extensions.thread_delete  = rtems_capture_delete_task;
> -  capture_extensions.thread_switch  = rtems_capture_switch_task;
> -  capture_extensions.thread_begin   = rtems_capture_begin_task;
> -  capture_extensions.thread_exitted = rtems_capture_exitted_task;
> -  capture_extensions.fatal          = NULL;
> -
> -  /*
>      * Register the user extension handlers for the CAPture Engine.
>      */
>     name = rtems_build_name ('C', 'A', 'P', 'E');
> @@ -1341,6 +1377,8 @@ rtems_capture_map_trigger (rtems_capture_trigger_t trigger)
>         return RTEMS_CAPTURE_BEGIN;
>       case rtems_capture_exitted:
>         return RTEMS_CAPTURE_EXITTED;
> +    case rtems_capture_terminated:
> +      return RTEMS_CAPTURE_TERMINATED;
>       default:
>         break;
>     }
> @@ -1542,6 +1580,8 @@ rtems_capture_read (uint32_t                 threshold,
>     *read = 0;
>     *recs = NULL;
>
> +  /* XXX read or rec == NULL? */
> +

What does this mean ?

If we support doxygen should be use something that can be parsed and 
collected ?

>     rtems_interrupt_lock_acquire (&capture_lock, &lock_context);
>
>     /*
> diff --git a/cpukit/libmisc/capture/capture.h b/cpukit/libmisc/capture/capture.h
> index fa82f6d..737c73f 100644
> --- a/cpukit/libmisc/capture/capture.h
> +++ b/cpukit/libmisc/capture/capture.h
> @@ -120,6 +120,7 @@ typedef struct rtems_capture_control_s
>   #define RTEMS_CAPTURE_DELETE        (1 << 4)
>   #define RTEMS_CAPTURE_BEGIN         (1 << 5)
>   #define RTEMS_CAPTURE_EXITTED       (1 << 6)
> +#define RTEMS_CAPTURE_TERMINATED    (1 << 7)
>
>   #define RTEMS_CAPTURE_FROM_TRIGS    (RTEMS_CAPTURE_SWITCH  | \
>                                        RTEMS_CAPTURE_CREATE | \
> @@ -208,12 +209,13 @@ typedef struct rtems_capture_record_s
>   #define RTEMS_CAPTURE_RESTARTED_EVENT     UINT32_C (0x00200000)
>   #define RTEMS_CAPTURE_DELETED_BY_EVENT    UINT32_C (0x00400000)
>   #define RTEMS_CAPTURE_DELETED_EVENT       UINT32_C (0x00800000)
> -#define RTEMS_CAPTURE_BEGIN_EVENT         UINT32_C (0x01000000)
> -#define RTEMS_CAPTURE_EXITTED_EVENT       UINT32_C (0x02000000)
> -#define RTEMS_CAPTURE_SWITCHED_OUT_EVENT  UINT32_C (0x04000000)
> -#define RTEMS_CAPTURE_SWITCHED_IN_EVENT   UINT32_C (0x08000000)
> -#define RTEMS_CAPTURE_TIMESTAMP           UINT32_C (0x10000000)
> -#define RTEMS_CAPTURE_EVENT_END           (28)
> +#define RTEMS_CAPTURE_TERMINATED_EVENT    UINT32_C (0x01000000)
> +#define RTEMS_CAPTURE_BEGIN_EVENT         UINT32_C (0x02000000)
> +#define RTEMS_CAPTURE_EXITTED_EVENT       UINT32_C (0x04000000)
> +#define RTEMS_CAPTURE_SWITCHED_OUT_EVENT  UINT32_C (0x08000000)
> +#define RTEMS_CAPTURE_SWITCHED_IN_EVENT   UINT32_C (0x10000000)
> +#define RTEMS_CAPTURE_TIMESTAMP           UINT32_C (0x20000000)
> +#define RTEMS_CAPTURE_EVENT_END           (29)
>
>   /**
>    * @brief Capture trigger modes
> @@ -240,7 +242,8 @@ typedef enum rtems_capture_trigger_e
>     rtems_capture_restart,
>     rtems_capture_delete,
>     rtems_capture_begin,
> -  rtems_capture_exitted
> +  rtems_capture_exitted,
> +  rtems_capture_terminated
>   } rtems_capture_trigger_t;
>
>   /**
>



More information about the devel mailing list