summaryrefslogtreecommitdiffstats
path: root/usr.sbin/dbsym
diff options
context:
space:
mode:
authorrgrimes <rgrimes@FreeBSD.org>1993-09-26 16:40:41 +0000
committerrgrimes <rgrimes@FreeBSD.org>1993-09-26 16:40:41 +0000
commit5e8d6a90390fce77a968b64eaaec9e83ef6055aa (patch)
treeac54d9abd176df0264b891df2a8c1ffdb6cd5779 /usr.sbin/dbsym
parenta6ae8d8157ee4fadcef4e8ec6b29963fe693368a (diff)
downloadFreeBSD-src-5e8d6a90390fce77a968b64eaaec9e83ef6055aa.zip
FreeBSD-src-5e8d6a90390fce77a968b64eaaec9e83ef6055aa.tar.gz
Import NetBSD version of dbsym (below is rlog of there version), and add
$Id$ to Makefile. ---------------------------- revision 1.8 date: 1993/08/02 17:57:02; author: mycroft; state: Exp; lines: +5 -0 Add RCS identifiers, remove some completely useless RCS logs and patchkit headers, and a few other insignificant changes. ---------------------------- revision 1.7 date: 1993/07/19 16:50:10; author: mycroft; state: Exp; lines: +43 -15 Kitchen sink version of dbsym. -f force; don't complain if db_symtab is missing -g debugging; include line number and function info -x remove local symbols -T addr specify load address (necessary to determine file positions) ---------------------------- revision 1.6 date: 1993/07/18 10:34:52; author: mycroft; state: Exp; lines: +1 -1 Hmmm. I suppose text_Adr really should be an int... ---------------------------- revision 1.5 date: 1993/07/18 09:44:12; author: mycroft; state: Exp; lines: +12 -6 Add -T option to specify load address of kernel (like ld); default to KERNBASE for compatibility. ---------------------------- revision 1.4 date: 1993/07/12 18:01:51; author: brezak; state: Exp; lines: +19 -2 Changes for GCC2 generated symbols. ---------------------------- revision 1.3 date: 1993/07/11 08:43:34; author: cgd; state: Exp; lines: +2 -2 if no symbols present, don't complain, and exit with 0 exit status. that way we can use dbsym from kernel makefiles and actually pay attention to its errors... ---------------------------- revision 1.2 date: 1993/06/18 06:52:03; author: cgd; state: Exp; lines: +3 -1 convert magic numbers to network byte order, and attendent changes ---------------------------- revision 1.1 date: 1993/03/21 09:59:19; author: cgd; state: Exp; branches: 1.1.1; Initial revision ---------------------------- revision 1.1.1.1 date: 1993/03/21 09:59:20; author: cgd; state: Exp; lines: +0 -0 initial import of 386bsd-0.1 sources
Diffstat (limited to 'usr.sbin/dbsym')
-rw-r--r--usr.sbin/dbsym/Makefile2
-rw-r--r--usr.sbin/dbsym/dbsym.c82
2 files changed, 72 insertions, 12 deletions
diff --git a/usr.sbin/dbsym/Makefile b/usr.sbin/dbsym/Makefile
index 95ab527..e1fbf2c 100644
--- a/usr.sbin/dbsym/Makefile
+++ b/usr.sbin/dbsym/Makefile
@@ -1,3 +1,5 @@
+# $Id$
+
PROG= dbsym
NOMAN= noman
diff --git a/usr.sbin/dbsym/dbsym.c b/usr.sbin/dbsym/dbsym.c
index 46514b4..7eb3de5 100644
--- a/usr.sbin/dbsym/dbsym.c
+++ b/usr.sbin/dbsym/dbsym.c
@@ -1,12 +1,21 @@
/* Written by Pace Willisson (pace@blitz.com)
* and placed in the public domain.
*/
+
+#ifndef lint
+static char rcsid[] = "$Id: dbsym.c,v 1.8 1993/08/02 17:57:02 mycroft Exp $";
+#endif /* not lint */
+
#include <stdio.h>
+#include <stdlib.h>
#include <a.out.h>
+#include <stab.h>
+#include <machine/param.h>
-char *malloc ();
+#define FILE_OFFSET(vadr) (((vadr) - text_adr) - N_DATADDR(hdr) + \
+ N_DATOFF(hdr) + N_TXTADDR(hdr))
-#define FILE_OFFSET(vadr) (((vadr) & ~0xff000000)-N_DATADDR(hdr)+N_DATOFF(hdr))
+u_int text_adr = KERNBASE;
struct nlist *old_syms;
int num_old_syms;
@@ -24,10 +33,13 @@ int db_symtab_adr;
int avail;
+int force = 0;
+int zap_locals = 0;
+int debugging = 0;
usage ()
{
- fprintf (stderr, "usage: dbsym file\n");
+ fprintf (stderr, "usage: dbsym [-fgx] [-T addr] file\n");
exit (1);
}
@@ -46,8 +58,22 @@ char **argv;
int len;
- while ((c = getopt (argc, argv, "")) != EOF) {
+ while ((c = getopt (argc, argv, "fgxT:")) != EOF) {
switch (c) {
+ case 'f':
+ force = 1;
+ break;
+ case 'g':
+ debugging = 1;
+ break;
+ case 'x':
+ zap_locals = 1;
+ break;
+ case 'T':
+ text_adr = strtoul(optarg, &p, 16);
+ if (*p)
+ err("illegal text address: %s", optarg);
+ break;
default:
usage ();
}
@@ -113,17 +139,44 @@ char **argv;
nsp = new_syms;
for (i = 0, sp = old_syms; i < num_old_syms; i++, sp++) {
+ if (zap_locals && !(sp->n_type & N_EXT))
+ continue;
+
if (sp->n_type & N_STAB)
+ switch (sp->n_type & ~N_EXT) {
+ case N_SLINE:
+ if (debugging)
+ *nsp++ = *sp;
+ continue;
+ case N_FUN:
+ case N_PSYM:
+ case N_SO:
+ if (!debugging)
+ continue;
+ goto skip_tests;
+ break;
+ default:
+ continue;
+ }
+
+ if ((sp->n_type & ~N_EXT) == N_UNDF)
+ continue;
+
+ if (!debugging && (sp->n_type & ~N_EXT) == N_FN)
continue;
+
if (sp->n_un.n_strx == 0)
continue;
- if (sp->n_value < 0xfe000000)
+ if (sp->n_value < text_adr)
continue;
- if (sp->n_value >= 0xff000000)
+ if (sp->n_value > (text_adr + hdr.a_text + hdr.a_data +
+ hdr.a_bss))
continue;
+ skip_tests:
+
name = old_strtab + sp->n_un.n_strx;
len = strlen (name);
@@ -131,12 +184,15 @@ char **argv;
if (len == 0)
continue;
- if (len >= 2 && name[len - 2] == '.' && name[len - 1] == 'o')
+ if (strcmp (name, "gcc_compiled.") == 0)
continue;
- if (strcmp (name, "gcc_compiled.") == 0)
+ if (strcmp (name, "gcc2_compiled.") == 0)
continue;
+ if (strcmp (name, "___gnu_compiled_c") == 0)
+ continue;
+
*nsp = *sp;
nsp->n_un.n_strx = new_strtab_size;
@@ -150,10 +206,12 @@ char **argv;
db_symtabsize_adr = sp->n_value;
}
- if (db_symtab_adr == 0 || db_symtabsize_adr == 0) {
- fprintf (stderr, "couldn't find db_symtab symbols\n");
- exit (1);
- }
+ if (db_symtab_adr == 0 || db_symtabsize_adr == 0)
+ if (!force) {
+ fprintf (stderr, "couldn't find db_symtab symbols\n");
+ exit (1);
+ } else
+ exit (0);
*(int *)new_strtab = new_strtab_size;
num_new_syms = nsp - new_syms;
OpenPOWER on IntegriCloud