1 // Copyright 2020 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 //============================================================================== 15 // BUID 16 // ninja -C out 17 // host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_basic 18 // 19 // RUN 20 // .out/host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_basic 21 // trace.bin 22 // 23 // DECODE 24 // python pw_trace_tokenized/py/trace_tokenized.py -i trace.bin -o trace.json 25 // ./out/host_clang_debug/obj/pw_trace_tokenized/bin/trace_tokenized_example_basic 26 // 27 // VIEW 28 // In chrome navigate to chrome://tracing, and load the trace.json file. 29 30 #include "pw_log/log.h" 31 #include "pw_trace/example/sample_app.h" 32 #include "pw_trace_tokenized/example/trace_to_file.h" 33 main(int argc,char ** argv)34int main(int argc, char** argv) { // Take filename as arg 35 if (argc != 2) { 36 PW_LOG_ERROR("Expected output file name as argument.\n"); 37 return -1; 38 } 39 40 // Enable tracing. 41 PW_TRACE_SET_ENABLED(true); 42 43 // Dump trace data to the file passed in. 44 pw::trace::TraceToFile trace_to_file(argv[1]); 45 46 PW_LOG_INFO("Running basic trace example...\n"); 47 RunTraceSampleApp(); 48 return 0; 49 }