Seulement dans fxt-0.3.9/tools: .deps Seulement dans fxt-0.3.9/tools: ev.lo Seulement dans fxt-0.3.9/tools: fkt_extract Seulement dans fxt-0.3.9/tools: fkt_print Seulement dans fxt-0.3.9/tools: fkt_record Seulement dans fxt-0.3.9/tools: fkt_select Seulement dans fxt-0.3.9/tools: fkt_setmask Seulement dans fxt-0.3.9/tools: fut_bench diff -ur -x '*.o' -x '*.a' -x '*.so' -x '*.swp' -x '*.Plo' -x '*.Po' -x fut.h fxt-0.3.9-orig/tools/fut_bench.c fxt-0.3.9/tools/fut_bench.c --- fxt-0.3.9-orig/tools/fut_bench.c 2016-08-23 16:15:32.000000000 +0200 +++ fxt-0.3.9/tools/fut_bench.c 2020-02-24 15:06:04.429266000 +0100 @@ -79,11 +79,11 @@ enable_fut_flush(); fut_setup(64<<20, FUT_KEYMASKALL, #ifdef __MINGW32__ - GetCurrentThreadId() + GetCurrentThreadId(), #else - pthread_self() + pthread_self(), #endif - ); + NULL); fut_keychange(FUT_ENABLE, FUT_KEYMASKALL, #ifdef __MINGW32__ GetCurrentThreadId() Seulement dans fxt-0.3.9/tools: fut_print.h diff -ur -x '*.o' -x '*.a' -x '*.so' -x '*.swp' -x '*.Plo' -x '*.Po' -x fut.h fxt-0.3.9-orig/tools/fut_record.c fxt-0.3.9/tools/fut_record.c --- fxt-0.3.9-orig/tools/fut_record.c 2017-03-22 18:17:46.000000000 +0100 +++ fxt-0.3.9/tools/fut_record.c 2020-02-24 15:03:45.209144000 +0100 @@ -214,6 +214,7 @@ static unsigned long trash_buffer[8]; extern int allow_fut_flush; extern pthread_mutex_t fut_flush_lock; +extern void (*fut_flush_callback)(void); #if !defined(__MINGW32__) #ifdef __GNUC__ @@ -337,6 +338,10 @@ /* We're done, let another flusher proceed */ pthread_mutex_unlock(&fut_flush_lock); + if (fut_flush_callback) { + (*fut_flush_callback)(); + } + /* And try to get our slot */ goto retry; } else { Seulement dans fxt-0.3.9/tools: fut_record.lo diff -ur -x '*.o' -x '*.a' -x '*.so' -x '*.swp' -x '*.Plo' -x '*.Po' -x fut.h fxt-0.3.9-orig/tools/fut_setup.c fxt-0.3.9/tools/fut_setup.c --- fxt-0.3.9-orig/tools/fut_setup.c 2017-03-24 09:35:01.000000000 +0100 +++ fxt-0.3.9/tools/fut_setup.c 2020-02-25 11:22:08.694558000 +0100 @@ -77,7 +77,7 @@ int fut_curbuf; /* buffer currently in use */ /* number of contiguous allocated bytes pointed to by fut_bufptr */ -unsigned int fut_nallocated = 0; +uint64_t fut_nallocated = 0; /* filename of the output trace */ static char *fut_filename = NULL; @@ -96,6 +96,8 @@ static int already_flushed = 0; +void (*fut_flush_callback)(void) = NULL; + void fut_set_filename(char* filename) { pthread_mutex_lock(&fut_flush_lock); @@ -186,11 +188,13 @@ includes mallocing the buffer to hold the trace. returns number of bytes allocated if all ok, else a negative error code. */ -int fut_setup( unsigned int nlongs, unsigned int keymask, unsigned int threadid ) +int64_t fut_setup( uint64_t nlongs, unsigned int keymask, unsigned int threadid, void (*flush_callback)(void) ) { - unsigned int nbytes; + uint64_t nbytes; unsigned long *iptr; + fut_flush_callback = flush_callback; + /* paranoia, so nobody waits for us while we are in here */ fut_active = 0; @@ -327,9 +331,9 @@ /* called to reset tracing to refill the entire buffer again. returns number of bytes in buffer if all ok, else a negative error code. */ -int fut_reset( unsigned int keymask, unsigned int threadid ) +int64_t fut_reset( unsigned int keymask, unsigned int threadid ) { - unsigned int nlongs; + uint64_t nlongs; /* paranoia, so nobody waits for us while we are in here */ @@ -363,9 +367,9 @@ /* called repeatedly to copy current buffer into user space. returns nlongs >= 0 if all ok, else a negative error code. */ -int fut_getbuffer( int *nlongs, unsigned long **buffer, unsigned long* first_slot, unsigned long *next_slot ) +uint64_t fut_getbuffer( uint64_t *nlongs, unsigned long **buffer, unsigned long* first_slot, unsigned long *next_slot ) { - int local_nlongs = 0; + uint64_t local_nlongs = 0; if( fut_bufptr[0] == NULL ) @@ -387,10 +391,11 @@ return local_nlongs; } -int fut_flush( char* filename, void *first_slot, void* next_slot, int record_flush_events ) +uint64_t fut_flush( char* filename, void *first_slot, void* next_slot, int record_flush_events ) { - int n, nlongs=0; + uint64_t n=0; + uint64_t nlongs = 0; long size; unsigned long *copy=NULL; static off_t begin = 0; @@ -441,10 +446,23 @@ if(record_flush_events) __fut_record_event(&start_flush_event, fut_getstamp(), FUT_CODE(FUT_START_FLUSH_CODE, 0)); - /* dump the buffer to disk */ - if( write(fut_fd, (void *)copy, size) < 0 ) { - perror("write buffer"); - } + /* dump the buffer to disk + * since write syscall can write at most ~2GB of data (see NOTES of `man 2 write`), + * we need to loop while whole buffer isn't flushed, if the buffer size if more than 2 GB. + */ + ssize_t written = 0; + ssize_t total_written = 0; + ssize_t to_write = size; + unsigned write_error = 0; + do { + written = write(fut_fd, (void *)copy + total_written, size - total_written); + if( written < 0 ) { + perror("write buffer"); + } + else { + total_written += written; + } + } while(written >= 0 && total_written < size); fxt_trace_user_raw_t stop_flush_event; if(record_flush_events) { @@ -480,14 +498,14 @@ return nlongs; } -int fut_endup( char *filename ) +uint64_t fut_endup( char *filename ) { /* stop all futher tracing */ fut_active = 0; /* dump the buffer to disk */ - int nlongs = fut_flush(filename, fut_first_slot, fut_next_slot, 0); + uint64_t nlongs = fut_flush(filename, fut_first_slot, fut_next_slot, 0); if(nlongs < 0) return nlongs; Seulement dans fxt-0.3.9/tools: fut_setup.lo diff -ur -x '*.o' -x '*.a' -x '*.so' -x '*.swp' -x '*.Plo' -x '*.Po' -x fut.h fxt-0.3.9-orig/tools/fut-template.h fxt-0.3.9/tools/fut-template.h --- fxt-0.3.9-orig/tools/fut-template.h 2019-07-12 11:38:56.945434200 +0200 +++ fxt-0.3.9/tools/fut-template.h 2020-02-24 15:03:45.219141000 +0100 @@ -329,14 +329,14 @@ extern unsigned long * volatile fut_last_slot; extern size_t volatile fut_filled_slot; -extern int fut_setup( unsigned int nints, unsigned int keymask, - unsigned int threadid ); -extern int fut_endup( char *filename ); +extern int64_t fut_setup( uint64_t nints, unsigned int keymask, + unsigned int threadid, void (*flush_callback)(void) ); +extern uint64_t fut_endup( char *filename ); extern int fut_done(void ); extern int fut_keychange( int how, unsigned int keymask, unsigned int threadid ); -extern int fut_reset( unsigned int keymask, unsigned int threadid ); -extern int fut_getbuffer( int *nints, unsigned long **buffer, unsigned long *first_slot, unsigned long *next_slot); +extern int64_t fut_reset( unsigned int keymask, unsigned int threadid ); +extern uint64_t fut_getbuffer( uint64_t *nints, unsigned long **buffer, unsigned long *first_slot, unsigned long *next_slot); extern int fut_header( unsigned long head, ... ); Seulement dans fxt-0.3.9/tools: fut-template.h.orig diff -ur -x '*.o' -x '*.a' -x '*.so' -x '*.swp' -x '*.Plo' -x '*.Po' -x fut.h fxt-0.3.9-orig/tools/fxt_internal.h fxt-0.3.9/tools/fxt_internal.h --- fxt-0.3.9-orig/tools/fxt_internal.h 2019-07-12 10:26:50.244193147 +0200 +++ fxt-0.3.9/tools/fxt_internal.h 2020-02-24 15:03:45.225150000 +0100 @@ -360,9 +360,9 @@ #endif unsigned long* __fut_record_event(fxt_trace_user_raw_t * rec, uint64_t stamp, unsigned long code); -int fut_flush( char* filename, void *first_slot, void* next_slot, int record_flush_events ); +uint64_t fut_flush( char* filename, void *first_slot, void* next_slot, int record_flush_events ); void __fut_reset_pointers(); -extern unsigned int fut_nallocated; +extern uint64_t fut_nallocated; #define i386_sync() __asm__ __volatile__("lock; addl $0,0(%%esp)" ::: "memory") #define x86_64_sync() __asm__ __volatile__("lock; addl $0,0(%%rsp)" ::: "memory") Seulement dans fxt-0.3.9/tools: fxt.lo Seulement dans fxt-0.3.9/tools: fxt_print Seulement dans fxt-0.3.9/tools: get_cpu_info.lo Seulement dans fxt-0.3.9/tools: libfxt.la Seulement dans fxt-0.3.9/tools: .libs Seulement dans fxt-0.3.9/tools: Makefile Seulement dans fxt-0.3.9/tools: names.lo Seulement dans fxt-0.3.9/tools: pids.lo Seulement dans fxt-0.3.9/tools: symbols.lo Seulement dans fxt-0.3.9/tools: test diff -ur -x '*.o' -x '*.a' -x '*.so' -x '*.swp' -x '*.Plo' -x '*.Po' -x fut.h fxt-0.3.9-orig/tools/test.c fxt-0.3.9/tools/test.c --- fxt-0.3.9-orig/tools/test.c 2017-11-22 15:28:18.000000000 +0100 +++ fxt-0.3.9/tools/test.c 2020-02-24 15:03:45.230141000 +0100 @@ -42,7 +42,7 @@ fprintf(stderr,"setting flush\n"); enable_fut_flush(); fprintf(stderr,"setting up\n"); - if (fut_setup(BUFFER_SIZE, 0xffff, myid()) < 0) + if (fut_setup(BUFFER_SIZE, 0xffff, myid(), NULL) < 0) { perror("fut_setup"); exit(EXIT_FAILURE);