1 /* 2 * Copyright (C) 2017 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 #pragma once 18 19 #include "common.h" 20 #include "code_ir.h" 21 #include "dex_ir.h" 22 #include "buffer.h" 23 #include "chronometer.h" 24 25 #include <vector> 26 27 namespace lir { 28 29 // Generates debug info from code IR 30 class DebugInfoEncoder : public Visitor { 31 private: 32 virtual bool Visit(DbgInfoHeader* dbg_header) override; 33 virtual bool Visit(DbgInfoAnnotation* dbg_annotation) override; 34 35 public: DebugInfoEncoder(const InstructionsList & instructions)36 explicit DebugInfoEncoder(const InstructionsList& instructions) 37 : instructions_(instructions) { 38 } 39 40 ~DebugInfoEncoder() = default; 41 42 void Encode(ir::EncodedMethod* ir_method, std::shared_ptr<ir::DexFile> dex_ir); 43 44 private: 45 std::vector<ir::String*>* param_names_ = nullptr; 46 dex::u4 line_start_ = 0; 47 dex::u4 last_line_ = 0; 48 dex::u4 last_address_ = 0; 49 ir::String* source_file_ = nullptr; 50 slicer::Buffer dbginfo_; 51 const InstructionsList& instructions_; 52 }; 53 54 } // namespace lir 55 56