summaryrefslogtreecommitdiff
path: root/compiler/enco/core/src/Support/Debugging.h
blob: c28356e760304f0f7217c0497fdb390ab26af155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file  Debugging.h
 * @brief This file includes various interactive debugging helpers
 */

#ifndef __ENCO_SUPPORT_DEBUGGING_H__
#define __ENCO_SUPPORT_DEBUGGING_H__

#include <coco/IR.h>

static_assert(sizeof(long) == sizeof(void *), "sizeof(long) == sizeof(pointer)");

/**
 * Debugging API with a single pointer argument
 */
#define DEBUGGING_API_P(NAME, TYPE) \
  void NAME(const TYPE *);          \
  void NAME(long);

/**
 * Print the details of all the allocated coco::Bag in coco::Module
 *
 * (gdb) call enco_dump_all_bags(bag->module())
 * (gdb) call enco_dump_all_bags(0x...)
 */
DEBUGGING_API_P(enco_dump_all_bags, coco::Module);

/**
 * Print the details of all the allocated coco::Object in coco::Module
 *
 * (gdb) call enco_dump_all_objects(obj->module())
 * (gdb) call enco_dump_all_objects(0x...)
 */
DEBUGGING_API_P(enco_dump_all_objects, coco::Module);

/**
 * Print the details of coco::Op
 *
 * (gdb) call enco_dump_op(op)
 * (gdb) call enco_dump_op(0x....)
 */
DEBUGGING_API_P(enco_dump_op, coco::Op);

/**
 * Print the (simplified) tree layout of coco::Op
 *
 * (gdb) call enco_dump_op_tree(op)
 * (gdb) call enco_dump_op_tree(0x....)
 */
DEBUGGING_API_P(enco_dump_op_tree, coco::Op);

/**
 * Print the details of all the allocated coco::Op in coco::Module
 *
 * (gdb) call enco_dump_all_ops(op->module())
 * (gdb) call enco_dump_all_ops(0x....)
 */
DEBUGGING_API_P(enco_dump_all_ops, coco::Module);

/**
 * Print the details of all the allocated coco::Instr in coco::Module
 *
 * (gdb) call enco_dump_all_instrs(instr->module())
 * (gdb) call enco_dump_all_instrs(0x...)
 */
DEBUGGING_API_P(enco_dump_all_instrs, coco::Module);

/**
 * Print the more details of all the allocated coco::Instr in coco::Module
 *
 * (gdb) call enco_dump_all_instrs_v(instr->module())
 * (gdb) call enco_dump_all_instrs_v(0x...)
 */
DEBUGGING_API_P(enco_dump_all_instrs_v, coco::Module);

/**
 * Print the details of a given coco::Instr
 *
 * (gdb) call enco_dump_instr(instr)
 * (gdb) call enco_dump_instr(0x...)
 */
DEBUGGING_API_P(enco_dump_instr, coco::Instr);

/**
 * Print the details of all the instruction in a given block
 *
 * (gdb) call enco_dump_block(b)
 * (gdb) call enco_dump_block(0x...)
 */
DEBUGGING_API_P(enco_dump_block, coco::Block);

#undef DEBUGGING_API_P

#endif // __ENCO_SUPPORT_DEBUGGING_H__