aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-15 15:19:34 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-15 15:19:34 -0500
commit23d149bde3a1020cf8d10da7255d080d0cf7355f (patch)
tree77e34557c0d9c524f426acee1f4e08418a3931a1
parent9231ed7a6e9cdf5c91cc8b36484555307e93629f (diff)
Comment the tracecmd_input functions
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-input.c125
1 files changed, 124 insertions, 1 deletions
diff --git a/trace-input.c b/trace-input.c
index 3cd6387..3889f66 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -410,6 +410,14 @@ static int read_ftrace_printk(struct tracecmd_input *handle)
410 return 0; 410 return 0;
411} 411}
412 412
413/**
414 * tracecmd_read_headers - read the header information from trace.dat
415 * @handle: input handle for the trace.dat file
416 *
417 * This reads the trace.dat file for various information. Like the
418 * format of the ring buffer, event formats, ftrace formats, kallsyms
419 * and printk.
420 */
413int tracecmd_read_headers(struct tracecmd_input *handle) 421int tracecmd_read_headers(struct tracecmd_input *handle)
414{ 422{
415 struct pevent *pevent = handle->pevent; 423 struct pevent *pevent = handle->pevent;
@@ -769,7 +777,19 @@ find_and_read_event(struct tracecmd_input *handle, unsigned long long offset,
769 return read_event(handle, offset, cpu); 777 return read_event(handle, offset, cpu);
770} 778}
771 779
772 780/**
781 * tracecmd_read_at - read a record from a specific offset
782 * @handle: input handle for the trace.dat file
783 * @offset: the offset into the file to find the record
784 * @pcpu: pointer to a variable to store the CPU id the record was found in
785 *
786 * This function is useful when looking for a previous record.
787 * You can store the offset of the record "record->offset" and use that
788 * offset to retreive the record again without needing to store any
789 * other information about the record.
790 *
791 * The record returned must be freed.
792 */
773struct record * 793struct record *
774tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset, 794tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset,
775 int *pcpu) 795 int *pcpu)
@@ -793,6 +813,15 @@ tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset,
793 return find_and_read_event(handle, offset, pcpu); 813 return find_and_read_event(handle, offset, pcpu);
794} 814}
795 815
816/**
817 * tracecmd_read_cpu_first - get the first record in a CPU
818 * @handle: input handle for the trace.dat file
819 * @cpu: the CPU to search
820 *
821 * This returns the first (by time) record entry in a given CPU.
822 *
823 * The record returned must be freed.
824 */
796struct record * 825struct record *
797tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu) 826tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu)
798{ 827{
@@ -801,6 +830,15 @@ tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu)
801 return tracecmd_read_data(handle, cpu); 830 return tracecmd_read_data(handle, cpu);
802} 831}
803 832
833/**
834 * tracecmd_read_cpu_last - get the last record in a CPU
835 * @handle: input handle for the trace.dat file
836 * @cpu: the CPU to search
837 *
838 * This returns the last (by time) record entry in a given CPU.
839 *
840 * The record returned must be freed.
841 */
804struct record * 842struct record *
805tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu) 843tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu)
806{ 844{
@@ -826,6 +864,21 @@ tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu)
826 return tracecmd_read_at(handle, offset, NULL); 864 return tracecmd_read_at(handle, offset, NULL);
827} 865}
828 866
867/**
868 * tracecmd_set_cpu_to_timestamp - set the CPU iterator to a given time
869 * @handle: input handle for the trace.dat file
870 * @cpu: the CPU pointer to set
871 * @ts: the timestamp to set the CPU at.
872 *
873 * This sets the CPU iterator used by tracecmd_read_data and
874 * tracecmd_peek_data to a location in the CPU storage near
875 * a given timestamp. It will try to set the iterator to a time before
876 * the time stamp and not actually at a given time.
877 *
878 * To use this to find a record in a time field, call this function
879 * first, than iterate with tracecmd_read_data to find the records
880 * you need.
881 */
829int 882int
830tracecmd_set_cpu_to_timestamp(struct tracecmd_input *handle, int cpu, 883tracecmd_set_cpu_to_timestamp(struct tracecmd_input *handle, int cpu,
831 unsigned long long ts) 884 unsigned long long ts)
@@ -946,6 +999,22 @@ translate_data(struct tracecmd_input *handle,
946 return type_len; 999 return type_len;
947} 1000}
948 1001
1002/**
1003 * tracecmd_translate_data - create a record from raw data
1004 * @handle: input handle for the trace.dat file
1005 * @ptr: raw data to read
1006 * @size: the size of the data
1007 *
1008 * This function tries to create a record from some given
1009 * raw data. The data does not need to be from the trace.dat file.
1010 * It can be stored from another location.
1011 *
1012 * Note, since the timestamp is calculated from within the trace
1013 * buffer, the timestamp for the record will be zero, since it
1014 * can't calculate it.
1015 *
1016 * The record returned must be freed.
1017 */
949struct record * 1018struct record *
950tracecmd_translate_data(struct tracecmd_input *handle, 1019tracecmd_translate_data(struct tracecmd_input *handle,
951 void *ptr, int size) 1020 void *ptr, int size)
@@ -977,6 +1046,16 @@ tracecmd_translate_data(struct tracecmd_input *handle,
977 return data; 1046 return data;
978} 1047}
979 1048
1049/**
1050 * tracecmd_peek_data - return the record at the current location.
1051 * @handle: input handle for the trace.dat file
1052 * @cpu: the CPU to pull from
1053 *
1054 * This returns the record at the current location of the CPU
1055 * iterator. It does not increment the CPU iterator.
1056 *
1057 * The record returned must be freed.
1058 */
980struct record * 1059struct record *
981tracecmd_peek_data(struct tracecmd_input *handle, int cpu) 1060tracecmd_peek_data(struct tracecmd_input *handle, int cpu)
982{ 1061{
@@ -1061,6 +1140,16 @@ read_again:
1061 return data; 1140 return data;
1062} 1141}
1063 1142
1143/**
1144 * tracecmd_read_data - read the next record and increment
1145 * @handle: input handle for the trace.dat file
1146 * @cpu: the CPU to pull from
1147 *
1148 * This returns the record at the current location of the CPU
1149 * iterator and increments the CPU iterator.
1150 *
1151 * The record returned must be freed.
1152 */
1064struct record * 1153struct record *
1065tracecmd_read_data(struct tracecmd_input *handle, int cpu) 1154tracecmd_read_data(struct tracecmd_input *handle, int cpu)
1066{ 1155{
@@ -1136,6 +1225,13 @@ static int init_cpu(struct tracecmd_input *handle, int cpu)
1136 return 0; 1225 return 0;
1137} 1226}
1138 1227
1228/**
1229 * tracecmd_init_data - prepare reading the data from trace.dat
1230 * @handle: input handle for the trace.dat file
1231 *
1232 * This prepares reading the data from trace.dat. This is called
1233 * after tracecmd_read_headers() and before tracecmd_read_data().
1234 */
1139int tracecmd_init_data(struct tracecmd_input *handle) 1235int tracecmd_init_data(struct tracecmd_input *handle)
1140{ 1236{
1141 struct pevent *pevent = handle->pevent; 1237 struct pevent *pevent = handle->pevent;
@@ -1195,6 +1291,13 @@ int tracecmd_init_data(struct tracecmd_input *handle)
1195 return 0; 1291 return 0;
1196} 1292}
1197 1293
1294/**
1295 * tracecmd_print_events - print the events that are stored in trace.dat
1296 * @handle: input handle for the trace.dat file
1297 *
1298 * This is a debugging routine to print out the events that
1299 * are stored in a given trace.dat file.
1300 */
1198void tracecmd_print_events(struct tracecmd_input *handle) 1301void tracecmd_print_events(struct tracecmd_input *handle)
1199{ 1302{
1200 int ret; 1303 int ret;
@@ -1211,6 +1314,10 @@ void tracecmd_print_events(struct tracecmd_input *handle)
1211 return; 1314 return;
1212} 1315}
1213 1316
1317/**
1318 * tracecmd_open - create a tracecmd_handle from the trace.dat file descriptor
1319 * @fd: the file descriptor for the trace.dat file
1320 */
1214struct tracecmd_input *tracecmd_open(int fd) 1321struct tracecmd_input *tracecmd_open(int fd)
1215{ 1322{
1216 struct tracecmd_input *handle; 1323 struct tracecmd_input *handle;
@@ -1268,21 +1375,37 @@ struct tracecmd_input *tracecmd_open(int fd)
1268 return NULL; 1375 return NULL;
1269} 1376}
1270 1377
1378/**
1379 * tracecmd_long_size - return the size of "long" for the arch
1380 * @handle: input handle for the trace.dat file
1381 */
1271int tracecmd_long_size(struct tracecmd_input *handle) 1382int tracecmd_long_size(struct tracecmd_input *handle)
1272{ 1383{
1273 return handle->long_size; 1384 return handle->long_size;
1274} 1385}
1275 1386
1387/**
1388 * tracecmd_page_size - return the PAGE_SIZE for the arch
1389 * @handle: input handle for the trace.dat file
1390 */
1276int tracecmd_page_size(struct tracecmd_input *handle) 1391int tracecmd_page_size(struct tracecmd_input *handle)
1277{ 1392{
1278 return handle->page_size; 1393 return handle->page_size;
1279} 1394}
1280 1395
1396/**
1397 * tracecmd_page_size - return the number of CPUs recorded
1398 * @handle: input handle for the trace.dat file
1399 */
1281int tracecmd_cpus(struct tracecmd_input *handle) 1400int tracecmd_cpus(struct tracecmd_input *handle)
1282{ 1401{
1283 return handle->cpus; 1402 return handle->cpus;
1284} 1403}
1285 1404
1405/**
1406 * tracecmd_get_pevent - return the pevent handle
1407 * @handle: input handle for the trace.dat file
1408 */
1286struct pevent *tracecmd_get_pevent(struct tracecmd_input *handle) 1409struct pevent *tracecmd_get_pevent(struct tracecmd_input *handle)
1287{ 1410{
1288 return handle->pevent; 1411 return handle->pevent;