Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: tools/ipc_fuzzer/ipclist/ipclist.cc

Issue 1025483002: Restructure the ipc_fuzzer directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move more files around Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/ipc_fuzzer/ipclist/DEPS ('k') | tools/ipc_fuzzer/ipclist/ipclist.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <algorithm>
6 #include <iostream>
7 #include <string>
8 #include <vector>
9
10 #include "base/basictypes.h"
11
12 // Include once to get the type definitions
13 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
14
15 struct msginfo {
16 const char* name;
17 const char* file;
18 int id;
19 int in_count;
20 int out_count;
21
22 bool operator< (const msginfo& other) const {
23 return id < other.id;
24 }
25 };
26
27 // Redefine macros to generate table
28 #include "ipc/ipc_message_null_macros.h"
29 #undef IPC_MESSAGE_DECL
30 #define IPC_MESSAGE_DECL(kind, type, name, in, out, ilist, olist) \
31 { #name, __FILE__, IPC_MESSAGE_ID(), in, out },
32
33 static msginfo msgtable[] = {
34 #include "tools/ipc_fuzzer/message_lib/all_messages.h"
35 };
36 #define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0]))
37 static_assert(MSGTABLE_SIZE, "check your headers for an extra semicolon");
38
39 static bool check_msgtable() {
40 bool result = true;
41 int previous_class_id = 0;
42 int highest_class_id = 0;
43 const char* file_name = "NONE";
44 const char* previous_file_name = "NONE";
45 std::vector<int> exemptions;
46
47 // Exclude test and other non-browser files from consideration. Do not
48 // include message files used inside the actual chrome browser in this list.
49 exemptions.push_back(TestMsgStart);
50 exemptions.push_back(FirefoxImporterUnittestMsgStart);
51 exemptions.push_back(ShellMsgStart);
52 exemptions.push_back(LayoutTestMsgStart);
53 exemptions.push_back(MetroViewerMsgStart);
54 exemptions.push_back(CCMsgStart); // Nothing but param traits.
55 exemptions.push_back(CldDataProviderMsgStart); // Conditional build.
56
57 // Sent from browser to renderer.
58 exemptions.push_back(WebCacheMsgStart);
59
60 #if defined(DISABLE_NACL)
61 exemptions.push_back(NaClMsgStart);
62 #endif // defined(DISABLE_NACL)
63
64 #if !defined(OS_ANDROID)
65 exemptions.push_back(JavaBridgeMsgStart);
66 exemptions.push_back(MediaPlayerMsgStart);
67 exemptions.push_back(EncryptedMediaMsgStart);
68 exemptions.push_back(GinJavaBridgeMsgStart);
69 exemptions.push_back(AndroidWebViewMsgStart);
70 #endif // !defined(OS_ANDROID)
71
72 #if !defined(OS_POSIX)
73 exemptions.push_back(CastMediaMsgStart); // FIXME: Add support for types.
74 #endif // !defined(OS_POSIX)
75
76 #if !defined(USE_OZONE)
77 exemptions.push_back(OzoneGpuMsgStart);
78 #endif // !defined(USE_OZONE)
79
80 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {
81 int class_id = IPC_MESSAGE_ID_CLASS(msgtable[i].id);
82 file_name = msgtable[i].file;
83 if (class_id >= LastIPCMsgStart) {
84 std::cout << "Invalid LastIPCMsgStart setting\n";
85 result = false;
86 }
87 if (class_id == previous_class_id &&
88 strcmp(file_name, previous_file_name) != 0) {
89 std::cerr << "enum used in multiple files: "
90 << file_name << " vs "
91 << previous_file_name << "\n";
92 result = false;
93 }
94 while (class_id > previous_class_id + 1) {
95 std::vector<int>::iterator iter;
96 iter = find(exemptions.begin(), exemptions.end(), previous_class_id + 1);
97 if (iter == exemptions.end()) {
98 std::cout << "Missing message file for enum "
99 << class_id - (previous_class_id + 1)
100 << " before enum used by " << file_name << "\n";
101 result = false;
102 }
103 ++previous_class_id;
104 }
105 previous_class_id = class_id;
106 previous_file_name = file_name;
107 if (class_id > highest_class_id)
108 highest_class_id = class_id;
109 }
110
111 while (LastIPCMsgStart > highest_class_id + 1) {
112 std::vector<int>::iterator iter;
113 iter = find(exemptions.begin(), exemptions.end(), highest_class_id+1);
114 if (iter == exemptions.end()) {
115 std::cout << "Missing message file for enum "
116 << LastIPCMsgStart - (highest_class_id + 1)
117 << " before enum LastIPCMsgStart\n";
118 break;
119 }
120 ++highest_class_id;
121 }
122
123 if (!result)
124 std::cout << "Please check tools/ipc_fuzzer/message_lib/all_messages.h\n";
125
126 return result;
127 }
128
129 static void dump_msgtable(bool show_args, bool show_ids,
130 bool show_comma, const char *prefix) {
131 bool first = true;
132 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {
133 if ((!prefix) || strstr(msgtable[i].name, prefix) == msgtable[i].name) {
134 if (show_comma) {
135 if (!first)
136 std::cout << ",";
137 first = false;
138 std::cout << msgtable[i].id;
139 } else {
140 if (show_ids)
141 std::cout << msgtable[i].id << " " <<
142 IPC_MESSAGE_ID_CLASS(msgtable[i].id) << "," <<
143 IPC_MESSAGE_ID_LINE(msgtable[i].id) << " ";
144 std::cout << msgtable[i].name;
145 if (show_args) {
146 std::cout << "(" << msgtable[i].in_count << " IN, " <<
147 msgtable[i].out_count << " OUT)";
148 }
149 std::cout << "\n";
150 }
151 }
152 }
153 if (show_comma)
154 std::cout << "\n";
155 }
156
157 int main(int argc, char **argv) {
158 bool show_args = false;
159 bool show_ids = false;
160 bool skip_check = false;
161 bool show_comma = false;
162 const char *filter = NULL;
163
164 while (--argc > 0) {
165 ++argv;
166 if (std::string("--args") == *argv) {
167 show_args = true;
168 } else if (std::string("--comma") == *argv) {
169 show_comma = true;
170 } else if (std::string("--filter") == *argv) {
171 filter = *(++argv);
172 --argc;
173 } else if (std::string("--ids") == *argv) {
174 show_ids = true;
175 } else if (std::string("--no-check") == *argv) {
176 skip_check = true;
177 } else {
178 std::cout <<
179 "usage: ipclist [--args] [--ids] [--no-check] [--filter prefix] "
180 "[--comma]\n";
181 return 1;
182 }
183 }
184
185 std::sort(msgtable, msgtable + MSGTABLE_SIZE);
186
187 if (!skip_check && check_msgtable() == false)
188 return 1;
189
190 dump_msgtable(show_args, show_ids, show_comma, filter);
191 return 0;
192 }
193
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/ipclist/DEPS ('k') | tools/ipc_fuzzer/ipclist/ipclist.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698