summaryrefslogtreecommitdiffstats
path: root/sys/ddb
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1994-01-03 07:54:10 +0000
committerdg <dg@FreeBSD.org>1994-01-03 07:54:10 +0000
commit17916ffcbb0b38dff696ae09db5821a833224036 (patch)
treed24eb1132beba030b8e4d69d09e3bb0bda50fb8b /sys/ddb
parent44196ffe13e5376b5162406170953832ebc8a828 (diff)
downloadFreeBSD-src-17916ffcbb0b38dff696ae09db5821a833224036.zip
FreeBSD-src-17916ffcbb0b38dff696ae09db5821a833224036.tar.gz
Patches from John Brezak (necessary for the syscall->trapframe conversion
as well as add additional functionality): Print symbolic args and line no's in stack traces.
Diffstat (limited to 'sys/ddb')
-rw-r--r--sys/ddb/db_aout.c116
-rw-r--r--sys/ddb/db_sym.c14
2 files changed, 122 insertions, 8 deletions
diff --git a/sys/ddb/db_aout.c b/sys/ddb/db_aout.c
index 06d1b06..2dd0b75 100644
--- a/sys/ddb/db_aout.c
+++ b/sys/ddb/db_aout.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_aout.c,v 1.3 1993/10/16 16:47:06 rgrimes Exp $
+ * $Id: db_aout.c,v 1.4 1993/11/25 01:30:02 wollman Exp $
*/
/*
@@ -44,6 +44,7 @@
#define _AOUT_INCLUDE_
#include "nlist.h"
+#include "stab.h"
/*
* An a.out symbol table as loaded into the kernel debugger:
@@ -165,13 +166,17 @@ X_db_search_symbol(symtab, off, strategy, diffp)
for (; sp < ep; sp++) {
if (sp->n_un.n_name == 0)
continue;
- if ((sp->n_type & N_STAB) != 0)
+ if ((sp->n_type & N_STAB) != 0 || (sp->n_type & N_TYPE) == N_FN)
continue;
if (off >= sp->n_value) {
if (off - sp->n_value < diff) {
diff = off - sp->n_value;
symp = sp;
- if (diff == 0)
+ if (diff == 0 &&
+ (strategy == DB_STGY_PROC &&
+ sp->n_type == (N_TEXT|N_EXT) ||
+ strategy == DB_STGY_ANY &&
+ (sp->n_type & N_EXT)))
break;
}
else if (off - sp->n_value == diff) {
@@ -210,12 +215,111 @@ X_db_symbol_values(sym, namep, valuep)
*valuep = sp->n_value;
}
+
boolean_t
-X_db_line_at_pc()
+X_db_line_at_pc(symtab, cursym, filename, linenum, off)
+ db_symtab_t * symtab;
+ db_sym_t cursym;
+ char **filename;
+ int *linenum;
+ db_expr_t off;
{
+ register struct nlist *sp, *ep;
+ register struct nlist *sym = (struct nlist *)cursym;
+ unsigned long sodiff = -1UL, lndiff = -1UL, ln = 0;
+ char *fname = NULL;
+
+ sp = (struct nlist *)symtab->start;
+ ep = (struct nlist *)symtab->end;
+
+/* XXX - gcc specific */
+#define NEWSRC(str) ((str) != NULL && \
+ (str)[0] == 'g' && strcmp((str), "gcc_compiled.") == 0)
+
+ for (; sp < ep; sp++) {
+
+ /*
+ * Prevent bogus linenumbers in case module not compiled
+ * with debugging options
+ */
+#if 0
+ if (sp->n_value <= off && (off - sp->n_value) <= sodiff &&
+ NEWSRC(sp->n_un.n_name)) {
+#endif
+ if ((sp->n_type & N_TYPE) == N_FN || NEWSRC(sp->n_un.n_name)) {
+ sodiff = lndiff = -1UL;
+ ln = 0;
+ fname = NULL;
+ }
+
+ if (sp->n_type == N_SO) {
+ if (sp->n_value <= off && (off - sp->n_value) < sodiff) {
+ sodiff = off - sp->n_value;
+ fname = sp->n_un.n_name;
+ }
+ continue;
+ }
+
+ if (sp->n_type != N_SLINE)
+ continue;
+
+ if (sp->n_value > off)
+ break;
+
+ if (off - sp->n_value < lndiff) {
+ lndiff = off - sp->n_value;
+ ln = sp->n_desc;
+ }
+ }
+
+ if (fname != NULL && ln != 0) {
+ *filename = fname;
+ *linenum = ln;
+ return TRUE;
+ }
+
return (FALSE);
}
+boolean_t
+X_db_sym_numargs(symtab, cursym, nargp, argnamep)
+ db_symtab_t * symtab;
+ db_sym_t cursym;
+ int *nargp;
+ char **argnamep;
+{
+ register struct nlist *sp, *ep;
+ u_long addr;
+ int maxnarg = *nargp, nargs = 0;
+
+ if (cursym == NULL)
+ return FALSE;
+
+ addr = ((struct nlist *)cursym)->n_value;
+ sp = (struct nlist *)symtab->start;
+ ep = (struct nlist *)symtab->end;
+
+ for (; sp < ep; sp++) {
+ if (sp->n_type == N_FUN && sp->n_value == addr) {
+ while (++sp < ep && sp->n_type == N_PSYM) {
+ if (nargs >= maxnarg)
+ break;
+ nargs++;
+ *argnamep++ = sp->n_un.n_name?sp->n_un.n_name:"???";
+ {
+ /* XXX - remove trailers */
+ char *cp = *(argnamep-1);
+ while (*cp != '\0' && *cp != ':') cp++;
+ if (*cp == ':') *cp = '\0';
+ }
+ }
+ *nargp = nargs;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
/*
* Initialization routine for a.out files.
*/
@@ -227,11 +331,11 @@ kdb_init(void)
extern int end;
if (esym > (char *)&end) {
- X_db_sym_init((int *)&end, esym, "mach");
+ X_db_sym_init((int *)&end, esym, "386bsd");
}
#endif
- X_db_sym_init (db_symtab, 0, "mach");
+ X_db_sym_init (db_symtab, 0, "386bsd");
}
#if 0
diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c
index 74c96e3..af22a97 100644
--- a/sys/ddb/db_sym.c
+++ b/sys/ddb/db_sym.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_sym.c,v 1.2 1993/10/16 16:47:25 rgrimes Exp $
+ * $Id: db_sym.c,v 1.3 1993/11/25 01:30:12 wollman Exp $
*/
/*
@@ -47,7 +47,9 @@ extern void X_db_symbol_values();
/*
* Multiple symbol tables
*/
+#ifndef MAXNOSYMTABS
#define MAXNOSYMTABS 3 /* mach, ux, emulator */
+#endif
db_symtab_t db_symtabs[MAXNOSYMTABS] = {{0,},};
int db_nsymtab = 0;
@@ -311,7 +313,6 @@ db_printsym(off, strategy)
}
}
-
boolean_t
db_line_at_pc( sym, filename, linenum, pc)
int sym;
@@ -321,3 +322,12 @@ db_line_at_pc( sym, filename, linenum, pc)
{
return X_db_line_at_pc( db_last_symtab, sym, filename, linenum, pc);
}
+
+int
+db_sym_numargs(sym, nargp, argnames)
+ db_sym_t sym;
+ int *nargp;
+ char **argnames;
+{
+ return X_db_sym_numargs(db_last_symtab, sym, nargp, argnames);
+}
OpenPOWER on IntegriCloud