1 /* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; version 2 of the License.
6 
7    This program is distributed in the hope that it will be useful,
8    but WITHOUT ANY WARRANTY; without even the implied warranty of
9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10    GNU General Public License for more details.
11 
12    You should have received a copy of the GNU General Public License
13    along with this program; if not, write to the Free Software
14    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
15 
16 #ifndef DEBUG_LOCK_ORDER_H
17 #define DEBUG_LOCK_ORDER_H
18 
19 #include "my_sys.h"
20 
21 struct PSI_bootstrap;
22 
23 struct LO_node_properties {
24   const char *m_name;
25   const char *m_operation;
26   int m_flags;
27 };
28 
29 struct LO_authorised_arc {
30   char *m_from_name;
31   char *m_from_state;
32   char *m_to_name;
33   bool m_op_recursive;
34   char *m_to_operation;
35   int m_flags;
36   char *m_constraint;
37   char *m_comment;
38 };
39 
40 #define LO_FLAG_TRACE 1 << 0
41 #define LO_FLAG_DEBUG 1 << 1
42 #define LO_FLAG_LOOP 1 << 2
43 #define LO_FLAG_IGNORED 1 << 3
44 #define LO_FLAG_BIND 1 << 4
45 #define LO_FLAG_UNFAIR 1 << 5
46 /* Micro arcs, generated from macro declarations. */
47 #define LO_FLAG_MICRO 1 << 6
48 
49 struct LO_global_param {
50   bool m_enabled;
51   char *m_out_dir;
52   char *m_dependencies_1;
53   char *m_dependencies_2;
54   bool m_print_txt;
55   bool m_trace_loop;
56   bool m_debug_loop;
57   bool m_trace_missing_arc;
58   bool m_debug_missing_arc;
59   bool m_trace_missing_unlock;
60   bool m_debug_missing_unlock;
61   bool m_trace_bad_unlock;
62   bool m_debug_bad_unlock;
63   bool m_trace_missing_key;
64   bool m_debug_missing_key;
65 };
66 
67 extern LO_global_param lo_param;
68 
69 int LO_init(
70     struct LO_global_param *param, PSI_thread_bootstrap **thread_bootstrap,
71     PSI_mutex_bootstrap **mutex_bootstrap,
72     PSI_rwlock_bootstrap **rwlock_bootstrap,
73     PSI_cond_bootstrap **cond_bootstrap, PSI_file_bootstrap **file_bootstrap,
74     PSI_socket_bootstrap **socket_bootstrap,
75     PSI_table_bootstrap **table_bootstrap, PSI_mdl_bootstrap **mdl_bootstrap,
76     PSI_idle_bootstrap **idle_bootstrap, PSI_stage_bootstrap **stage_bootstrap,
77     PSI_statement_bootstrap **statement_bootstrap,
78     PSI_transaction_bootstrap **transaction_bootstrap,
79     PSI_memory_bootstrap **memory_bootstrap);
80 
81 void LO_activate();
82 
83 class LO_graph;
84 void LO_add_authorised_arc(LO_graph *g, const LO_authorised_arc *arc);
85 void LO_add_node_properties(LO_graph *g, const LO_node_properties *node);
86 
87 void LO_dump();
88 
89 void LO_cleanup();
90 
91 /*
92   Helper for the performance schema.
93 */
94 PSI_thread *LO_get_chain_thread(PSI_thread *psi);
95 
96 #endif
97