#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gpxe/init.h>
#include <gpxe/uaccess.h>
Go to the source code of this file.
Data Structures | |
| struct | fnrec_buffer |
| A trace buffer. More... | |
Enumerations | |
| enum | { fnrec_magic = 'f' << 24 | 'n' << 16 | 'r' << 8 | 'e', fnrec_buffer_length = 4096 / sizeof ( unsigned long ) } |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static int | fnrec_is_valid (void) |
| Test whether the trace buffer is valid. | |
| static void | fnrec_reset (void) |
| Reset the trace buffer and clear entries. | |
| static void | fnrec_append_unique (unsigned long l) |
| Write a value to the end of the buffer if it is not a repetition. | |
| static void | fnrec_dump (void) |
| Print the contents of the trace buffer in chronological order. | |
| static void | fnrec_init (void) |
| Function tracer initialisation function. | |
| struct init_fn fnrec_init_fn | __init_fn (INIT_NORMAL) |
| void | __cyg_profile_func_enter (void *called_fn, void *call_site __unused) |
| void | __cyg_profile_func_exit (void *called_fn __unused, void *call_site __unused) |
Variables | |
| static struct fnrec_buffer * | fnrec_buffer |
| The trace buffer. | |
Definition in file fnrec.c.
| anonymous enum |
| fnrec_magic | Constant for identifying valid trace buffers. |
| fnrec_buffer_length | Trace buffer length. |
Definition at line 33 of file fnrec.c.
00033 { 00034 /** Constant for identifying valid trace buffers */ 00035 fnrec_magic = 'f' << 24 | 'n' << 16 | 'r' << 8 | 'e', 00036 00037 /** Trace buffer length */ 00038 fnrec_buffer_length = 4096 / sizeof ( unsigned long ), 00039 };
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static int fnrec_is_valid | ( | void | ) | [static] |
Test whether the trace buffer is valid.
| is_valid | Buffer is valid |
Definition at line 61 of file fnrec.c.
References fnrec_magic, and fnrec_buffer::magic.
Referenced by __cyg_profile_func_enter(), and fnrec_dump().
00061 { 00062 return fnrec_buffer && fnrec_buffer->magic == fnrec_magic; 00063 }
| static void fnrec_reset | ( | void | ) | [static] |
Reset the trace buffer and clear entries.
Definition at line 68 of file fnrec.c.
References fnrec_magic, fnrec_buffer::magic, and memset().
Referenced by fnrec_init().
00068 { 00069 memset ( fnrec_buffer, 0, sizeof ( *fnrec_buffer ) ); 00070 fnrec_buffer->magic = fnrec_magic; 00071 }
| static void fnrec_append_unique | ( | unsigned long | l | ) | [static] |
Write a value to the end of the buffer if it is not a repetition.
| l | Value to append |
Definition at line 78 of file fnrec.c.
References fnrec_buffer::data, fnrec_buffer_length, and fnrec_buffer::idx.
Referenced by __cyg_profile_func_enter().
00078 { 00079 static unsigned long lastval; 00080 uint32_t idx = fnrec_buffer->idx; 00081 00082 /* Avoid recording the same value repeatedly */ 00083 if ( l == lastval ) 00084 return; 00085 00086 fnrec_buffer->data[idx] = l; 00087 fnrec_buffer->idx = ( idx + 1 ) % fnrec_buffer_length; 00088 lastval = l; 00089 }
| static void fnrec_dump | ( | void | ) | [static] |
Print the contents of the trace buffer in chronological order.
Definition at line 94 of file fnrec.c.
References fnrec_buffer::data, fnrec_buffer_length, fnrec_is_valid(), fnrec_buffer::idx, and printf().
Referenced by fnrec_init().
00094 { 00095 size_t i; 00096 00097 if ( !fnrec_is_valid() ) { 00098 printf ( "fnrec buffer not found\n" ); 00099 return; 00100 } 00101 00102 printf ( "fnrec buffer dump:\n" ); 00103 for ( i = 0; i < fnrec_buffer_length; i++ ) { 00104 unsigned long l = fnrec_buffer->data[ 00105 ( fnrec_buffer->idx + i ) % fnrec_buffer_length]; 00106 printf ( "%08lx%c", l, i % 8 == 7 ? '\n' : ' ' ); 00107 } 00108 }
| static void fnrec_init | ( | void | ) | [static] |
Function tracer initialisation function.
Definition at line 113 of file fnrec.c.
References fnrec_dump(), fnrec_reset(), and phys_to_virt().
00113 { 00114 /* Hardcoded to 17 MB */ 00115 fnrec_buffer = phys_to_virt ( 17 * 1024 * 1024 ); 00116 fnrec_dump(); 00117 fnrec_reset(); 00118 }
| struct init_fn fnrec_init_fn __init_fn | ( | INIT_NORMAL | ) | [read] |
| void __cyg_profile_func_enter | ( | void * | called_fn, | |
| void *call_site | __unused | |||
| ) |
Definition at line 128 of file fnrec.c.
References fnrec_append_unique(), and fnrec_is_valid().
00128 { 00129 if ( fnrec_is_valid() ) 00130 fnrec_append_unique ( ( unsigned long ) called_fn ); 00131 }
| void __cyg_profile_func_exit | ( | void *called_fn | __unused, | |
| void *call_site | __unused | |||
| ) |
struct fnrec_buffer* fnrec_buffer [static] |
1.5.7.1