From 62781896f752f9e9db04146aa87cf46f050fe10e Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 30 May 2017 15:39:04 +0000 Subject: [PATCH] Kill db_sym_t. ok deraadt@, kettenis@, jasper@ --- sys/arch/amd64/amd64/db_trace.c | 10 +++++----- sys/arch/arm64/arm64/db_trace.c | 4 ++-- sys/arch/hppa/hppa/db_interface.c | 4 ++-- sys/arch/i386/i386/db_trace.c | 10 +++++----- sys/arch/m88k/m88k/db_trace.c | 6 +++--- sys/arch/mips64/mips64/trap.c | 4 ++-- sys/arch/powerpc/ddb/db_trace.c | 4 ++-- sys/arch/sh/sh/db_disasm.c | 4 ++-- sys/arch/sh/sh/db_trace.c | 4 ++-- sys/arch/sparc64/sparc64/openfirm.c | 4 ++-- sys/ddb/db_ctf.c | 4 ++-- sys/ddb/db_elf.c | 14 +++++++------- sys/ddb/db_hangman.c | 8 ++++---- sys/ddb/db_sym.c | 8 ++++---- sys/ddb/db_sym.h | 20 +++++++------------- sys/sys/exec_elf.h | 4 +++- 16 files changed, 54 insertions(+), 58 deletions(-) diff --git a/sys/arch/amd64/amd64/db_trace.c b/sys/arch/amd64/amd64/db_trace.c index 1fac964070a..6f403562021 100644 --- a/sys/arch/amd64/amd64/db_trace.c +++ b/sys/arch/amd64/amd64/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.30 2017/05/29 06:14:10 mpi Exp $ */ +/* $OpenBSD: db_trace.c,v 1.31 2017/05/30 15:39:04 mpi Exp $ */ /* $NetBSD: db_trace.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /* @@ -79,7 +79,7 @@ struct db_variable * db_eregs = db_regs + nitems(db_regs); #define INTERRUPT 3 #define AST 4 -int db_numargs(struct callframe *, db_sym_t); +int db_numargs(struct callframe *, Elf_Sym *); void db_nextframe(struct callframe **, db_addr_t *, long *, int, int (*) (const char *, ...)); @@ -92,7 +92,7 @@ void db_nextframe(struct callframe **, db_addr_t *, long *, int, * reliably determine the values currently, just return 0. */ int -db_numargs(struct callframe *fp, db_sym_t sym) +db_numargs(struct callframe *fp, Elf_Sym *sym) { #ifdef DDBCTF int args; @@ -231,7 +231,7 @@ db_stack_trace_print(db_expr_t addr, boolean_t have_addr, db_expr_t count, unsigned int i; char * name; db_expr_t offset; - db_sym_t sym; + Elf_Sym * sym; sym = db_search_symbol(callpc, DB_STGY_ANY, &offset); db_symbol_values(sym, &name, NULL); @@ -366,7 +366,7 @@ db_save_stack_trace(struct db_stack_trace *st) struct trapframe *tf; char *name; db_expr_t offset; - db_sym_t sym; + Elf_Sym * sym; int is_trap; st->st_pc[st->st_count++] = callpc; diff --git a/sys/arch/arm64/arm64/db_trace.c b/sys/arch/arm64/arm64/db_trace.c index 07c5ed5e0ee..f7892e1e96b 100644 --- a/sys/arch/arm64/arm64/db_trace.c +++ b/sys/arch/arm64/arm64/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.4 2017/02/17 17:16:04 patrick Exp $ */ +/* $OpenBSD: db_trace.c,v 1.5 2017/05/30 15:39:04 mpi Exp $ */ /* $NetBSD: db_trace.c,v 1.8 2003/01/17 22:28:48 thorpej Exp $ */ /* @@ -66,7 +66,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, u_int64_t frame, lastframe, lr, lastlr, sp; char c, *cp = modif; db_expr_t offset; - db_sym_t sym; + Elf_Sym * sym; char *name; boolean_t kernel_only = TRUE; boolean_t trace_thread = FALSE; diff --git a/sys/arch/hppa/hppa/db_interface.c b/sys/arch/hppa/hppa/db_interface.c index 707f6db3e7f..c7eabf3ba7e 100644 --- a/sys/arch/hppa/hppa/db_interface.c +++ b/sys/arch/hppa/hppa/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.39 2017/04/30 16:45:45 mpi Exp $ */ +/* $OpenBSD: db_interface.c,v 1.40 2017/05/30 15:39:04 mpi Exp $ */ /* * Copyright (c) 1999-2003 Michael Shalayeff @@ -227,7 +227,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, char *modif, int (*pr)(const char *, ...)) { register_t *fp, pc, rp, *argp; - db_sym_t sym; + Elf_Sym *sym; db_expr_t off; char *name; int nargs; diff --git a/sys/arch/i386/i386/db_trace.c b/sys/arch/i386/i386/db_trace.c index 7e522d484b3..7f5b5af1727 100644 --- a/sys/arch/i386/i386/db_trace.c +++ b/sys/arch/i386/i386/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.27 2017/05/29 06:14:10 mpi Exp $ */ +/* $OpenBSD: db_trace.c,v 1.28 2017/05/30 15:39:04 mpi Exp $ */ /* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */ /* @@ -74,7 +74,7 @@ struct db_variable *db_eregs = db_regs + nitems(db_regs); #define INTERRUPT 3 #define AST 4 -int db_numargs(struct callframe *, db_sym_t); +int db_numargs(struct callframe *, Elf_Sym *); void db_nextframe(struct callframe **, db_addr_t *, int *, int, int (*pr)(const char *, ...)); @@ -82,7 +82,7 @@ void db_nextframe(struct callframe **, db_addr_t *, int *, int, * Figure out how many arguments were passed into the frame at "fp". */ int -db_numargs(struct callframe *fp, db_sym_t sym) +db_numargs(struct callframe *fp, Elf_Sym *sym) { int *argp; int inst; @@ -236,7 +236,7 @@ db_stack_trace_print(db_expr_t addr, boolean_t have_addr, db_expr_t count, int narg; char * name; db_expr_t offset; - db_sym_t sym; + Elf_Sym *sym; sym = db_search_symbol(callpc, DB_STGY_ANY, &offset); db_symbol_values(sym, &name, NULL); @@ -339,7 +339,7 @@ db_save_stack_trace(struct db_stack_trace *st) for (i = 0; i < DB_STACK_TRACE_MAX && frame != NULL; i++) { char *name; db_expr_t offset; - db_sym_t sym; + Elf_Sym *sym; int is_trap = 0; st->st_pc[st->st_count++] = callpc; diff --git a/sys/arch/m88k/m88k/db_trace.c b/sys/arch/m88k/m88k/db_trace.c index 1c19735f092..2cadcab6136 100644 --- a/sys/arch/m88k/m88k/db_trace.c +++ b/sys/arch/m88k/m88k/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.16 2016/09/19 21:18:35 jasper Exp $ */ +/* $OpenBSD: db_trace.c,v 1.17 2017/05/30 15:39:04 mpi Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -458,7 +458,7 @@ static int next_address_likely_wrong = 0; static vaddr_t stack_decode(db_addr_t addr, vaddr_t *stack, int (*pr)(const char *, ...)) { - db_sym_t proc; + Elf_Sym *proc; db_expr_t offset_from_proc; uint instructions_to_search; db_addr_t check_addr; @@ -470,7 +470,7 @@ stack_decode(db_addr_t addr, vaddr_t *stack, int (*pr)(const char *, ...)) vaddr_t str30_addr = 0; vaddr_t last_subu_addr = 0; - /* get what we hope will be the db_sym_t for the function name */ + /* get what we hope will be the symbol for the function name */ proc = db_search_symbol(addr, DB_STGY_PROC, &offset_from_proc); if (offset_from_proc == addr) /* i.e. no symbol found */ proc = NULL; diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index 247d0444cfd..6d572473f37 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.123 2017/04/20 15:42:26 visa Exp $ */ +/* $OpenBSD: trap.c,v 1.124 2017/05/30 15:39:04 mpi Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -1206,7 +1206,7 @@ stacktrace_subr(struct trapframe *regs, int count, extern char k_general[]; #ifdef DDB db_expr_t diff; - db_sym_t sym; + Elf_Sym *sym; char *symname; #endif diff --git a/sys/arch/powerpc/ddb/db_trace.c b/sys/arch/powerpc/ddb/db_trace.c index a8a1cd591a3..832f19ccea3 100644 --- a/sys/arch/powerpc/ddb/db_trace.c +++ b/sys/arch/powerpc/ddb/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.11 2017/01/24 00:58:55 mpi Exp $ */ +/* $OpenBSD: db_trace.c,v 1.12 2017/05/30 15:39:05 mpi Exp $ */ /* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */ /* @@ -119,7 +119,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, { db_addr_t lr, sp, lastsp; db_expr_t offset; - db_sym_t sym; + Elf_Sym *sym; char *name; char c, *cp = modif; int trace_proc = 0; diff --git a/sys/arch/sh/sh/db_disasm.c b/sys/arch/sh/sh/db_disasm.c index fae5830d37a..24950ba1240 100644 --- a/sys/arch/sh/sh/db_disasm.c +++ b/sys/arch/sh/sh/db_disasm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_disasm.c,v 1.3 2007/02/26 19:33:41 miod Exp $ */ +/* $OpenBSD: db_disasm.c,v 1.4 2017/05/30 15:39:05 mpi Exp $ */ /* $NetBSD: db_disasm.c,v 1.13 2006/01/21 02:09:06 uwe Exp $ */ /* @@ -152,7 +152,7 @@ disasm_branch(char *buf, size_t bufsiz, const char *opstr, db_addr_t addr) size_t len; db_expr_t d, value; char *name; - db_sym_t cursym; + Elf_Sym *cursym; extern unsigned long db_lastsym; extern unsigned int db_maxoff; diff --git a/sys/arch/sh/sh/db_trace.c b/sys/arch/sh/sh/db_trace.c index ad0839dfe6f..a7f97d71957 100644 --- a/sys/arch/sh/sh/db_trace.c +++ b/sys/arch/sh/sh/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.6 2014/07/13 12:11:01 jasper Exp $ */ +/* $OpenBSD: db_trace.c,v 1.7 2017/05/30 15:39:05 mpi Exp $ */ /* $NetBSD: db_trace.c,v 1.19 2006/01/21 22:10:59 uwe Exp $ */ /*- @@ -113,7 +113,7 @@ db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, } else { char *name; db_expr_t offset; - db_sym_t sym; + Elf_Sym *sym; DPRINTF(" (1)newpc 0x%lx, newfp 0x%lx\n", diff --git a/sys/arch/sparc64/sparc64/openfirm.c b/sys/arch/sparc64/sparc64/openfirm.c index 3331354188a..14c3c30a0a0 100644 --- a/sys/arch/sparc64/sparc64/openfirm.c +++ b/sys/arch/sparc64/sparc64/openfirm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.c,v 1.19 2016/05/19 09:15:28 kettenis Exp $ */ +/* $OpenBSD: openfirm.c,v 1.20 2017/05/30 15:39:05 mpi Exp $ */ /* $NetBSD: openfirm.c,v 1.13 2001/06/21 00:08:02 eeh Exp $ */ /* @@ -802,7 +802,7 @@ void OF_val2sym(cells) cell_t offset; cell_t symbol; } *args = (struct args*)cells; - db_sym_t symbol; + Elf_Sym *symbol; db_expr_t value; db_expr_t offset; diff --git a/sys/ddb/db_ctf.c b/sys/ddb/db_ctf.c index 09809762daa..ff4dc9776b8 100644 --- a/sys/ddb/db_ctf.c +++ b/sys/ddb/db_ctf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_ctf.c,v 1.9 2017/05/29 06:14:10 mpi Exp $ */ +/* $OpenBSD: db_ctf.c,v 1.10 2017/05/30 15:39:05 mpi Exp $ */ /* * Copyright (c) 2016 Jasper Lievisse Adriaanse @@ -152,7 +152,7 @@ db_ctf_idx2sym(size_t *idx, uint8_t type) * For a given function name, return the number of arguments. */ int -db_ctf_func_numargs(db_sym_t st) +db_ctf_func_numargs(Elf_Sym *st) { Elf_Sym *symp, *stp = (Elf_Sym *)st; uint16_t *fstart, *fend; diff --git a/sys/ddb/db_elf.c b/sys/ddb/db_elf.c index 893b0365e19..fe4872e9a25 100644 --- a/sys/ddb/db_elf.c +++ b/sys/ddb/db_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_elf.c,v 1.25 2017/05/28 11:41:52 mpi Exp $ */ +/* $OpenBSD: db_elf.c,v 1.26 2017/05/30 15:39:05 mpi Exp $ */ /* $NetBSD: db_elf.c,v 1.13 2000/07/07 21:55:18 jhawk Exp $ */ /*- @@ -263,7 +263,7 @@ db_elf_sym_lookup(char *symstr) * Search for the symbol with the given address (matching within the * provided threshold). */ -db_sym_t +Elf_Sym * db_elf_sym_search(db_addr_t off, db_strategy_t strategy, db_expr_t *diffp) { @@ -324,14 +324,14 @@ db_elf_sym_search(db_addr_t off, db_strategy_t strategy, else *diffp = diff; - return ((db_sym_t)rsymp); + return (rsymp); } /* * Return the name and value for a symbol. */ void -db_symbol_values(db_sym_t sym, char **namep, db_expr_t *valuep) +db_symbol_values(Elf_Sym *sym, char **namep, db_expr_t *valuep) { db_symtab_t *stab = &db_symtab; Elf_Sym *symp = (Elf_Sym *)sym; @@ -362,7 +362,7 @@ db_symbol_values(db_sym_t sym, char **namep, db_expr_t *valuep) * if we can find the appropriate debugging symbol. */ int -db_elf_line_at_pc(db_sym_t cursym, char **filename, +db_elf_line_at_pc(Elf_Sym *cursym, char **filename, int *linenum, db_expr_t off) { db_symtab_t *stab = &db_symtab; @@ -426,7 +426,7 @@ db_elf_sym_forall(db_forall_func_t db_forall_func, void *arg) default: suffix[0] = '\0'; } - (*db_forall_func)((db_sym_t)symp, + (*db_forall_func)(symp, strtab + symp->st_name, suffix, 0, arg); } } @@ -439,6 +439,6 @@ db_value_of_name(char *name, db_expr_t *valuep) sym = db_elf_sym_lookup(name); if (sym == NULL) return (0); - db_symbol_values((db_sym_t)sym, &name, valuep); + db_symbol_values(sym, &name, valuep); return (1); } diff --git a/sys/ddb/db_hangman.c b/sys/ddb/db_hangman.c index 9d6dd1c751e..69cfc3bf236 100644 --- a/sys/ddb/db_hangman.c +++ b/sys/ddb/db_hangman.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_hangman.c,v 1.36 2016/09/16 19:00:25 jasper Exp $ */ +/* $OpenBSD: db_hangman.c,v 1.37 2017/05/30 15:39:05 mpi Exp $ */ /* * Copyright (c) 1996 Theo de Raadt, Michael Shalayeff @@ -66,16 +66,16 @@ static const char substchar[]="\\/|\\/O|/-|"; struct db_hang_forall_arg { int cnt; - db_sym_t sym; + Elf_Sym *sym; }; /* * Horrible abuse of the forall function, but we're not in a hurry. */ -static void db_hang_forall(db_sym_t, char *, char *, int, void *); +static void db_hang_forall(Elf_Sym *, char *, char *, int, void *); static void -db_hang_forall(db_sym_t sym, char *name, char *suff, int pre, void *varg) +db_hang_forall(Elf_Sym *sym, char *name, char *suff, int pre, void *varg) { struct db_hang_forall_arg *arg = varg; diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c index a3506c2edc1..fb0755140a0 100644 --- a/sys/ddb/db_sym.c +++ b/sys/ddb/db_sym.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_sym.c,v 1.52 2017/05/27 16:08:23 claudio Exp $ */ +/* $OpenBSD: db_sym.c,v 1.53 2017/05/30 15:39:05 mpi Exp $ */ /* $NetBSD: db_sym.c,v 1.24 2000/08/11 22:50:47 tv Exp $ */ /* @@ -95,12 +95,12 @@ db_eqname(char *src, char *dst, int c) * Find the closest symbol to val, and return its name * and the difference between val and the symbol found. */ -db_sym_t +Elf_Sym * db_search_symbol(db_addr_t val, db_strategy_t strategy, db_expr_t *offp) { unsigned int diff; db_expr_t newdiff; - db_sym_t ret = NULL, sym; + Elf_Sym *ret = NULL, *sym; newdiff = diff = ~0; sym = db_elf_sym_search(val, strategy, &newdiff); @@ -143,7 +143,7 @@ db_printsym(db_expr_t off, db_strategy_t strategy, char *name; db_expr_t value; int linenum; - db_sym_t cursym; + Elf_Sym *cursym; char buf[DB_FORMAT_BUF_SIZE]; if (off <= db_lastsym) { diff --git a/sys/ddb/db_sym.h b/sys/ddb/db_sym.h index fc590eeea41..df24cc1cfc7 100644 --- a/sys/ddb/db_sym.h +++ b/sys/ddb/db_sym.h @@ -33,13 +33,7 @@ #define _DDB_DB_SYM_H_ #include - -/* - * Symbol representation is specific to the symtab style: - * BSD compilers use dbx' nlist, other compilers might use - * a different one - */ -typedef char * db_sym_t; /* opaque handle on symbols */ +#include /* * Non-stripped symbol tables will have duplicates, for instance @@ -64,7 +58,7 @@ typedef int db_strategy_t; /* search strategy */ * the type, prefix an initial ignorable function prefix (e.g. "_" * in a.out), and arg an opaque argument to be passed in. */ -typedef void (db_forall_func_t)(db_sym_t, char *, char *, int, void *); +typedef void (db_forall_func_t)(Elf_Sym *, char *, char *, int, void *); extern unsigned int db_maxoff; /* like gdb's "max-symbolic-offset" */ @@ -74,10 +68,10 @@ int db_eqname(char *, char *, int); int db_value_of_name(char *, db_expr_t *); /* find symbol value given name */ -db_sym_t db_search_symbol(db_addr_t, db_strategy_t, db_expr_t *); +Elf_Sym * db_search_symbol(db_addr_t, db_strategy_t, db_expr_t *); /* find symbol given value */ -void db_symbol_values(db_sym_t, char **, db_expr_t *); +void db_symbol_values(Elf_Sym *, char **, db_expr_t *); /* return name and value of symbol */ #define db_find_sym_and_offset(val,namep,offp) \ @@ -92,15 +86,15 @@ void db_printsym(db_expr_t, db_strategy_t, int (*)(const char *, ...)); /* print closest symbol to a value */ int db_elf_sym_init(int, void *, void *, const char *); -db_sym_t db_elf_sym_search(db_addr_t, db_strategy_t, db_expr_t *); -int db_elf_line_at_pc(db_sym_t, char **, int *, db_expr_t); +Elf_Sym * db_elf_sym_search(db_addr_t, db_strategy_t, db_expr_t *); +int db_elf_line_at_pc(Elf_Sym *, char **, int *, db_expr_t); void db_elf_sym_forall(db_forall_func_t db_forall_func, void *); bool db_dwarf_line_at_pc(const char *, size_t, uintptr_t, const char **, const char **, int *); #ifdef DDBCTF -int db_ctf_func_numargs(db_sym_t); +int db_ctf_func_numargs(Elf_Sym *); #endif #endif /* _DDB_DB_SYM_H_ */ diff --git a/sys/sys/exec_elf.h b/sys/sys/exec_elf.h index 690df79ad3c..77c13a0372c 100644 --- a/sys/sys/exec_elf.h +++ b/sys/sys/exec_elf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.h,v 1.73 2017/02/18 06:42:08 jsg Exp $ */ +/* $OpenBSD: exec_elf.h,v 1.74 2017/05/30 15:39:05 mpi Exp $ */ /* * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. * @@ -736,6 +736,8 @@ extern Elf_Dyn _DYNAMIC[]; #endif #ifdef _KERNEL +struct exec_package; + int exec_elf_makecmds(struct proc *, struct exec_package *); #endif /* _KERNEL */ -- 2.20.1