• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://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,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LIBLLVMBACKEND_LOWERING_DEBUG_DATA_BUILDER_H
17 #define LIBLLVMBACKEND_LOWERING_DEBUG_DATA_BUILDER_H
18 
19 #include <string>
20 #include <memory>
21 #include "libpandabase/macros.h"
22 
23 namespace llvm {
24 class Function;
25 class DIBuilder;
26 class DICompileUnit;
27 class Instruction;
28 class Module;
29 }  // namespace llvm
30 
31 namespace ark::llvmbackend {
32 
33 class DebugDataBuilder final {
34 public:
35     explicit DebugDataBuilder(llvm::Module *module, const std::string &filename);
36 
37     void BeginSubprogram(llvm::Function *function, const std::string &filename, uint32_t line);
38     void EndSubprogram(llvm::Function *function);
39 
40     void SetLocation(llvm::Instruction *inst, uint32_t line, uint32_t column = 1);
41 
42     void AppendInlinedAt(llvm::Instruction *inst, llvm::Function *function, uint32_t line, uint32_t column = 1);
43 
44     void Finalize();
45 
46     ~DebugDataBuilder();
47 
48     NO_COPY_SEMANTIC(DebugDataBuilder);
49     NO_MOVE_SEMANTIC(DebugDataBuilder);
50 
51 private:
52     llvm::DIBuilder *builder_;
53 };
54 
55 }  // namespace ark::llvmbackend
56 
57 #endif  // LIBLLVMBACKEND_LOWERING_DEBUG_DATA_BUILDER_H
58