BufferBlock *first_buffer;
BufferBlock *last_buffer;
- int count_total;
- int count_last;
+ size_t count_total;
+ size_t count_last;
Buffer();
void add (char x);
struct PerAddr {
PerThread *owner;
void *ptr;
- int idx;
+ size_t idx;
int valid;
const char *reason;
- int reason_idx;
+ size_t reason_idx;
__malloc_trace_buffer_s *inverted;
PerAddr(void *_ptr) : owner(0), ptr(_ptr), valid(0), reason("not seen"), inverted(NULL) {};
};
static void
process_one_trace_record (__malloc_trace_buffer_s *r)
{
- int i = r - trace_records;
+ size_t i = r - trace_records;
// Quick-skip for NULs at EOF
if (r->type == __MTB_TYPE_UNUSED)
{
if (pa2->inverted)
{
- printf ("%d: pointer %p alloc'd again? (possible multi-level inversion) size %d %d:%s\n",
- i, pa2->ptr, (int)r->size, pa2->reason_idx, pa2->reason);
- exit (1);
+ printf ("%ld: pointer %p alloc'd again? (possible multi-level inversion) size %ld %ld:%s\n",
+ i, pa2->ptr, (long int)r->size, pa2->reason_idx, pa2->reason);
+ // exit (1);
}
- printf("inversion for type %d\n", r->type);
pa2->inverted = r;
fixed_inversions ++;
pending_inversions ++;
}
else
{
- printf("%d: invalid pointer %p passed to free: %d:%s\n", i, pa1->ptr, pa1->reason_idx, pa1->reason);
+ printf("%ld: invalid pointer %p passed to free: %ld:%s\n", i, pa1->ptr, pa1->reason_idx, pa1->reason);
}
break;
case __MTB_TYPE_MEMALIGN:
acq_ptr (thread, pa2);
if (pa2 && pa2->valid)
- printf ("%d: pointer %p memalign'd again? %d:%s\n", i, pa2->ptr, pa2->reason_idx, pa2->reason);
+ printf ("%ld: pointer %p memalign'd again? %ld:%s\n", i, pa2->ptr, pa2->reason_idx, pa2->reason);
thread->add (C_MEMALIGN);
thread->add_int (pa2 ? pa2->idx : 0);
thread->add_int (r->size2);
break;
case __MTB_TYPE_POSIX_MEMALIGN:
- printf ("%d: Unsupported posix_memalign call.\n", i);
+ printf ("%ld: Unsupported posix_memalign call.\n", i);
exit (1);
break;
per_addr[0] = NULL;
- for (unsigned int i = 0; i < num_trace_records; i++)
+ for (unsigned long i = 0; i < num_trace_records; i++)
process_one_trace_record (trace_records + i);
int n_threads = per_thread.size();
PerThread *threads[n_threads];
- int thread_off[n_threads];
+ size_t thread_off[n_threads];
int i = 0;
PerThreadMap::iterator iter;
threads[i++] = iter->second;
iter->second->add(C_DONE);
if(verbose)
- printf("thread: %d bytes\n", iter->second->workload.count_total);
+ printf("thread: %ld bytes\n", (long)iter->second->workload.count_total);
}
/* The location of each thread's workload depends on the size of the
startup block, but the size of the startup block depends on the
size of the thread's location encoding. So, we loop until it
stabilizes. */
- int old_len = 1;
- int new_len = 2;
+ size_t old_len = 1;
+ size_t new_len = 2;
Buffer main_loop;
while (old_len != new_len)
{
- int off = new_len;
+ size_t off = new_len;
int i;
old_len = new_len;
for (i=0; i<n_threads; i++)
{
if (verbose)
- printf("Start thread[%d] offset 0x%x\n", i, thread_off[i]);
+ printf("Start thread[%d] offset 0x%lx\n", i, (long)thread_off[i]);
threads[i]->workload.write (wl_fd);
}
+#define _LARGEFILE64_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
io->incr = incr;
pthread_mutex_lock (&io_mutex);
- lseek (io_fd, io->buf_base, SEEK_SET);
+ lseek64 (io_fd, io->buf_base, SEEK_SET);
// short read OK, the eof is just to prevent runaways from bad data.
if (read (io_fd, io->buf, incr) < 0)
io->saw_eof = 1;
ticks_t my_realloc_time = 0, my_realloc_count = 0;
ticks_t my_free_time = 0, my_free_count = 0;
ticks_t stime, etime;
+ int thread_idx = io - thread_io;
#ifdef MDEBUG
volatile void *tmp;
#endif
while (1)
{
+ unsigned char this_op = io_peek (io);
if (io->saw_eof)
myabort();
dprintf("op %p:%ld is %d\n", (void *)thrc, io_pos (io), io_peek (io));
break;
default:
+ printf("op %d - unsupported, thread %d addr %lu\n",
+ this_op, thread_idx, (long unsigned int)io_pos (io));
myabort();
}
}
idx = get_int (&main_io);
io_init (& thread_io[thread_idx], idx, guessed_io_size);
pthread_create (&thread_ids[thread_idx], NULL, thread_common, thread_io + thread_idx);
- dprintf("Starting thread %lld at offset %d %x\n", (long long)thread_ids[thread_idx], (int)idx, (unsigned int)idx);
+ dprintf("Starting thread %lld at offset %lu %lx\n", (long long)thread_ids[thread_idx], (unsigned long)idx, (unsigned long)idx);
thread_idx ++;
break;
case C_DONE: