diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2008-07-18 21:57:32 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-06-18 00:27:17 +0200 |
commit | f08d1e37cc4e72f93b1fe08b19012869f0370ecc (patch) | |
tree | d128b67f91d5c3699949b66d465c3e8b236edaf5 /ddb | |
parent | 4df0f89aa4f32b12aab06d81d6ce91a12a64553e (diff) |
2008-07-18 Andrei Barbu <andrei@0xab.com>
* (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.
Diffstat (limited to 'ddb')
-rw-r--r-- | ddb/db_sym.c | 29 | ||||
-rw-r--r-- | ddb/db_sym.h | 46 |
2 files changed, 66 insertions, 9 deletions
diff --git a/ddb/db_sym.c b/ddb/db_sym.c index 5f8a0f4..dd72138 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 */ diff --git a/ddb/db_sym.h b/ddb/db_sym.h index 453ac7f..e40264a 100644 --- a/ddb/db_sym.h +++ b/ddb/db_sym.h @@ -28,6 +28,9 @@ * Date: 8/90 */ +#ifndef _DDB_DB_SYM_H_ +#define _DDB_DB_SYM_H_ + #include <mach/boolean.h> #include <mach/machine/vm_types.h> #include <machine/db_machdep.h> @@ -115,22 +118,43 @@ extern void db_symbol_values( db_symtab_t *stab, /* find name&value given approx val */ #define db_find_sym_and_offset(val,namep,offp) \ - db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0) + do { \ + db_sym_t s; \ + db_symbol_values(0, s = db_search_symbol(val,DB_STGY_ANY,offp) \ + ,namep,0); \ + db_free_symbol(s); \ + } while(0); + /* ditto, but no locals */ #define db_find_xtrn_sym_and_offset(val,namep,offp) \ - db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) + do { \ + db_sym_t s; \ + db_symbol_values(0, s = db_search_symbol(val,DB_STGY_XTRN,offp) \ + ,namep,0); \ + db_free_symbol(s); \ + } while(0); /* find name&value given approx val */ #define db_find_task_sym_and_offset(val,namep,offp,task) \ - db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \ - namep, 0) + do { \ + db_sym_t s; \ + db_symbol_values(0, s = db_search_task_symbol(val,DB_STGY_ANY \ + ,offp,task), \ + namep, 0); \ + db_free_symbol(s); \ + } while(0); /* ditto, but no locals */ #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \ - db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \ - namep,0) + do { \ + db_sym_t s; \ + db_symbol_values(0, s = db_search_task_symbol(val,DB_STGY_XTRN \ + ,offp,task), \ + namep,0); \ + db_free_symbol(s); \ + } while(0); /* find symbol in current task */ #define db_search_symbol(val,strgy,offp) \ @@ -147,6 +171,10 @@ extern void db_task_printsym( db_expr_t off, /* print closest symbol to a value */ extern void db_printsym( db_expr_t off, db_strategy_t strategy); +/* free a symbol */ +extern void db_free_symbol(db_sym_t s); + + /* * Symbol table switch, defines the interface * to symbol-table specific routines. @@ -187,6 +215,9 @@ extern struct db_sym_switch { db_expr_t *valuep ); + void (*free_symbol)( + db_sym_t sym + ); } x_db[]; #ifndef symtab_type @@ -198,9 +229,12 @@ extern struct db_sym_switch { #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d) #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a) #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(s,p,n,v) +#define X_db_free_symbol(s,m) x_db[(s)->type].free_symbol(m) extern boolean_t db_line_at_pc( db_sym_t sym, char **filename, int *linenum, db_expr_t pc); + +#endif |