summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--ddb/db_sym.c29
-rw-r--r--ddb/db_sym.h46
-rw-r--r--i386/i386/db_trace.c10
-rw-r--r--kern/lock_mon.c2
5 files changed, 89 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 0fc49c7..92ade83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,21 @@
return the breakpoint in non-ddb case.
* ddb/db_break.h (BKPT_EXTERNAL): New macro.
(db_set_breakpoint): Add declaration.
+ * (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.
2008-07-15 Barry deFreese <bddebian@comcast.net>
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
diff --git a/i386/i386/db_trace.c b/i386/i386/db_trace.c
index aad305c..c4019b5 100644
--- a/i386/i386/db_trace.c
+++ b/i386/i386/db_trace.c
@@ -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 --git a/kern/lock_mon.c b/kern/lock_mon.c
index a9a3989..0d69ac1 100644
--- a/kern/lock_mon.c
+++ b/kern/lock_mon.c
@@ -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 {