Ejemplo n.º 1
0
static void emit_user_trace64(struct perf_record *pr,
							  struct perfconv_context *cctx)
{
	struct proftype_user_trace64 *rec = (struct proftype_user_trace64 *)
		pr->data;
	size_t size = sizeof(struct perf_record_sample) +
		(rec->num_traces - 1) * sizeof(uint64_t);
	struct perf_record_sample *xrec = xzmalloc(size);

	xrec->header.type = PERF_RECORD_SAMPLE;
	xrec->header.misc = PERF_RECORD_MISC_USER;
	xrec->header.size = size;
	xrec->ip = rec->trace[0];
	xrec->pid = xrec->tid = rec->pid;
	xrec->time = rec->tstamp;
	xrec->addr = rec->trace[0];
	xrec->id = perfconv_get_event_id(cctx, rec->info);
	xrec->cpu = rec->cpu;
	xrec->nr = rec->num_traces - 1;
	memcpy(xrec->ips, rec->trace + 1, (rec->num_traces - 1) * sizeof(uint64_t));

	mem_file_write(&cctx->data, xrec, size, 0);

	free(xrec);
}
Ejemplo n.º 2
0
/**@brief Function for processing ANTFS upload data event.
 * 
 * @param[in] p_event The event extracted from the queue to be processed.
 */
static void event_upload_data_handle(const antfs_event_return_t * p_event)
{
    // This example does not interact with a file system, and it does not account for latency for 
    // reading or writing a file from EEPROM/flash. Buffering and other strategies might be useful 
    // to handle a received upload, while maintaining the burst timing.             
    if (m_upload_success && (m_file_index == p_event->file_index)) 
    {
        // Offset requested for upload. 
        const uint32_t offset     = p_event->offset;    
        // Size of current block of data.        
        const uint32_t data_bytes = p_event->bytes;     

        // Write data to file.
        if (!mem_file_write(m_file_index, offset, p_event->data, data_bytes))    
        {
            // Failed to write the data to system; do not attempt to write any more data after this, 
            // and set upload response as FAIL. 
            m_upload_success = false;     
            printf("Failed to write file to system\n");
            printf("Current offset %u, ", offset);
        }
        else
        {
            // Data was written successfully:
            // - update offset
            // - update current CRC.
            m_file_offset = offset + data_bytes;    
            m_current_crc = p_event->crc;           
        }
    }
}
Ejemplo n.º 3
0
static int mem_file_putchar(MXFFileSysData *sysData, int c)
{
    unsigned char data = (unsigned char)c;
    if (mem_file_write(sysData, &data, 1) == 0)
        return EOF;

    return c;
}
Ejemplo n.º 4
0
static void add_attribute(struct mem_file *amf, struct mem_file *mmf,
						  const struct perf_event_attr *attr,
						  const uint64_t *ids, size_t nids)
{
	struct perf_file_section *psids;
	struct perf_file_section sids;

	mem_file_write(amf, attr, sizeof(*attr), 0);

	sids.offset = mmf->size;
	sids.size = nids * sizeof(uint64_t);

	mem_file_write(mmf, ids, nids * sizeof(uint64_t), 0);

	psids = mem_file_write(amf, &sids, sizeof(sids), MBWR_SOLID);

	mem_file_add_reloc(amf, &psids->offset);
}
Ejemplo n.º 5
0
static void add_event_type(struct mem_file *mf, uint64_t id, const char *name)
{
	struct perf_trace_event_type evt;

	ZERO_DATA(evt);
	evt.event_id = id;
	strncpy(evt.name, name, sizeof(evt.name));
	evt.name[sizeof(evt.name) - 1] = 0;

	mem_file_write(mf, &evt, sizeof(evt), 0);
}
Ejemplo n.º 6
0
static void headers_write(struct perf_headers *hdrs, struct perf_header *ph,
						  struct mem_file *mf)
{
	size_t i;

	for (i = 0; i < HEADER_FEAT_BITS; i++) {
		struct mem_block *mb = hdrs->headers[i];

		if (mb) {
			mem_file_write(mf, mb->base, mb->wptr - mb->base, 0);
			set_bitno(ph->adds_features, i);
		}
	}
}
Ejemplo n.º 7
0
static void emit_comm(uint32_t pid, const char *comm,
					  struct perfconv_context *cctx)
{
	size_t size = sizeof(struct perf_record_comm) + strlen(comm) + 1;
	struct perf_record_comm *xrec = xzmalloc(size);

	xrec->header.type = PERF_RECORD_COMM;
	xrec->header.misc = PERF_RECORD_MISC_USER;
	xrec->header.size = size;
	xrec->pid = xrec->tid = pid;
	strcpy(xrec->comm, comm);

	mem_file_write(&cctx->data, xrec, size, 0);

	free(xrec);
}
Ejemplo n.º 8
0
static void emit_pid_mmap64(struct perf_record *pr,
							struct perfconv_context *cctx)
{
	struct proftype_pid_mmap64 *rec = (struct proftype_pid_mmap64 *) pr->data;
	size_t size = sizeof(struct perf_record_mmap) + strlen(rec->path) + 1;
	struct perf_record_mmap *xrec = xzmalloc(size);

	xrec->header.type = PERF_RECORD_MMAP;
	xrec->header.misc = PERF_RECORD_MISC_USER;
	xrec->header.size = size;
	xrec->pid = xrec->tid = rec->pid;
	xrec->addr = rec->addr;
	xrec->len = rec->size;
	xrec->pgoff = rec->offset;
	strcpy(xrec->filename, rec->path);

	mem_file_write(&cctx->data, xrec, size, 0);

	free(xrec);
}
Ejemplo n.º 9
0
static void emit_static_mmaps(struct perfconv_context *cctx)
{
	struct static_mmap64 *mm;

	for (mm = cctx->static_mmaps; mm; mm = mm->next) {
		size_t size = sizeof(struct perf_record_mmap) + strlen(mm->path) + 1;
		struct perf_record_mmap *xrec = xzmalloc(size);

		xrec->header.type = PERF_RECORD_MMAP;
		xrec->header.misc = PERF_RECORD_MISC_USER;
		xrec->header.size = size;
		xrec->pid = xrec->tid = mm->pid;
		xrec->addr = mm->addr;
		xrec->len = mm->size;
		xrec->pgoff = mm->offset;
		strcpy(xrec->filename, mm->path);

		mem_file_write(&cctx->data, xrec, size, 0);

		free(xrec);
	}
}