diff options
Diffstat (limited to 'lib/debugobjects.c')
| -rw-r--r-- | lib/debugobjects.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/lib/debugobjects.c b/lib/debugobjects.c index a78b7c6e042c..77cb245f8e7b 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c | |||
| @@ -268,12 +268,16 @@ static void debug_print_object(struct debug_obj *obj, char *msg) | |||
| 268 | * Try to repair the damage, so we have a better chance to get useful | 268 | * Try to repair the damage, so we have a better chance to get useful |
| 269 | * debug output. | 269 | * debug output. |
| 270 | */ | 270 | */ |
| 271 | static void | 271 | static int |
| 272 | debug_object_fixup(int (*fixup)(void *addr, enum debug_obj_state state), | 272 | debug_object_fixup(int (*fixup)(void *addr, enum debug_obj_state state), |
| 273 | void * addr, enum debug_obj_state state) | 273 | void * addr, enum debug_obj_state state) |
| 274 | { | 274 | { |
| 275 | int fixed = 0; | ||
| 276 | |||
| 275 | if (fixup) | 277 | if (fixup) |
| 276 | debug_objects_fixups += fixup(addr, state); | 278 | fixed = fixup(addr, state); |
| 279 | debug_objects_fixups += fixed; | ||
| 280 | return fixed; | ||
| 277 | } | 281 | } |
| 278 | 282 | ||
| 279 | static void debug_object_is_on_stack(void *addr, int onstack) | 283 | static void debug_object_is_on_stack(void *addr, int onstack) |
| @@ -386,6 +390,9 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) | |||
| 386 | struct debug_bucket *db; | 390 | struct debug_bucket *db; |
| 387 | struct debug_obj *obj; | 391 | struct debug_obj *obj; |
| 388 | unsigned long flags; | 392 | unsigned long flags; |
| 393 | struct debug_obj o = { .object = addr, | ||
| 394 | .state = ODEBUG_STATE_NOTAVAILABLE, | ||
| 395 | .descr = descr }; | ||
| 389 | 396 | ||
| 390 | if (!debug_objects_enabled) | 397 | if (!debug_objects_enabled) |
| 391 | return; | 398 | return; |
| @@ -425,8 +432,9 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr) | |||
| 425 | * let the type specific code decide whether this is | 432 | * let the type specific code decide whether this is |
| 426 | * true or not. | 433 | * true or not. |
| 427 | */ | 434 | */ |
| 428 | debug_object_fixup(descr->fixup_activate, addr, | 435 | if (debug_object_fixup(descr->fixup_activate, addr, |
| 429 | ODEBUG_STATE_NOTAVAILABLE); | 436 | ODEBUG_STATE_NOTAVAILABLE)) |
| 437 | debug_print_object(&o, "activate"); | ||
| 430 | } | 438 | } |
| 431 | 439 | ||
| 432 | /** | 440 | /** |
| @@ -563,6 +571,44 @@ out_unlock: | |||
| 563 | } | 571 | } |
| 564 | 572 | ||
| 565 | /** | 573 | /** |
| 574 | * debug_object_assert_init - debug checks when object should be init-ed | ||
| 575 | * @addr: address of the object | ||
| 576 | * @descr: pointer to an object specific debug description structure | ||
| 577 | */ | ||
| 578 | void debug_object_assert_init(void *addr, struct debug_obj_descr *descr) | ||
| 579 | { | ||
| 580 | struct debug_bucket *db; | ||
| 581 | struct debug_obj *obj; | ||
| 582 | unsigned long flags; | ||
| 583 | |||
| 584 | if (!debug_objects_enabled) | ||
| 585 | return; | ||
| 586 | |||
| 587 | db = get_bucket((unsigned long) addr); | ||
| 588 | |||
| 589 | raw_spin_lock_irqsave(&db->lock, flags); | ||
| 590 | |||
| 591 | obj = lookup_object(addr, db); | ||
| 592 | if (!obj) { | ||
| 593 | struct debug_obj o = { .object = addr, | ||
| 594 | .state = ODEBUG_STATE_NOTAVAILABLE, | ||
| 595 | .descr = descr }; | ||
| 596 | |||
| 597 | raw_spin_unlock_irqrestore(&db->lock, flags); | ||
| 598 | /* | ||
| 599 | * Maybe the object is static. Let the type specific | ||
| 600 | * code decide what to do. | ||
| 601 | */ | ||
| 602 | if (debug_object_fixup(descr->fixup_assert_init, addr, | ||
| 603 | ODEBUG_STATE_NOTAVAILABLE)) | ||
| 604 | debug_print_object(&o, "assert_init"); | ||
| 605 | return; | ||
| 606 | } | ||
| 607 | |||
| 608 | raw_spin_unlock_irqrestore(&db->lock, flags); | ||
| 609 | } | ||
| 610 | |||
| 611 | /** | ||
| 566 | * debug_object_active_state - debug checks object usage state machine | 612 | * debug_object_active_state - debug checks object usage state machine |
| 567 | * @addr: address of the object | 613 | * @addr: address of the object |
| 568 | * @descr: pointer to an object specific debug description structure | 614 | * @descr: pointer to an object specific debug description structure |
