From f08d1e37cc4e72f93b1fe08b19012869f0370ecc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 18 Jul 2008 21:57:32 +0000 Subject: 2008-07-18 Andrei Barbu * (ddb/db_sym.h): Add _DDB_DB_SYM_H_ header protection. (db_find_sym_and_offset, db_find_xtrn_sym_and_offset, db_find_task_sym_and_offset, db_find_xtrn_task_sym_and_offset): Call db_free_symbol. (db_free_symbol): New declaration. (db_sym_switch): New `free_symbol' member. (X_db_free_symbol): New macro. * ddb/db_sym.c (db_value_of_name, db_lookup, db_name_is_ambiguous, db_search_task_symbol, db_search_in_task_symbol, db_task_printsym): Call db_free_symbol. (db_free_symbol): New function. (dummy_db_free_symbol): New empty function. (x_db): Initialize `free_symbol' memberi with dummy_db_free_symbol. * i386/i386/db_trace.c (db_i386_stack_trace): Call db_free_symbol. * kern/lock_mon.c (print_lock_info): Likewise. --- ddb/db_sym.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'ddb/db_sym.c') diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 5f8a0f4d..dd721384 100644 --- a/ddb/db_sym.c +++ b/ddb/db_sym.c @@ -129,6 +129,8 @@ db_value_of_name(name, valuep) if (sym == DB_SYM_NULL) return (FALSE); db_symbol_values(0, sym, &name, valuep); + + db_free_symbol(sym); return (TRUE); } @@ -177,6 +179,7 @@ db_lookup(symstr) db_last_symtab = &db_symtabs[i]; return sp; } + db_free_symbol(sp); } return 0; } @@ -273,11 +276,16 @@ db_name_is_ambiguous(sym_name) return FALSE; for (i = 0; i < db_nsymtab; i++) { - if (X_db_lookup(&db_symtabs[i], sym_name)) { + db_sym_t sp; + if (sp = X_db_lookup(&db_symtabs[i], sym_name)) { if (found_once) + { + db_free_symbol(sp); return TRUE; + } found_once = TRUE; } + db_free_symbol(sp); } return FALSE; } @@ -316,6 +324,7 @@ db_search_task_symbol(val, strategy, offp, task) */ if (ret == DB_SYM_NULL || (*offp) > 0x1000000) { + db_free_symbol(ret); task = db_current_task(); ret = db_search_in_task_symbol(val, strategy, offp, task); } @@ -354,6 +363,7 @@ db_search_in_task_symbol(val, strategy, offp, task) { /* first hit */ db_last_symtab = sp; diff = newdiff; + db_free_symbol(ret); ret = sym; continue; } @@ -363,6 +373,7 @@ db_search_in_task_symbol(val, strategy, offp, task) { /* closer null map match */ db_last_symtab = sp; diff = newdiff; + db_free_symbol(ret); ret = sym; continue; } @@ -376,6 +387,7 @@ db_search_in_task_symbol(val, strategy, offp, task) */ db_last_symtab = sp; diff = newdiff; + db_free_symbol(ret); ret = sym; continue; } @@ -452,6 +464,7 @@ db_task_printsym(off, strategy, task) db_symbol_values(0, cursym, &name, &value); if (name == 0 || d >= db_maxoff || value == 0 || *name == 0) { db_printf("%#n", off); + db_free_symbol(cursym); return; } db_printf("%s", name); @@ -465,6 +478,7 @@ db_task_printsym(off, strategy, task) db_printf("]"); } } + db_free_symbol(cursym); } void @@ -487,6 +501,13 @@ db_line_at_pc( sym, filename, linenum, pc) FALSE; } +void db_free_symbol(db_sym_t s) +{ + return (db_last_symtab) ? + X_db_free_symbol( db_last_symtab, s) : + FALSE; +} + /* * Switch into symbol-table specific routines */ @@ -499,6 +520,8 @@ extern boolean_t coff_db_sym_init(), coff_db_line_at_pc(); extern db_sym_t coff_db_lookup(), coff_db_search_symbol(); extern void coff_db_symbol_values(); +void dummy_db_free_symbol(sym_t) { } + struct db_sym_switch x_db[] = { /* BSD a.out format (really, sdb/dbx(1) symtabs) */ @@ -506,14 +529,14 @@ struct db_sym_switch x_db[] = { { 0,}, #else /* DB_NO_AOUT */ { aout_db_sym_init, aout_db_lookup, aout_db_search_symbol, - aout_db_line_at_pc, aout_db_symbol_values }, + aout_db_line_at_pc, aout_db_symbol_values, dummy_db_free_symbol }, #endif /* DB_NO_AOUT */ #ifdef DB_NO_COFF { 0,}, #else /* DB_NO_COFF */ { coff_db_sym_init, coff_db_lookup, coff_db_search_symbol, - coff_db_line_at_pc, coff_db_symbol_values }, + coff_db_line_at_pc, coff_db_symbol_values, dummy_db_free_symbol }, #endif /* DB_NO_COFF */ /* Machdep, not inited here */ -- cgit v1.2.3