• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <stdio.h>
18 
19 #include "perfetto/base/logging.h"
20 #include "perfetto/ext/base/file_utils.h"
21 #include "perfetto/ext/base/scoped_file.h"
22 #include "perfetto/ext/base/string_splitter.h"
23 #include "perfetto/ext/base/utils.h"
24 #include "perfetto/trace_processor/trace_processor.h"
25 #include "src/profiling/deobfuscator.h"
26 #include "tools/trace_to_text/deobfuscate_profile.h"
27 #include "tools/trace_to_text/utils.h"
28 
29 namespace perfetto {
30 namespace trace_to_text {
31 
DeobfuscateProfile(std::istream * input,std::ostream * output)32 int DeobfuscateProfile(std::istream* input, std::ostream* output) {
33   base::ignore_result(input);
34   base::ignore_result(output);
35   auto maybe_map = profiling::GetPerfettoProguardMapPath();
36   if (maybe_map.empty()) {
37     PERFETTO_ELOG("No PERFETTO_PROGUARD_MAP specified.");
38     return 1;
39   }
40   if (!profiling::ReadProguardMapsToDeobfuscationPackets(
41           maybe_map, [output](const std::string& trace_proto) {
42             *output << trace_proto;
43           })) {
44     return 1;
45   }
46 
47   return 0;
48 }
49 
50 }  // namespace trace_to_text
51 }  // namespace perfetto
52