diff options
Diffstat (limited to 'testcode/checklocks.c')
| -rw-r--r-- | testcode/checklocks.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/testcode/checklocks.c b/testcode/checklocks.c index d1c877467307..fdc1b8af16de 100644 --- a/testcode/checklocks.c +++ b/testcode/checklocks.c @@ -68,6 +68,8 @@ static struct thr_check* thread_infos[THRDEBUG_MAX_THREADS]; int check_locking_order = 1; /** the pid of this runset, reasonably unique. */ static pid_t check_lock_pid; +/** the name of the output file */ +static const char* output_name = "ublocktrace"; /** * Should checklocks print a trace of the lock and unlock calls. * It uses fprintf for that because the log function uses a lock and that @@ -142,7 +144,8 @@ acquire_locklock(struct checked_lock* lock, /** add protected region */ void -lock_protect(void *p, void* area, size_t size) +lock_protect_place(void* p, void* area, size_t size, const char* def_func, + const char* def_file, int def_line, const char* def_area) { struct checked_lock* lock = *(struct checked_lock**)p; struct protected_area* e = (struct protected_area*)malloc( @@ -151,6 +154,10 @@ lock_protect(void *p, void* area, size_t size) fatal_exit("lock_protect: out of memory"); e->region = area; e->size = size; + e->def_func = def_func; + e->def_file = def_file; + e->def_line = def_line; + e->def_area = def_area; e->hold = malloc(size); if(!e->hold) fatal_exit("lock_protect: out of memory"); @@ -203,6 +210,9 @@ prot_check(struct checked_lock* lock, if(memcmp(p->hold, p->region, p->size) != 0) { log_hex("memory prev", p->hold, p->size); log_hex("memory here", p->region, p->size); + log_err("lock_protect on %s %s:%d %s failed", + p->def_func, p->def_file, p->def_line, + p->def_area); lock_error(lock, func, file, line, "protected area modified"); } @@ -675,13 +685,19 @@ checklock_unlock(enum check_lock_type type, struct checked_lock* lock, } } +void +checklock_set_output_name(const char* name) +{ + output_name = name; +} + /** open order info debug file, thr->num must be valid */ static void open_lockorder(struct thr_check* thr) { char buf[24]; time_t t; - snprintf(buf, sizeof(buf), "ublocktrace.%d", thr->num); + snprintf(buf, sizeof(buf), "%s.%d", output_name, thr->num); thr->order_info = fopen(buf, "w"); if(!thr->order_info) fatal_exit("could not open %s: %s", buf, strerror(errno)); |
