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
|
From bdc9b8583e6336bb3a44a80f10bac8b7b369719c Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Sat, 15 Aug 2015 16:43:24 +0200
Subject: [PATCH gnumach 1/4] kern: disable the simple lock checks while
debugging
* kern/lock.c (do_check_simple_locks): New variable.
(check_simple_locks): Make check conditional.
(check_simple_locks_{en,dis}able): New functions.
* kern/lock.h (check_simple_locks_{en,dis}able): New declarations.
* ddb/db_trap.c (db_task_trap): Disable simple lock checks.
---
ddb/db_trap.c | 4 ++++
kern/lock.c | 14 +++++++++++++-
kern/lock.h | 6 ++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/ddb/db_trap.c b/ddb/db_trap.c
index 7e10731..cbb6bde 100644
--- a/ddb/db_trap.c
+++ b/ddb/db_trap.c
@@ -45,6 +45,7 @@
#include <ddb/db_trap.h>
#include <ddb/db_run.h>
#include <machine/db_interface.h>
+#include <kern/lock.h>
extern jmp_buf_t *db_recover;
@@ -65,6 +66,8 @@ db_task_trap(
boolean_t watchpt;
task_t task_space;
+ check_simple_locks_disable();
+
task_space = db_target_space(current_thread(), user_space);
bkpt = IS_BREAKPOINT_TRAP(type, code);
watchpt = IS_WATCHPOINT_TRAP(type, code);
@@ -97,6 +100,7 @@ db_task_trap(
db_command_loop();
}
+ check_simple_locks_enable();
db_restart_at_pc(watchpt, task_space);
}
diff --git a/kern/lock.c b/kern/lock.c
index 3c74fec..d894b06 100644
--- a/kern/lock.c
+++ b/kern/lock.c
@@ -136,9 +136,21 @@ struct simple_locks_info {
void *ra;
} simple_locks_info[NSLINFO];
+int do_check_simple_locks = 1;
+
void check_simple_locks(void)
{
- assert(simple_locks_taken == 0);
+ assert(! do_check_simple_locks || simple_locks_taken == 0);
+}
+
+void check_simple_locks_enable(void)
+{
+ do_check_simple_locks = 1;
+}
+
+void check_simple_locks_disable(void)
+{
+ do_check_simple_locks = 0;
}
/* Need simple lock sanity checking code if simple locks are being
diff --git a/kern/lock.h b/kern/lock.h
index 435ee1d..0eba0ad 100644
--- a/kern/lock.h
+++ b/kern/lock.h
@@ -81,6 +81,8 @@ class simple_lock_data_t name;
#define simple_lock_taken(lock) (simple_lock_assert(lock), \
1) /* always succeeds */
#define check_simple_locks()
+#define check_simple_locks_enable()
+#define check_simple_locks_disable()
#else /* NCPUS > 1 */
/*
@@ -97,6 +99,8 @@ extern boolean_t simple_lock_try(simple_lock_t);
(lock)->lock_data)
extern void check_simple_locks(void);
+extern void check_simple_locks_enable(void);
+extern void check_simple_locks_disable(void);
#endif /* NCPUS > 1 */
@@ -121,6 +125,8 @@ class struct simple_lock_data_empty name;
#define simple_lock_taken(l) (simple_lock_assert(l), \
1) /* always succeeds */
#define check_simple_locks()
+#define check_simple_locks_enable()
+#define check_simple_locks_disable()
#define simple_lock_pause()
#endif /* MACH_SLOCKS */
--
2.1.4
|