svn commit: r212994 - head/sys/kern

Andriy Gapon avg at FreeBSD.org
Wed Sep 22 06:45:08 UTC 2010


Author: avg
Date: Wed Sep 22 06:45:07 2010
New Revision: 212994
URL: http://svn.freebsd.org/changeset/base/212994

Log:
  kdb_backtrace: use stack_print_ddb instead of stack_print
  
  This is a followup to r212964.
  stack_print call chain obtains linker sx lock and thus potentially may
  lead to a deadlock depending on a kind of a panic.
  stack_print_ddb doesn't acquire any locks and it doesn't use any
  facilities of ddb backend.
  Using stack_print_ddb outside of DDB ifdef required taking a number of
  helper functions from under it as well.
  
  It is a good idea to rename linker_ddb_* and stack_*_ddb functions to
  have 'unlocked' component in their name instead of 'ddb', because those
  functions do not use any DDB services, but instead they provide unlocked
  access to linker symbol information.  The latter was previously needed
  only for DDB, hence the 'ddb' name component.
  
  Alternative is to ditch unlocked versions altogether after implementing
  proper panic handling:
  1. stop other cpus upon a panic
  2. make all non-spinlock lock operations (mutex, sx, rwlock) be a no-op
     when panicstr != NULL
  
  Suggested by:	mdf
  Discussed with:	attilio
  MFC after:	2 weeks

Modified:
  head/sys/kern/kern_linker.c
  head/sys/kern/subr_kdb.c
  head/sys/kern/subr_stack.c

Modified: head/sys/kern/kern_linker.c
==============================================================================
--- head/sys/kern/kern_linker.c	Wed Sep 22 06:10:22 2010	(r212993)
+++ head/sys/kern/kern_linker.c	Wed Sep 22 06:45:07 2010	(r212994)
@@ -924,7 +924,6 @@ linker_debug_search_symbol_name(caddr_t 
 	return (0);
 }
 
-#ifdef DDB
 /*
  * DDB Helpers.  DDB has to look across multiple files with their own symbol
  * tables and string tables.
@@ -933,12 +932,14 @@ linker_debug_search_symbol_name(caddr_t 
  * DDB to hang because somebody's got the lock held.  We'll take the chance
  * that the files list is inconsistant instead.
  */
+#ifdef DDB
 int
 linker_ddb_lookup(const char *symstr, c_linker_sym_t *sym)
 {
 
 	return (linker_debug_lookup(symstr, sym));
 }
+#endif
 
 int
 linker_ddb_search_symbol(caddr_t value, c_linker_sym_t *sym, long *diffp)
@@ -961,7 +962,6 @@ linker_ddb_search_symbol_name(caddr_t va
 
 	return (linker_debug_search_symbol_name(value, buf, buflen, offset));
 }
-#endif
 
 /*
  * stack(9) helper for non-debugging environemnts.  Unlike DDB helpers, we do

Modified: head/sys/kern/subr_kdb.c
==============================================================================
--- head/sys/kern/subr_kdb.c	Wed Sep 22 06:10:22 2010	(r212993)
+++ head/sys/kern/subr_kdb.c	Wed Sep 22 06:45:07 2010	(r212994)
@@ -308,7 +308,7 @@ kdb_backtrace(void)
 
 		printf("KDB: stack backtrace:\n");
 		stack_save(&st);
-		stack_print(&st);
+		stack_print_ddb(&st);
 	}
 #endif
 }

Modified: head/sys/kern/subr_stack.c
==============================================================================
--- head/sys/kern/subr_stack.c	Wed Sep 22 06:10:22 2010	(r212993)
+++ head/sys/kern/subr_stack.c	Wed Sep 22 06:45:07 2010	(r212994)
@@ -44,9 +44,7 @@ static MALLOC_DEFINE(M_STACK, "stack", "
 
 static int stack_symbol(vm_offset_t pc, char *namebuf, u_int buflen,
 	    long *offset);
-#ifdef DDB
 static int stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset);
-#endif
 
 struct stack *
 stack_create(void)
@@ -125,7 +123,6 @@ stack_print_short(struct stack *st)
 	printf("\n");
 }
 
-#ifdef DDB
 void
 stack_print_ddb(struct stack *st)
 {
@@ -141,6 +138,7 @@ stack_print_ddb(struct stack *st)
 	}
 }
 
+#ifdef DDB
 void
 stack_print_short_ddb(struct stack *st)
 {
@@ -255,7 +253,6 @@ stack_symbol(vm_offset_t pc, char *nameb
 		return (0);
 }
 
-#ifdef DDB
 static int
 stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset)
 {
@@ -275,4 +272,3 @@ stack_symbol_ddb(vm_offset_t pc, const c
 	*name = "??";
 	return (ENOENT);
 }
-#endif


More information about the svn-src-head mailing list