git: bdc903460be4 - main - kern_ctf.c: Don't print out warning messages unconditionally
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 29 Mar 2024 19:32:40 UTC
The branch main has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=bdc903460be4b6a729c1b7cde55963730c68cec4 commit bdc903460be4b6a729c1b7cde55963730c68cec4 Author: Bojan Novković <bnovkov@FreeBSD.org> AuthorDate: 2024-03-29 19:17:19 +0000 Commit: Bojan Novković <bnovkov@FreeBSD.org> CommitDate: 2024-03-29 19:32:18 +0000 kern_ctf.c: Don't print out warning messages unconditionally The kernel CTF loading routines print various warnings when attempting to load CTF data from an ELF file. After the changes in c21bc6f3c242 those warnings are unnecessarily printed for each kernel module that was compiled without CTF data. The kernel linker already uses the bootverbose flag to conditionally print CTF loading errors. This patch alters kern_ctf.c routines to do the same. Reported by: Alexander@leidinger.net Approved by: markj (mentor) Fixes: c21bc6f3c242 ("ddb: Add CTF-based pretty printing") --- sys/kern/kern_ctf.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/sys/kern/kern_ctf.c b/sys/kern/kern_ctf.c index b525c274f9e0..1087406ff82e 100644 --- a/sys/kern/kern_ctf.c +++ b/sys/kern/kern_ctf.c @@ -144,9 +144,12 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc) * .SUNW_ctf section containing the CTF data. */ if (hdr->e_shstrndx == 0 || shdr[hdr->e_shstrndx].sh_type != SHT_STRTAB) { - printf("%s(%d): module %s e_shstrndx is %d, sh_type is %d\n", - __func__, __LINE__, lf->pathname, hdr->e_shstrndx, - shdr[hdr->e_shstrndx].sh_type); + if (bootverbose) { + printf( + "%s(%d): module %s e_shstrndx is %d, sh_type is %d\n", + __func__, __LINE__, lf->pathname, hdr->e_shstrndx, + shdr[hdr->e_shstrndx].sh_type); + } error = EFTYPE; goto out; } @@ -167,8 +170,10 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc) /* Check if the CTF section wasn't found. */ if (i >= hdr->e_shnum) { - printf("%s(%d): module %s has no .SUNW_ctf section\n", - __func__, __LINE__, lf->pathname); + if (bootverbose) { + printf("%s(%d): module %s has no .SUNW_ctf section\n", + __func__, __LINE__, lf->pathname); + } error = EFTYPE; goto out; } @@ -181,17 +186,21 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc) /* Check the CTF magic number. */ if (cth.cth_magic != CTF_MAGIC) { - printf("%s(%d): module %s has invalid format\n", - __func__, __LINE__, lf->pathname); + if (bootverbose) { + printf("%s(%d): module %s has invalid format\n", + __func__, __LINE__, lf->pathname); + } error = EFTYPE; goto out; } if (cth.cth_version != CTF_VERSION_2 && cth.cth_version != CTF_VERSION_3) { - printf( - "%s(%d): module %s CTF format has unsupported version %d\n", - __func__, __LINE__, lf->pathname, cth.cth_version); + if (bootverbose) { + printf( + "%s(%d): module %s CTF format has unsupported version %d\n", + __func__, __LINE__, lf->pathname, cth.cth_version); + } error = EFTYPE; goto out; } @@ -250,8 +259,10 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc) ret = uncompress(ctftab + sizeof(cth), &destlen, raw + sizeof(cth), shdr[i].sh_size - sizeof(cth)); if (ret != Z_OK) { - printf("%s(%d): zlib uncompress returned %d\n", - __func__, __LINE__, ret); + if (bootverbose) { + printf("%s(%d): zlib uncompress returned %d\n", + __func__, __LINE__, ret); + } error = EIO; goto out; }