aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-24 23:26:44 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-09-24 23:26:44 -0400
commitc52d7ab471d62b32836617fce06c0946d08ecb09 (patch)
tree812ac53de825715de689cc0f10cc87ec23bbb61b /src
parent00de6faa7cf1a9e95d738b204f570dd7123e738e (diff)
display information about struct timestamp
Diffstat (limited to 'src')
-rw-r--r--src/ftdump.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/ftdump.c b/src/ftdump.c
index 849d6ee..2871537 100644
--- a/src/ftdump.c
+++ b/src/ftdump.c
@@ -12,7 +12,7 @@ static void dump(struct timestamp* ts, size_t count)
12 struct timestamp *x; 12 struct timestamp *x;
13 while (count--) { 13 while (count--) {
14 x = ts++; 14 x = ts++;
15 printf("event:%d seq:%u cpu:%d type:%d\n", 15 printf("event:%d seq:%u cpu:%d type:%d\n",
16 (int) x->event, x->seq_no, x->cpu, x->task_type); 16 (int) x->event, x->seq_no, x->cpu, x->task_type);
17 } 17 }
18} 18}
@@ -21,15 +21,31 @@ static void die(char* msg)
21{ 21{
22 if (errno) 22 if (errno)
23 perror("error: "); 23 perror("error: ");
24 fprintf(stderr, "%s\n", msg); 24 fprintf(stderr, "%s\n", msg);
25 exit(1); 25 exit(1);
26} 26}
27 27
28int main(int argc, char** argv) 28#define offset(type, member) ((unsigned int) &((type *) 0)->member)
29
30int main(int argc, char** argv)
29{ 31{
30 void* mapped; 32 void* mapped;
31 size_t size, count; 33 size_t size, count;
32 struct timestamp* ts; 34 struct timestamp* ts;
35
36 printf("struct timestamp:\n"
37 "\t size = %3lu\n"
38 "\t offset(timestamp) = %3u\n"
39 "\t offset(seq_no) = %3u\n"
40 "\t offset(cpu) = %3u\n"
41 "\t offset(event) = %3u\n"
42 "\t offset(task_type) = %3u\n",
43 sizeof(struct timestamp),
44 offset(struct timestamp, timestamp),
45 offset(struct timestamp, seq_no),
46 offset(struct timestamp, cpu),
47 offset(struct timestamp, event),
48 offset(struct timestamp, task_type));
33 49
34 if (argc != 2) 50 if (argc != 2)
35 die("Usage: ftdump <logfile>"); 51 die("Usage: ftdump <logfile>");
@@ -37,7 +53,7 @@ int main(int argc, char** argv)
37 die("could not map file"); 53 die("could not map file");
38 54
39 ts = (struct timestamp*) mapped; 55 ts = (struct timestamp*) mapped;
40 count = size / sizeof(struct timestamp); 56 count = size / sizeof(struct timestamp);
41 57
42 dump(ts, count); 58 dump(ts, count);
43 return 0; 59 return 0;