Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Dec 2015 08:02:10 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Konstantin Belousov <kib@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r292620 - head/sys/kern
Message-ID:  <20151223073258.M993@besplex.bde.org>
In-Reply-To: <201512222012.tBMKCqqg039018@repo.freebsd.org>
References:  <201512222012.tBMKCqqg039018@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 22 Dec 2015, Konstantin Belousov wrote:

> Log:
>  If we annoy user with the terminal output due to failed load of
>  interpreter, also show the actual error code instead of some
>  interpretation.

This and nearby messages are of annoyingly low quality.  They don't
even print the program name(s).

I use the following partial fixes.  I forget if they print the program
name or the interpeter name.

X Index: imgact_elf.c
X ===================================================================
X RCS file: /home/ncvs/src/sys/kern/imgact_elf.c,v
X retrieving revision 1.151
X diff -u -2 -r1.151 imgact_elf.c
X --- imgact_elf.c	5 Jun 2004 02:18:28 -0000	1.151
X +++ imgact_elf.c	5 Jun 2004 06:51:25 -0000
X @@ -694,6 +693,6 @@
X  	brand_info = __elfN(get_brandinfo)(hdr, interp);
X  	if (brand_info == NULL) {
X -		uprintf("ELF binary type \"%u\" not known.\n",
X -		    hdr->e_ident[EI_OSABI]);
X +		uprintf("%s: ELF binary type \"%u\" not known.\n",
X +		    imgp->stringbase, hdr->e_ident[EI_OSABI]);
X  		error = ENOEXEC;
X  		goto fail;
X @@ -828,5 +827,6 @@
X  		    &imgp->entry_addr, sv->sv_pagesize);
X  		if (error != 0) {
X -			uprintf("ELF interpreter %s not found\n", interp);
X +			uprintf("%s: ELF interpreter %s not found\n",
X +			    imgp->stringbase, interp);
X  			goto fail;
X  		}

Other uprintf()s in imgact_elf.c are worse -- they print a fixed string that
gives no hint about the intepreter either (except it sometimes says ELF or
elf or PT_).

Y 		uprintf("elf_load_section: truncated ELF file\n");
Y 		uprintf("Program headers not in the first page\n");
Y 		uprintf("Unaligned program headers\n");
Y 				uprintf("Invalid PT_INTERP\n");
Y 					uprintf("i/o error PT_INTERP\n");
Y 			uprintf("Cannot execute shared object\n");
Y 		uprintf("%s\n", err_str);
Y 			uprintf("ELF interpreter %s not found\n", interp);
Y 			uprintf("i/o error PT_NOTE\n");

The "ELF binary type \"%u\" not known.\n", message is the only one with
the style bug of a terminating ".".  My patch is missing the fix for this.

"elf_load_section: truncated ELF file\n" messages is the only one that
prints the function name.  This is not very useful for users.

All kernel printfs and KASSERT()s in the file use __func__ to obfuscate
the function name and have many other style bugs.

uprintf() is rarely used.  Aproximately 100 times.  Most uses don't
print enough context.  In kern_exec.c there is a related one that
prints a pathname, but not in err() format with the name first.  The
problematic pathname or interpreter name may be nested.  I'm not sure how
to find the complete sequence of names.

tprintf() is only used 7 times.  Some uprintf()s should probably be
tprintf()s to get them logged.

Bruce



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