aboutsummaryrefslogtreecommitdiffstats
path: root/trace-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace-input.c')
-rw-r--r--trace-input.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/trace-input.c b/trace-input.c
index fed915d..c919cd0 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -1747,6 +1747,36 @@ static int init_cpu(struct tracecmd_input *handle, int cpu)
1747 return 0; 1747 return 0;
1748} 1748}
1749 1749
1750static int handle_options(struct tracecmd_input *handle)
1751{
1752 unsigned short option;
1753 unsigned int size;
1754 char *buf;
1755
1756 do {
1757 if (do_read_check(handle, &option, 2))
1758 return -1;
1759
1760 switch (option) {
1761 case TRACECMD_OPTION_DONE:
1762 break;
1763 default:
1764 warning("unknown option %d", option);
1765 /* next 4 bytes is the size of the option */
1766 if (do_read_check(handle, &size, 4))
1767 return -1;
1768 size = __data2host4(handle->pevent, size);
1769 buf = malloc_or_die(size);
1770 if (do_read_check(handle, buf, size))
1771 return -1;
1772 free(buf);
1773 break;
1774 }
1775 } while (option != TRACECMD_OPTION_DONE);
1776
1777 return 0;
1778}
1779
1750/** 1780/**
1751 * tracecmd_init_data - prepare reading the data from trace.dat 1781 * tracecmd_init_data - prepare reading the data from trace.dat
1752 * @handle: input handle for the trace.dat file 1782 * @handle: input handle for the trace.dat file
@@ -1783,14 +1813,27 @@ int tracecmd_init_data(struct tracecmd_input *handle)
1783 pevent_set_cpus(pevent, handle->cpus); 1813 pevent_set_cpus(pevent, handle->cpus);
1784 pevent_set_long_size(pevent, handle->long_size); 1814 pevent_set_long_size(pevent, handle->long_size);
1785 1815
1816 if (do_read_check(handle, buf, 10))
1817 return -1;
1818
1819 /* check if this handles options */
1820 if (strncmp(buf, "options", 7) == 0) {
1821 if (handle_options(handle) < 0)
1822 return -1;
1823 if (do_read_check(handle, buf, 10))
1824 return -1;
1825 }
1826
1786 /* 1827 /*
1787 * Check if this is a latency report or not. 1828 * Check if this is a latency report or not.
1788 */ 1829 */
1789 if (do_read_check(handle, buf, 10))
1790 return -1;
1791 if (strncmp(buf, "latency", 7) == 0) 1830 if (strncmp(buf, "latency", 7) == 0)
1792 return 1; 1831 return 1;
1793 1832
1833 /* We expect this to be flyrecord */
1834 if (strncmp(buf, "flyrecord", 9) != 0)
1835 return -1;
1836
1794 handle->cpu_data = malloc(sizeof(*handle->cpu_data) * handle->cpus); 1837 handle->cpu_data = malloc(sizeof(*handle->cpu_data) * handle->cpus);
1795 if (!handle->cpu_data) 1838 if (!handle->cpu_data)
1796 return -1; 1839 return -1;