| 88 | }; |
| 89 | |
| 90 | static int |
| 91 | command(int argc, char *argv[]) |
| 92 | { |
| 93 | bool flagDumpFrames = false; |
| 94 | int opt; |
| 95 | while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) { |
| 96 | switch (opt) { |
| 97 | case 'h': |
| 98 | usage(); |
| 99 | return 0; |
| 100 | case DUMP_FRAMES_OPT: |
| 101 | flagDumpFrames = true; |
| 102 | break; |
| 103 | default: |
| 104 | std::cerr << "error: unexpected option `" << (char)opt << "`\n"; |
| 105 | usage(); |
| 106 | return 1; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | typedef std::vector<FrameEntry> FrameEntries; |
| 111 | FrameEntries frames; |
| 112 | |
| 113 | for (int i = optind; i < argc; ++i) { |
| 114 | unsigned long framesCount = 0; |
| 115 | trace::API api = trace::API_UNKNOWN; |
| 116 | trace::Parser p; |
| 117 | |
| 118 | if (!p.open(argv[i])) { |
| 119 | return 1; |
| 120 | } |
| 121 | |
| 122 | trace::Call *call; |
| 123 | size_t callsInFrame = 0; |
| 124 | size_t firstCallId = 0; |
| 125 | size_t frameBytesOffset = 0; |
| 126 | bool endFrame = true; |
| 127 | while ((call = p.parse_call())) { |
| 128 | if (flagDumpFrames) { |
| 129 | ++callsInFrame; |
| 130 | if (endFrame) { |
| 131 | firstCallId = call->no; |
| 132 | endFrame = false; |
| 133 | } |
| 134 | } |
| 135 | if (api == trace::API_UNKNOWN && p.api != trace::API_UNKNOWN) |
| 136 | api = p.api; |
| 137 | if (call->flags & trace::CALL_FLAG_END_FRAME) { |
| 138 | ++framesCount; |
| 139 | if (flagDumpFrames) { |
| 140 | size_t curBytesOffset = p.dataBytesRead(); |
| 141 | frames.push_back( |
| 142 | FrameEntry { |
| 143 | firstCallId, |
| 144 | call->no, |
| 145 | callsInFrame, |
| 146 | curBytesOffset-frameBytesOffset |
| 147 | } |
nothing calls this directly
no test coverage detected