summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/capture/capture_buffer.h
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-08-30 16:46:25 +1000
committerChris Johns <chrisj@rtems.org>2016-09-01 11:11:22 +1000
commit6da06c559f17f33177f59c0f83164bb2d20c8b9f (patch)
tree9f4b23a8f6e5215489ffbb8219c85fd11aa08e6c /cpukit/libmisc/capture/capture_buffer.h
parentarm/xilinx_zynq: Start the second core when an SMP build. (diff)
downloadrtems-6da06c559f17f33177f59c0f83164bb2d20c8b9f.tar.bz2
libmisc/capture: Fix the capture engine on SMP.
This patches some issues with the capture engine: 1. Check is the engine is open in ctrace commands. 2. Check all record open and appends for overflow. 3. Fix the record open to take the size of user data and not the record header. 4. Use packed structs for data being written to the per cpu buffers. 5. Remove direct struct access to the capture buffers to avoid misaligned accesses. 6. Add support to extract records, no struct access to the capture buffers. 7. Update ctrace to extract records from the capture buffers. 8. Add support to ctrace to always print the task name if it has one. 9. Add support to manage names or the lack of a name. 10. Range of minor fixes. 11. Fix a long standing bug in ctset's handling of args. Closes #2780.
Diffstat (limited to 'cpukit/libmisc/capture/capture_buffer.h')
-rw-r--r--cpukit/libmisc/capture/capture_buffer.h69
1 files changed, 42 insertions, 27 deletions
diff --git a/cpukit/libmisc/capture/capture_buffer.h b/cpukit/libmisc/capture/capture_buffer.h
index 2b90b0abc2..7f21f4709e 100644
--- a/cpukit/libmisc/capture/capture_buffer.h
+++ b/cpukit/libmisc/capture/capture_buffer.h
@@ -12,6 +12,9 @@
COPYRIGHT (c) 2014.
On-Line Applications Research Corporation (OAR).
+ Copyright 2016 Chris Johns <chrisj@rtems.org>.
+ All rights reserved.
+
The license and distribution terms for this file may be
found in the file LICENSE in this distribution.
@@ -20,83 +23,95 @@
------------------------------------------------------------------------
*/
-#ifndef __CAPTUREBUFFER_H_
-#define __CAPTUREBUFFER_H_
+#ifndef __CAPTURE_BUFFER_H_
+#define __CAPTURE_BUFFER_H_
#include <stdlib.h>
-
/**@{*/
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * Capture buffer. There is one per CPU.
+ */
typedef struct {
- uint8_t *buffer;
- size_t size;
- size_t count;
- size_t head;
- size_t tail;
- size_t end;
+ uint8_t* buffer; /**< The per cpu buffer. */
+ size_t size; /**< The size of the buffer in bytes. */
+ size_t count; /**< The number of used bytes in the buffer. */
+ size_t head; /**< First record. */
+ size_t tail; /**< Head == Tail for empty. */
+ size_t end; /**< Buffer current end, it may move in. */
+ size_t max_rec; /**< The largest record in the buffer. */
} rtems_capture_buffer_t;
-static inline void rtems_capture_buffer_flush( rtems_capture_buffer_t* buffer )
+static inline void
+rtems_capture_buffer_flush (rtems_capture_buffer_t* buffer)
{
buffer->end = buffer->size;
buffer->head = buffer->tail = 0;
buffer->count = 0;
+ buffer->max_rec = 0;
}
-static inline void rtems_capture_buffer_create( rtems_capture_buffer_t* buffer, size_t size )
+static inline void
+rtems_capture_buffer_create (rtems_capture_buffer_t* buffer, size_t size)
{
buffer->buffer = malloc(size);
buffer->size = size;
- rtems_capture_buffer_flush( buffer );
+ rtems_capture_buffer_flush (buffer);
}
-static inline void rtems_capture_buffer_destroy( rtems_capture_buffer_t* buffer )
+static inline void
+rtems_capture_buffer_destroy (rtems_capture_buffer_t* buffer)
{
- rtems_capture_buffer_flush( buffer );
- free( buffer->buffer);
+ rtems_capture_buffer_flush (buffer);
+ free (buffer->buffer);
buffer->buffer = NULL;
}
-static inline bool rtems_capture_buffer_is_empty( rtems_capture_buffer_t* buffer )
+static inline bool
+rtems_capture_buffer_is_empty (rtems_capture_buffer_t* buffer)
{
- return( buffer->count == 0 );
+ return buffer->count == 0;
}
-static inline bool rtems_capture_buffer_is_full( rtems_capture_buffer_t* buffer )
+static inline bool
+rtems_capture_buffer_is_full (rtems_capture_buffer_t* buffer)
{
- return (buffer->count == buffer->size);
+ return buffer->count == buffer->size;
}
-static inline bool rtems_capture_buffer_has_wrapped( rtems_capture_buffer_t* buffer )
+static inline bool
+rtems_capture_buffer_has_wrapped (rtems_capture_buffer_t* buffer)
{
- if ( buffer->tail > buffer->head)
+ if (buffer->tail > buffer->head)
return true;
return false;
}
-static inline void *rtems_capture_buffer_peek( rtems_capture_buffer_t* buffer, size_t *size )
+static inline void*
+rtems_capture_buffer_peek (rtems_capture_buffer_t* buffer, size_t* size)
{
- if (rtems_capture_buffer_is_empty(buffer)) {
+ if (rtems_capture_buffer_is_empty (buffer))
+ {
*size = 0;
return NULL;
}
- if ( buffer->tail > buffer->head)
+ if (buffer->tail > buffer->head)
*size = buffer->end - buffer->tail;
else
*size = buffer->head - buffer->tail;
- return &buffer->buffer[ buffer->tail ];
+ return &buffer->buffer[buffer->tail];
}
-void *rtems_capture_buffer_allocate( rtems_capture_buffer_t* buffer, size_t size );
+void* rtems_capture_buffer_allocate (rtems_capture_buffer_t* buffer, size_t size);
-void *rtems_capture_buffer_free( rtems_capture_buffer_t* buffer, size_t size );
+void* rtems_capture_buffer_free (rtems_capture_buffer_t* buffer, size_t size);
#ifdef __cplusplus
}