-/* $OpenBSD: db_trace.c,v 1.29 2017/05/28 14:24:19 mpi Exp $ */
+/* $OpenBSD: db_trace.c,v 1.30 2017/05/29 06:14:10 mpi Exp $ */
/* $NetBSD: db_trace.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */
/*
#include <machine/frame.h>
#include <machine/trap.h>
-#ifdef DDBCTF
-#include <ddb/db_extern.h>
-#endif
#include <ddb/db_sym.h>
#include <ddb/db_access.h>
#include <ddb/db_variables.h>
#define INTERRUPT 3
#define AST 4
-int db_numargs(struct callframe *, const char *);
+int db_numargs(struct callframe *, db_sym_t);
void db_nextframe(struct callframe **, db_addr_t *, long *, int,
int (*) (const char *, ...));
* reliably determine the values currently, just return 0.
*/
int
-db_numargs(struct callframe *fp, const char *sym)
+db_numargs(struct callframe *fp, db_sym_t sym)
{
#ifdef DDBCTF
int args;
narg = 0;
else {
is_trap = NONE;
- narg = db_numargs(frame, name);
+ narg = db_numargs(frame, sym);
}
(*pr)("%s(", name);
-/* $OpenBSD: db_trace.c,v 1.26 2017/05/28 14:24:19 mpi Exp $ */
+/* $OpenBSD: db_trace.c,v 1.27 2017/05/29 06:14:10 mpi Exp $ */
/* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */
/*
#include <machine/db_machdep.h>
-#ifdef DDBCTF
-#include <ddb/db_extern.h>
-#endif
#include <ddb/db_sym.h>
#include <ddb/db_access.h>
#include <ddb/db_variables.h>
#define INTERRUPT 3
#define AST 4
-int db_numargs(struct callframe *, const char *);
+int db_numargs(struct callframe *, db_sym_t);
void db_nextframe(struct callframe **, db_addr_t *, int *, int,
int (*pr)(const char *, ...));
* Figure out how many arguments were passed into the frame at "fp".
*/
int
-db_numargs(struct callframe *fp, const char *sym)
+db_numargs(struct callframe *fp, db_sym_t sym)
{
int *argp;
int inst;
narg = 0;
else {
is_trap = NONE;
- narg = db_numargs(frame, name);
+ narg = db_numargs(frame, sym);
}
(*pr)("%s(", name);
-/* $OpenBSD: db_ctf.c,v 1.8 2017/05/28 14:24:19 mpi Exp $ */
+/* $OpenBSD: db_ctf.c,v 1.9 2017/05/29 06:14:10 mpi Exp $ */
/*
* Copyright (c) 2016 Jasper Lievisse Adriaanse <jasper@openbsd.org>
struct ddb_ctf db_ctf;
static const char *db_ctf_lookup_name(uint32_t);
-static const char *db_ctf_idx2sym(size_t *, uint8_t);
+static Elf_Sym *db_ctf_idx2sym(size_t *, uint8_t);
static char *db_ctf_decompress(const char *, size_t, off_t);
/*
* It must be noted this only works if the CTF table has the same order
* as the symbol table.
*/
-static const char *
+Elf_Sym *
db_ctf_idx2sym(size_t *idx, uint8_t type)
{
Elf_Sym *symp, *symtab_start, *symtab_end;
continue;
*idx = i;
- return db_ctf.strtab + symp->st_name;
+ return symp;
}
return NULL;
* For a given function name, return the number of arguments.
*/
int
-db_ctf_func_numargs(const char *funcname)
+db_ctf_func_numargs(db_sym_t st)
{
+ Elf_Sym *symp, *stp = (Elf_Sym *)st;
uint16_t *fstart, *fend;
- const char *fname;
uint16_t *fsp, kind, vlen;
size_t i, idx = 0;
- if (!db_ctf.ctf_found)
+ if (!db_ctf.ctf_found || stp == NULL)
return -1;
fstart = (uint16_t *)(db_ctf.data + db_ctf.cth->cth_funcoff);
fsp = fstart;
while (fsp < fend) {
- fname = db_ctf_idx2sym(&idx, STT_FUNC);
- if (fname == NULL)
+ symp = db_ctf_idx2sym(&idx, STT_FUNC);
+ if (symp == NULL)
break;
kind = CTF_INFO_KIND(*fsp);
for (i = 0; i < vlen; i++)
fsp++;
- if (strcmp(funcname, fname) == 0)
+ if (symp == stp)
return vlen;
}
-/* $OpenBSD: db_extern.h,v 1.18 2016/09/16 19:13:17 jasper Exp $ */
+/* $OpenBSD: db_extern.h,v 1.19 2017/05/29 06:14:10 mpi Exp $ */
/* $NetBSD: db_extern.h,v 1.1 1996/02/05 01:57:00 christos Exp $ */
/*
void db_prof_disable(void);
/* db_ctf.c */
-int db_ctf_func_numargs(const char *);
void db_ctf_init(void);
#endif /* _DDB_DB_EXTERN_H_ */
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);
+#endif
+
#endif /* _DDB_DB_SYM_H_ */