header.c (8dc58101f2c838355d44402aa77646649d10dbec) | header.c (2c46dbb517a10b18d459e6ceffefde5bfb290cf6) |
---|---|
1#define _FILE_OFFSET_BITS 64 2 3#include <sys/types.h> 4#include <byteswap.h> 5#include <unistd.h> 6#include <stdio.h> 7#include <stdlib.h> 8#include <linux/list.h> --- 793 unchanged lines hidden (view full) --- 802 for (j = 0; j < attr->ids; j++) { 803 if (attr->id[j] == id) 804 return &attr->attr; 805 } 806 } 807 808 return NULL; 809} | 1#define _FILE_OFFSET_BITS 64 2 3#include <sys/types.h> 4#include <byteswap.h> 5#include <unistd.h> 6#include <stdio.h> 7#include <stdlib.h> 8#include <linux/list.h> --- 793 unchanged lines hidden (view full) --- 802 for (j = 0; j < attr->ids; j++) { 803 if (attr->id[j] == id) 804 return &attr->attr; 805 } 806 } 807 808 return NULL; 809} |
810 811int event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, 812 event__handler_t process, 813 struct perf_session *session) 814{ 815 event_t *ev; 816 size_t size; 817 int err; 818 819 size = sizeof(struct perf_event_attr); 820 size = ALIGN(size, sizeof(u64)); 821 size += sizeof(struct perf_event_header); 822 size += ids * sizeof(u64); 823 824 ev = malloc(size); 825 826 ev->attr.attr = *attr; 827 memcpy(ev->attr.id, id, ids * sizeof(u64)); 828 829 ev->attr.header.type = PERF_RECORD_HEADER_ATTR; 830 ev->attr.header.size = size; 831 832 err = process(ev, session); 833 834 free(ev); 835 836 return err; 837} 838 839int event__synthesize_attrs(struct perf_header *self, 840 event__handler_t process, 841 struct perf_session *session) 842{ 843 struct perf_header_attr *attr; 844 int i, err = 0; 845 846 for (i = 0; i < self->attrs; i++) { 847 attr = self->attr[i]; 848 849 err = event__synthesize_attr(&attr->attr, attr->ids, attr->id, 850 process, session); 851 if (err) { 852 pr_debug("failed to create perf header attribute\n"); 853 return err; 854 } 855 } 856 857 return err; 858} 859 860int event__process_attr(event_t *self, struct perf_session *session) 861{ 862 struct perf_header_attr *attr; 863 unsigned int i, ids, n_ids; 864 865 attr = perf_header_attr__new(&self->attr.attr); 866 if (attr == NULL) 867 return -ENOMEM; 868 869 ids = self->header.size; 870 ids -= (void *)&self->attr.id - (void *)self; 871 n_ids = ids / sizeof(u64); 872 873 for (i = 0; i < n_ids; i++) { 874 if (perf_header_attr__add_id(attr, self->attr.id[i]) < 0) { 875 perf_header_attr__delete(attr); 876 return -ENOMEM; 877 } 878 } 879 880 if (perf_header__add_attr(&session->header, attr) < 0) { 881 perf_header_attr__delete(attr); 882 return -ENOMEM; 883 } 884 885 perf_session__update_sample_type(session); 886 887 return 0; 888} |
|