From b856f645a2f58a3e224976167b4b1fb030d7967b Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Mon, 11 Jul 2016 20:50:34 -0400 Subject: Update to new binary file-based trace file. In order to not lose records, or need to guess ahead of time how many records you need, this switches to a mmap'd file for the trace buffer, and grows it as needed. The trace2dat perl script is replaced with a trace2wl C++ program that runs a lot faster and can handle the binary format. --- malloc/mtrace.h | 57 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'malloc/mtrace.h') diff --git a/malloc/mtrace.h b/malloc/mtrace.h index db3cbe51a6..dcb20bb53c 100644 --- a/malloc/mtrace.h +++ b/malloc/mtrace.h @@ -43,32 +43,31 @@ struct __malloc_trace_buffer_s { typedef struct __malloc_trace_buffer_s *__malloc_trace_buffer_ptr; -/* These three are only valid inside glibc proper. */ -extern volatile __malloc_trace_buffer_ptr __malloc_trace_buffer; -extern volatile size_t __malloc_trace_buffer_size; -extern volatile size_t __malloc_trace_buffer_head; - -/* bufptr is a random chunk of memory, bufsize is the size of that - chunk in BYTES. Returns the size of __malloc_trace_buffer_s. The - buffer should be filled with NUL bytes before passing, such that - each record's type is UNUSED (below). The trace buffer may be - disabled by passing NULL,0 although it's up to the caller to obtain - and free/unmap the previous buffer first. */ -int __malloc_set_trace_buffer (void *bufptr, size_t bufsize); - -/* Returns the location of the buffer (same as passed above, or NULL). - Also fills in BUFCOUNT which is the number of records (not bytes) - in the buffer, and BUFHEAD which is the index of the most recently - filled entry. NOTE that BUFHEAD might be greater than bufcount; if - so it reflects the number of records that would have been stored - had there been size, and the caller must modulo that by BUFCOUNT to - get the ending index. The last BUFCOUNT records are stored; - earlier records are overwritten. */ -void * __malloc_get_trace_buffer (size_t *bufcount, size_t *bufhead); +/* Initialize the trace buffer and backing file. The file is + overwritten if it already exists. */ +void __malloc_trace_init (char *filename); + +/* All remaining functions return current count of trace records. */ + +/* Pause - but don't stop - tracing. */ +size_t __malloc_trace_pause (void); + +/* Resume tracing where it left off when paused. */ +size_t __malloc_trace_unpause (void); + +/* Stop tracing and clean up all the trace buffer mappings. */ +size_t __malloc_trace_stop (void); + +/* Sync all buffer data to file (typically a no-op on Linux). */ +size_t __malloc_trace_sync (void); #define __MTB_TYPE_UNUSED 0 +/* ptr1 is 0x1234, size is sizeof(void *) - there is one of these at + the beginning of the trace. */ +#define __MTB_TYPE_MAGIC 255 + /* ptr2 = malloc (size) */ #define __MTB_TYPE_MALLOC 1 @@ -104,3 +103,17 @@ typedef enum { } MSCAN_Types; void __malloc_scan_chunks (void (*callback)(void * /*ptr*/, size_t /*length*/, int /*type*/)); + +/* Codes for the simulator/workload programs. */ +#define C_NOP 0 +#define C_DONE 1 +#define C_MALLOC 2 +#define C_CALLOC 3 +#define C_REALLOC 4 +#define C_FREE 5 +#define C_SYNC_W 6 +#define C_SYNC_R 7 +#define C_ALLOC_PTRS 8 +#define C_ALLOC_SYNCS 9 +#define C_NTHREADS 10 +#define C_START_THREAD 11 -- cgit v1.2.3