1/* 2 * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 3 * Copyright (c) 2010 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 44 unchanged lines hidden (view full) --- 53 uint64_t uncompressed_trace_size, 54 std::vector<Sequencer*>& seq_map, 55 uint64_t block_size_bytes) 56 : m_uncompressed_trace(uncompressed_trace), 57 m_uncompressed_trace_size(uncompressed_trace_size), 58 m_seq_map(seq_map), m_bytes_read(0), m_records_read(0), 59 m_records_flushed(0), m_block_size_bytes(block_size_bytes) 60{ |
61 if (m_uncompressed_trace != NULL) { 62 if (m_block_size_bytes < RubySystem::getBlockSizeBytes()) { 63 // Block sizes larger than when the trace was recorded are not 64 // supported, as we cannot reliably turn accesses to smaller blocks 65 // into larger ones. 66 panic("Recorded cache block size (%d) < current block size (%d) !!", 67 m_block_size_bytes, RubySystem::getBlockSizeBytes()); 68 } 69 } |
70} 71 72CacheRecorder::~CacheRecorder() 73{ 74 if (m_uncompressed_trace != NULL) { 75 delete [] m_uncompressed_trace; 76 m_uncompressed_trace = NULL; 77 } --- 78 unchanged lines hidden (view full) --- 156 rec->m_pc_address = pc_addr; 157 rec->m_type = type; 158 memcpy(rec->m_data, data.getData(0, m_block_size_bytes), 159 m_block_size_bytes); 160 161 m_records.push_back(rec); 162} 163 |
164uint64 165CacheRecorder::aggregateRecords(uint8_t** buf, uint64 total_size) |
166{ 167 std::sort(m_records.begin(), m_records.end(), compareTraceRecords); 168 169 int size = m_records.size(); |
170 uint64 current_size = 0; |
171 int record_size = sizeof(TraceRecord) + m_block_size_bytes; 172 173 for (int i = 0; i < size; ++i) { 174 // Determine if we need to expand the buffer size 175 if (current_size + record_size > total_size) { 176 uint8_t* new_buf = new (nothrow) uint8_t[total_size * 2]; 177 if (new_buf == NULL) { 178 fatal("Unable to allocate buffer of size %s\n", --- 20 unchanged lines hidden --- |