diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-08-16 06:13:04 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-08-16 06:13:04 +0000 |
commit | e5f3198a5ad2032891a5108cc9f2f6594a1f43db (patch) | |
tree | 3e1d256342be2b2c7146eb008bf70d92e67db665 /sys/ddb | |
parent | ebfc1657f16fe79a581980efa54dc71cc903cfd5 (diff) |
add symtab list public iterator.
Diffstat (limited to 'sys/ddb')
-rw-r--r-- | sys/ddb/db_sym.c | 32 | ||||
-rw-r--r-- | sys/ddb/db_sym.h | 5 |
2 files changed, 25 insertions, 12 deletions
diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c index f2e8cf6d23a..19d2ff493c2 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_sym.c,v 1.13 1996/08/13 00:41:34 niklas Exp $ */ +/* $OpenBSD: db_sym.c,v 1.14 1996/08/16 06:13:02 mickey Exp $ */ /* $NetBSD: db_sym.c,v 1.12 1996/02/05 01:57:15 christos Exp $ */ /* @@ -77,6 +77,7 @@ db_add_symbol_table(start, end, name, ref) new->end = end; new->name = name; new->private = ref; + new->id = db_nsymtabs; TAILQ_INSERT_TAIL(&db_symtabs, new, list); return ++db_nsymtabs; @@ -89,9 +90,9 @@ void db_del_symbol_table(name) char *name; { - db_symtab_t p; + register db_symtab_t p; - for (p = db_symtabs.tqh_first; p != NULL; p = p->list.tqe_next) + for (p = db_symiter(NULL); p != NULL; p = db_symiter(p)) if (!strcmp(name, p->name)) break; @@ -111,12 +112,23 @@ db_istab(i) { register db_symtab_t p; - for (p = db_symtabs.tqh_first; i && p != NULL ; p = p->list.tqe_next) + for (p = db_symiter(NULL); i && p != NULL ; p = db_symiter(p)) i--; return i? NULL : p; } +db_symtab_t +db_symiter(st) + db_symtab_t st; +{ + if (st == NULL) + st = db_symtabs.tqh_first; + else + st = st->list.tqe_next; + return st; +} + /* * db_qualify("vm_map", "bsd") returns "bsd:vm_map". * @@ -191,9 +203,9 @@ db_lookup(symstr) for (cp = symstr; *cp; cp++) if (*cp == ':') { *cp = '\0'; - for (st = db_symtabs.tqh_first; + for (st = db_symiter(NULL); st != NULL; - st = st->list.tqe_next) + st = db_symiter(st)) if (!strcmp(symstr, st->name)) break; *cp = ':'; @@ -211,9 +223,7 @@ db_lookup(symstr) if (st != NULL) sp = X_db_lookup(st, symstr); else - for (st = db_symtabs.tqh_first; - st != NULL; - st = st->list.tqe_next) + for (st = db_symiter(NULL); st != NULL; st = db_symiter(st)) if ((sp = X_db_lookup(st, symstr)) != NULL) break; @@ -242,7 +252,7 @@ db_symbol_is_ambiguous(sym) return FALSE; db_symbol_values(sym, &sym_name, 0); - for (st = db_symtabs.tqh_first; st != NULL; st = st->list.tqe_next) { + for (st = db_symiter(NULL); st != NULL; st = db_symiter(st)) { if (X_db_lookup(st, sym_name) != NULL) { if (found_once) return TRUE; @@ -270,7 +280,7 @@ db_search_symbol( val, strategy, offp) newdiff = diff = -1; db_last_symtab = 0; - for (st = db_symtabs.tqh_first; st != NULL; st = st->list.tqe_next) { + for (st = db_symiter(NULL); st != NULL; st = db_symiter(st)) { sym = X_db_search_symbol(st, val, strategy, &newdiff); if (newdiff < diff || diff < 0) { db_last_symtab = st; diff --git a/sys/ddb/db_sym.h b/sys/ddb/db_sym.h index 9091c38a72c..5fb6ffebe58 100644 --- a/sys/ddb/db_sym.h +++ b/sys/ddb/db_sym.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_sym.h,v 1.7 1996/05/11 07:44:43 niklas Exp $ */ +/* $OpenBSD: db_sym.h,v 1.8 1996/08/16 06:13:03 mickey Exp $ */ /* $NetBSD: db_sym.h,v 1.7 1996/02/05 01:57:16 christos Exp $ */ /* @@ -42,6 +42,7 @@ typedef struct db_symtab { TAILQ_ENTRY(db_symtab) list; /* all the tabs */ char *name; /* symtab name */ + u_int id; /* id */ char *start; /* symtab location */ char *end; char *private; /* optional machdep pointer */ @@ -85,6 +86,8 @@ int db_add_symbol_table __P((char *, char *, char *, char *)); void db_del_symbol_table __P((char *)); /* remove a symbol table from list */ db_symtab_t db_istab __P((size_t)); +db_symtab_t db_symiter __P((db_symtab_t)); + /* iterate through all the symtabs, if any */ boolean_t db_eqname __P((char *, char *, int)); /* strcmp, modulo leading char */ |