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

Unified Diff: chrome/tools/ipclist/ipclist.cc

Issue 6711024: Example of how to interpose yourself in a message stream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/tools/ipclist/ipclist.cc
===================================================================
--- chrome/tools/ipclist/ipclist.cc (revision 83739)
+++ chrome/tools/ipclist/ipclist.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -75,36 +75,57 @@
return result;
}
-static void dump_msgtable(bool show_args, bool show_ids) {
+static void dump_msgtable(bool show_args, bool show_ids,
+ bool show_comma, const char *prefix) {
+ bool first = true;
for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {
- if (show_ids) {
- std::cout << "{" << IPC_MESSAGE_ID_CLASS(msgtable[i].id) << ", " <<
- IPC_MESSAGE_ID_LINE(msgtable[i].id) << "}: ";
+ if ((!prefix) || strstr(msgtable[i].name, prefix) == msgtable[i].name) {
+ if (show_comma) {
+ if (!first)
+ std::cout << ",";
+ first = false;
+ std::cout << msgtable[i].id;
+ } else {
+ if (show_ids)
+ std::cout << msgtable[i].id << " " <<
+ IPC_MESSAGE_ID_CLASS(msgtable[i].id) << "," <<
+ IPC_MESSAGE_ID_LINE(msgtable[i].id) << " ";
+ std::cout << msgtable[i].name;
+ if (show_args) {
+ std::cout << "(" << msgtable[i].in_count << " IN, " <<
+ msgtable[i].out_count << " OUT)";
+ }
+ std::cout << "\n";
+ }
}
- std::cout << msgtable[i].name;
- if (show_args) {
- std::cout << "(" << msgtable[i].in_count << " IN, " <<
- msgtable[i].out_count << " OUT)";
- }
+ }
+ if (show_comma)
std::cout << "\n";
- }
}
int main(int argc, char **argv) {
bool show_args = false;
bool show_ids = false;
bool skip_check = false;
+ bool show_comma = false;
+ const char *filter = NULL;
while (--argc > 0) {
++argv;
if (std::string("--args") == *argv) {
show_args = true;
+ } else if (std::string("--comma") == *argv) {
+ show_comma = true;
+ } else if (std::string("--filter") == *argv) {
+ filter = *(++argv); --argc;
} else if (std::string("--ids") == *argv) {
show_ids = true;
} else if (std::string("--no-check") == *argv) {
skip_check = true;
} else {
- std::cout << "usage: ipclist [--args] [--ids] [--no-check]\n";
+ std::cout <<
+ "usage: ipclist [--args] [--ids] [--no-check] [--filter prefix] "
+ "[--comma]\n";
return 1;
}
}
@@ -114,7 +135,7 @@
if (!skip_check && check_msgtable() == false)
return 1;
- dump_msgtable(show_args, show_ids);
+ dump_msgtable(show_args, show_ids, show_comma, filter);
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698