Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 May 2004 14:04:33 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 52949 for review
Message-ID:  <200405172104.i4HL4XHQ069845@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=52949

Change 52949 by peter@peter_hammer on 2004/05/17 14:03:44

	trim debugging

Affected files ...

.. //depot/projects/hammer/sys/kern/kern_linker.c#15 edit
.. //depot/projects/hammer/sys/kern/link_elf_obj.c#34 edit

Differences ...

==== //depot/projects/hammer/sys/kern/kern_linker.c#15 (text+ko) ====

@@ -1,4 +1,3 @@
-#define KLD_DEBUG
 /*-
  * Copyright (c) 1997-2000 Doug Rabson
  * All rights reserved.
@@ -53,7 +52,7 @@
 #include "linker_if.h"
 
 #ifdef KLD_DEBUG
-int kld_debug = 3;
+int kld_debug = 0;
 #endif
 
 /*

==== //depot/projects/hammer/sys/kern/link_elf_obj.c#34 (text+ko) ====

@@ -152,39 +152,7 @@
 
 static int	relocate_file(elf_file_t ef);
 
-static void *
-Malloc(const char *id, unsigned long size, struct malloc_type *type, int flags)
-{
-	void *ret;
-
-	ret = malloc(size, type, flags);
-	printf("Malloc: id %s, size 0x%lx -> ret %p\n", id, size, ret);
-	return ret;
-}
 static void
-Free(const char *id, void *addr, struct malloc_type *type)
-{
-	printf("Free: id %s, addr %p\n", id, addr);
-	free(addr, type);
-}
-
-static int
-Vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base,
-    int len, off_t offset, enum uio_seg segflg, int ioflg,
-    struct ucred *active_cred, struct ucred *file_cred, int *aresid,
-    struct thread *td)
-{
-	int ret;
-
-	printf("vn_rdwr: base %p, len 0x%x, off 0x%lx -> ", base, len, offset);
-	ret = vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, active_cred, file_cred, aresid, td);
-	printf("resid 0x%x, ret %d\n", aresid ? *aresid : 0, ret);
-	return ret;
-}
-#define vn_rdwr Vn_rdwr
-
-
-static void
 link_elf_error(const char *s)
 {
 	printf("kldload: %s\n", s);
@@ -257,7 +225,7 @@
 #endif
 
 	/* Read the elf header from the file. */
-	hdr = Malloc("elf header", sizeof(*hdr), M_LINKER, M_WAITOK);
+	hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK);
 	if (hdr == NULL) {
 		error = ENOMEM;
 		goto out;
@@ -318,7 +286,7 @@
 		error = ENOEXEC;
 		goto out;
 	}
-	shdr = Malloc("shdr", nbytes, M_LINKER, M_WAITOK);
+	shdr = malloc(nbytes, M_LINKER, M_WAITOK);
 	if (shdr == NULL) {
 		error = ENOMEM;
 		goto out;
@@ -378,13 +346,13 @@
 
 	/* Allocate space for tracking the load chunks */
 	if (ef->nprogtab != 0)
-		ef->progtab = Malloc("progtab", ef->nprogtab * sizeof(*ef->progtab),
+		ef->progtab = malloc(ef->nprogtab * sizeof(*ef->progtab),
 		    M_LINKER, M_WAITOK | M_ZERO);
 	if (ef->nrel != 0)
-		ef->reltab = Malloc("reltab", ef->nrel * sizeof(*ef->reltab), M_LINKER,
+		ef->reltab = malloc(ef->nrel * sizeof(*ef->reltab), M_LINKER,
 		    M_WAITOK | M_ZERO);
 	if (ef->nrela != 0)
-		ef->relatab = Malloc("relatab", ef->nrela * sizeof(*ef->relatab), M_LINKER,
+		ef->relatab = malloc(ef->nrela * sizeof(*ef->relatab), M_LINKER,
 		    M_WAITOK | M_ZERO);
 	if ((ef->nprogtab != 0 && ef->progtab == NULL) ||
 	    (ef->nrel != 0 && ef->reltab == NULL) ||
@@ -397,7 +365,7 @@
 		panic("lost symbol table index");
 	/* Allocate space for and load the symbol table */
 	ef->ddbsymcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym);
-	ef->ddbsymtab = Malloc("ddbsymtab", shdr[symtabindex].sh_size, M_LINKER, M_WAITOK);
+	ef->ddbsymtab = malloc(shdr[symtabindex].sh_size, M_LINKER, M_WAITOK);
 	if (ef->ddbsymtab == NULL) {
 		error = ENOMEM;
 		goto out;
@@ -417,7 +385,7 @@
 		panic("lost symbol string index");
 	/* Allocate space for and load the symbol strings */
 	ef->ddbstrcnt = shdr[symstrindex].sh_size;
-	ef->ddbstrtab = Malloc("ddbstrtab", shdr[symstrindex].sh_size, M_LINKER, M_WAITOK);
+	ef->ddbstrtab = malloc(shdr[symstrindex].sh_size, M_LINKER, M_WAITOK);
 	if (ef->ddbstrtab == NULL) {
 		error = ENOMEM;
 		goto out;
@@ -439,7 +407,7 @@
 	    shdr[hdr->e_shstrndx].sh_type == SHT_STRTAB) {
 		shstrindex = hdr->e_shstrndx;
 		ef->shstrcnt = shdr[shstrindex].sh_size;
-		ef->shstrtab = Malloc("shstrtab", shdr[shstrindex].sh_size, M_LINKER,
+		ef->shstrtab = malloc(shdr[shstrindex].sh_size, M_LINKER,
 		    M_WAITOK);
 		if (ef->shstrtab == NULL) {
 			error = ENOMEM;
@@ -501,7 +469,6 @@
 	lf->address = ef->address = (caddr_t)mapbase;
 	lf->size = mapsize;
 
-printf("mapbase: 0x%lx, mapsize 0x%lx, end 0x%lx\n", mapbase, mapsize, mapbase + mapsize);
 	/*
 	 * Now load code/data(progbits), zero bss(nobits), allocate space for
 	 * and load relocs
@@ -541,16 +508,14 @@
 			if (ef->shstrtab && shdr[i].sh_name != 0)
 				ef->progtab[pb].name =
 				    ef->shstrtab + shdr[i].sh_name;
-printf("section %d, pb %d, base %p, name %s\n", i, pb, ef->progtab[pb].addr, ef->progtab[pb].name);
 			mapbase += shdr[i].sh_size;
 			pb++;
 			break;
 		case SHT_REL:
-			ef->reltab[rl].rel = Malloc("one SHT_REL", shdr[i].sh_size, M_LINKER,
+			ef->reltab[rl].rel = malloc(shdr[i].sh_size, M_LINKER,
 			    M_WAITOK);
 			ef->reltab[rl].nrel = shdr[i].sh_size / sizeof(Elf_Rel);
 			ef->reltab[rl].sec = shdr[i].sh_info;
-printf("rel sec %d rl %d addr %p size 0x%lx nrel %d\n", i, rl, ef->reltab[rl].rel, shdr[i].sh_size, ef->reltab[rl].nrel);
 			error = vn_rdwr(UIO_READ, nd.ni_vp,
 			    (void *)ef->reltab[rl].rel,
 			    shdr[i].sh_size, shdr[i].sh_offset,
@@ -565,12 +530,11 @@
 			rl++;
 			break;
 		case SHT_RELA:
-			ef->relatab[ra].rela = Malloc("one SHT_RELA", shdr[i].sh_size, M_LINKER,
+			ef->relatab[ra].rela = malloc(shdr[i].sh_size, M_LINKER,
 			    M_WAITOK);
 			ef->relatab[ra].nrela =
 			    shdr[i].sh_size / sizeof(Elf_Rela);
 			ef->relatab[ra].sec = shdr[i].sh_info;
-printf("rela sec %d ra %d addr %p size 0x%lx nrela %d\n", i, ra, ef->relatab[ra].rela, shdr[i].sh_size, ef->relatab[ra].nrela);
 			error = vn_rdwr(UIO_READ, nd.ni_vp,
 			    (void *)ef->relatab[ra].rela,
 			    shdr[i].sh_size, shdr[i].sh_offset,
@@ -593,7 +557,7 @@
 	if (ra != ef->nrela)
 		panic("lost rela");
 	if (mapbase != (vm_offset_t)ef->address + mapsize)
-		printf("mapbase 0x%lx != address %p + mapsize 0x%lx (0x%lx)\n", mapbase, ef->address, mapsize, (vm_offset_t)ef->address + mapsize);
+		panic("mapbase 0x%lx != address %p + mapsize 0x%lx (0x%lx)\n", mapbase, ef->address, mapsize, (vm_offset_t)ef->address + mapsize);
 
 	/* Local intra-module relocations */
 	link_elf_reloc_local(lf);
@@ -616,12 +580,10 @@
 	*result = lf;
 
 out:
-	if (error && lf) {
-		printf("error: unloading\n");
+	if (error && lf)
 		linker_file_unload(lf);
-	}
 	if (hdr)
-		Free("elf hdr", hdr, M_LINKER);
+		free(hdr, M_LINKER);
 	VOP_UNLOCK(nd.ni_vp, 0, td);
 	vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
 
@@ -639,32 +601,31 @@
 
 	for (i = 0; i < ef->nrel; i++)
 		if (ef->reltab[i].rel)
-			Free("one reltab", ef->reltab[i].rel, M_LINKER);
+			free(ef->reltab[i].rel, M_LINKER);
 	for (i = 0; i < ef->nrela; i++)
 		if (ef->relatab[i].rela)
-			Free("one relatab", ef->relatab[i].rela, M_LINKER);
+			free(ef->relatab[i].rela, M_LINKER);
 	if (ef->reltab)
-		Free("reltab", ef->reltab, M_LINKER);
+		free(ef->reltab, M_LINKER);
 	if (ef->relatab)
-		Free("relatab", ef->relatab, M_LINKER);
+		free(ef->relatab, M_LINKER);
 	if (ef->progtab)
-		Free("progtab", ef->progtab, M_LINKER);
+		free(ef->progtab, M_LINKER);
 
 	if (ef->object) {
-printf("object: %p, size %ld pages, addr %p, end 0x%lx\n", ef->object, ef->object->size, ef->address, (vm_offset_t) ef->address + (ef->object->size << PAGE_SHIFT));
 		vm_map_remove(kernel_map, (vm_offset_t) ef->address,
 		    (vm_offset_t) ef->address +
 		    (ef->object->size << PAGE_SHIFT));
 		vm_object_deallocate(ef->object);
 	}
 	if (ef->e_shdr)
-		Free("shdr", ef->e_shdr, M_LINKER);
+		free(ef->e_shdr, M_LINKER);
 	if (ef->ddbsymtab)
-		Free("ddbsymtab", ef->ddbsymtab, M_LINKER);
+		free(ef->ddbsymtab, M_LINKER);
 	if (ef->ddbstrtab)
-		Free("ddbstrtab", ef->ddbstrtab, M_LINKER);
+		free(ef->ddbstrtab, M_LINKER);
 	if (ef->shstrtab)
-		Free("shstrtab", ef->shstrtab, M_LINKER);
+		free(ef->shstrtab, M_LINKER);
 }
 
 static const char *
@@ -863,7 +824,6 @@
 				*stopp = stop;
 			if (countp)
 				*countp = count;
-printf("lookup_set: %s start %p stop %p count 0x%x\n", name, start, stop, count);
 			return (0);
 		}
 	}
@@ -939,7 +899,7 @@
 		return ret;
 
 	case STB_WEAK:
-		printf("Weak symbols not supported\n");
+		printf("link_elf_obj: Weak symbols not supported\n");
 		return (0);
 
 	default:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405172104.i4HL4XHQ069845>