From 347cb29151859a56a6c5f0f355a43033e5e035a5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 15 Aug 2015 17:04:08 +0200 Subject: kern: improve simple lock debugging Do not bother saving the return address when acquire a simple lock. Save the location as provided by the compiler as string instead. Also save the lock parameter. * kern/lock.c (struct simple_locks_info): Drop `ra', add `expr', `loc'. (simple_lock): Rename to `_simple_lock', add expression and location parameters and save them. (simple_lock_try): Likewise. (simple_unlock): Zero-out the now unused slot in the list of taken locks. (db_show_all_slocks): Use the new information. * kern/lock.h (simple_lock, simple_lock_try): Provide macro versions passing the location and expression as string. --- kern/lock.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'kern/lock.h') diff --git a/kern/lock.h b/kern/lock.h index 0eba0ad1..e88e1824 100644 --- a/kern/lock.h +++ b/kern/lock.h @@ -90,9 +90,20 @@ class simple_lock_data_t name; */ extern void simple_lock_init(simple_lock_t); -extern void simple_lock(simple_lock_t); +extern void _simple_lock(simple_lock_t, + const char *, const char *); extern void simple_unlock(simple_lock_t); -extern boolean_t simple_lock_try(simple_lock_t); +extern boolean_t _simple_lock_try(simple_lock_t, + const char *, const char *); + +/* We provide simple_lock and simple_lock_try so that we can save the + location. */ +#define XSTR(x) #x +#define STR(x) XSTR(x) +#define LOCATION __FILE__ ":" STR(__LINE__) + +#define simple_lock(lock) _simple_lock((lock), #lock, LOCATION) +#define simple_lock_try(lock) _simple_lock_try((lock), #lock, LOCATION) #define simple_lock_pause() #define simple_lock_taken(lock) (simple_lock_assert(lock), \ -- cgit v1.2.3