diff -rN -p -u old-gnumach/ddb/db_sym.c new-gnumach-1/ddb/db_sym.c --- old-gnumach/ddb/db_sym.c 2008-07-18 10:38:01.000000000 -0400 +++ new-gnumach-1/ddb/db_sym.c 2008-07-18 10:38:02.000000000 -0400 @@ -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 +178,7 @@ db_lookup(symstr) db_last_symtab = &db_symtabs[i]; return sp; } + db_free_symbol(sp); } return 0; } @@ -273,11 +275,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 +323,7 @@ db_search_task_symbol(val, strategy, off */ 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 +362,7 @@ db_search_in_task_symbol(val, strategy, { /* first hit */ db_last_symtab = sp; diff = newdiff; + db_free_symbol(ret); ret = sym; continue; } @@ -363,6 +372,7 @@ db_search_in_task_symbol(val, strategy, { /* closer null map match */ db_last_symtab = sp; diff = newdiff; + db_free_symbol(ret); ret = sym; continue; } @@ -376,6 +386,7 @@ db_search_in_task_symbol(val, strategy, */ db_last_symtab = sp; diff = newdiff; + db_free_symbol(ret); ret = sym; continue; } @@ -453,6 +464,7 @@ db_task_printsym(off, strategy, task) if (name == 0 || d >= db_maxoff || value == 0 || *name == 0) { db_printf("%#n", off); + db_free_symbol(cursym); return; } db_printf("%s", name); @@ -466,6 +478,7 @@ db_task_printsym(off, strategy, task) db_printf("]"); } } + db_free_symbol(cursym); } void @@ -488,6 +501,13 @@ db_line_at_pc( sym, filename, linenum, p 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 */ @@ -500,6 +520,8 @@ extern boolean_t coff_db_sym_init(), cof 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) */ @@ -507,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 -rN -p -u old-gnumach/ddb/db_sym.h new-gnumach-1/ddb/db_sym.h --- old-gnumach/ddb/db_sym.h 2008-07-18 10:38:01.000000000 -0400 +++ new-gnumach-1/ddb/db_sym.h 2008-07-18 10:38:02.000000000 -0400 @@ -28,6 +28,9 @@ * Date: 8/90 */ +#ifndef _DDB_DB_SYM_H_ +#define _DDB_DB_SYM_H_ + #include #include #include @@ -115,22 +118,43 @@ extern void db_symbol_values( db_symtab_ /* 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 /* 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 diff -rN -p -u old-gnumach/i386/i386/db_trace.c new-gnumach-1/i386/i386/db_trace.c --- old-gnumach/i386/i386/db_trace.c 2008-07-18 10:38:01.000000000 -0400 +++ new-gnumach-1/i386/i386/db_trace.c 2008-07-18 10:38:02.000000000 -0400 @@ -452,10 +452,14 @@ db_i386_stack_trace( if (INKERNEL((unsigned)callpc) && user_frame == 0) { db_addr_t call_func = 0; - db_symbol_values(0, db_search_task_symbol(callpc, - DB_STGY_XTRN, (db_addr_t *)&offset, - TASK_NULL), + db_sym_t sym_tmp; + db_symbol_values(0, + sym_tmp = db_search_task_symbol(callpc, + DB_STGY_XTRN, + (db_addr_t *)&offset, + TASK_NULL), &name, (db_expr_t *)&call_func); + db_free_symbol(sym_tmp); if ((db_user_trap_symbol_value && call_func == db_user_trap_symbol_value) || (db_kernel_trap_symbol_value && call_func == db_kernel_trap_symbol_value)) { frame_type = TRAP; diff -rN -p -u old-gnumach/kern/lock_mon.c new-gnumach-1/kern/lock_mon.c --- old-gnumach/kern/lock_mon.c 2008-07-18 10:38:01.000000000 -0400 +++ new-gnumach-1/kern/lock_mon.c 2008-07-18 10:38:02.000000000 -0400 @@ -281,7 +281,7 @@ struct lock_info *li; li->masked, (li->masked*100)/sum, li->stack, li->stack/sum, li->time, li->time/sum); - db_search_symbol(li->lock, 0, &off); + db_free_symbol(db_search_symbol(li->lock, 0, &off)); if (off < 1024) db_printsym(li->lock, 0); else {