• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  // Copyright 2006 The Android Open Source Project
2  
3  #ifndef GTRACE_H
4  #define GTRACE_H
5  
6  class Gtrace {
7   public:
8    static const int kGtraceEntriesPerBlock = 1024;
9    static const uint32_t kMillion = 1000000;
10    static const uint32_t kTicsPerSecond = 200 * kMillion;
11    static const int kBaseTic = 0x1000;
12  
13    struct trace_entry {
14      uint32_t	cycle;
15      uint32_t	event;
16    };
17  
18    struct block_header {
19      uint32_t	blockno;
20      uint32_t	entry_width;
21      uint32_t	block_tic;
22      uint32_t	block_time;
23      uint32_t	usec_cpu;
24      uint32_t	pid;
25      uint32_t	bug_count;
26      uint32_t	zero_count;
27    };
28  
29    struct first_header {
30      block_header	common;
31      uint32_t		tic;
32      uint32_t		one;
33      uint32_t		tics_per_second;
34      uint32_t		trace_time;
35      uint32_t		version;
36      uint32_t		file_proc;
37      uint32_t		pdate;
38      uint32_t		ptime;
39    };
40  
41    Gtrace();
42    ~Gtrace();
43  
44    void		Open(const char *gtrace_file, uint32_t pdate, uint32_t ptime);
45    void		WriteFirstHeader(uint32_t start_sec, uint32_t pid);
46    void		AddProcedure(int filenum, int procnum, const char *proc_name);
47    void		AddProcEntry(int filenum, int procnum, uint32_t cycle, uint32_t pid);
48    void		AddProcExit(int filenum, int procnum, uint32_t cycle, uint32_t pid);
49  
50   private:
51    void		AddGtraceRecord(int filenum, int procnum, uint32_t cycle, uint32_t pid,
52                                  int is_exit);
53    void		FillFirstHeader(uint32_t start_sec, uint32_t pid,
54                                  first_header *fh);
55    void		WriteBlockHeader(uint32_t cycle, uint32_t pid);
56  
57    const char	*gtrace_file_;
58    char		gname_file_[100];
59    FILE		*ftrace_;
60    FILE		*fnames_;
61    uint32_t	start_sec_;
62    uint32_t	pdate_;
63    uint32_t	ptime_;
64    int		num_entries_;
65    int		blockno_;
66    uint32_t	current_pid_;
67  };
68  
69  #endif  // GTRACE_H
70