summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorjohnlev <none@none>2006-05-09 04:32:25 -0700
committerjohnlev <none@none>2006-05-09 04:32:25 -0700
commitc168da277d64ace98b478c694fd808f783ce7d2e (patch)
treeb19514d130bf1dfbb2ead3000c1e32cc32f260be /usr/src
parent20e0c306d13b54840b7f8b12a43090fcb2bdbc04 (diff)
downloadillumos-joyent-c168da277d64ace98b478c694fd808f783ce7d2e.tar.gz
6418593 ctfmerge error messages need improvement
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/tools/ctf/cvt/ctf.c6
-rw-r--r--usr/src/tools/ctf/cvt/ctfconvert.c15
-rw-r--r--usr/src/tools/ctf/cvt/ctftools.h4
-rw-r--r--usr/src/tools/ctf/cvt/dwarf.c2
-rw-r--r--usr/src/tools/ctf/cvt/input.c6
-rw-r--r--usr/src/tools/ctf/cvt/merge.c10
-rw-r--r--usr/src/tools/ctf/cvt/output.c5
-rw-r--r--usr/src/tools/ctf/cvt/stabs.c34
-rw-r--r--usr/src/tools/ctf/cvt/util.c54
9 files changed, 76 insertions, 60 deletions
diff --git a/usr/src/tools/ctf/cvt/ctf.c b/usr/src/tools/ctf/cvt/ctf.c
index d16febcd72..91e0f611cb 100644
--- a/usr/src/tools/ctf/cvt/ctf.c
+++ b/usr/src/tools/ctf/cvt/ctf.c
@@ -547,8 +547,7 @@ write_buffer(ctf_header_t *h, ctf_buf_t *buf, size_t *resszp)
(void) bcopy_data(h, sizeof (ctf_header_t), &bufpos);
(void) bcopy_data(buf->ctb_base, buf->ctb_ptr - buf->ctb_base,
&bufpos);
- if (strtab_write(&buf->ctb_strtab, bcopy_data, &bufpos) < 0)
- terminate("strtab_write failed\n");
+ (void) strtab_write(&buf->ctb_strtab, bcopy_data, &bufpos);
*resszp = bufpos - outbuf;
return (outbuf);
}
@@ -572,8 +571,7 @@ write_compressed_buffer(ctf_header_t *h, ctf_buf_t *buf, size_t *resszp)
(void) compress_buffer(buf->ctb_base, buf->ctb_ptr - buf->ctb_base,
&resbuf);
compress_flush(&resbuf, Z_FULL_FLUSH);
- if (strtab_write(&buf->ctb_strtab, compress_buffer, &resbuf) < 0)
- terminate("strtab_write failed\n");
+ (void) strtab_write(&buf->ctb_strtab, compress_buffer, &resbuf);
compress_end(&resbuf);
*resszp = (resbuf.rb_ptr - resbuf.rb_base);
diff --git a/usr/src/tools/ctf/cvt/ctfconvert.c b/usr/src/tools/ctf/cvt/ctfconvert.c
index bd5ba964b0..756549e545 100644
--- a/usr/src/tools/ctf/cvt/ctfconvert.c
+++ b/usr/src/tools/ctf/cvt/ctfconvert.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -99,7 +98,7 @@ file_read(tdata_t *td, const char *filename, int ignore_non_c)
if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
close(fd);
terminate("failed to read %s: %s\n", filename,
- elf_errmsg(elf_errno()));
+ elf_errmsg(-1));
}
source_types = built_source_types(elf, filename);
@@ -122,8 +121,10 @@ file_read(tdata_t *td, const char *filename, int ignore_non_c)
* None of the readers found compatible type data.
*/
- if (findelfsecidx(elf, ".debug") >= 0)
- terminate("DWARF version 1 is not supported\n");
+ if (findelfsecidx(elf, filename, ".debug") >= 0) {
+ terminate("%s: DWARF version 1 is not supported\n",
+ filename);
+ }
if (!(source_types & SOURCE_C) && ignore_non_c) {
debug(1, "Ignoring file %s not built from C sources\n",
diff --git a/usr/src/tools/ctf/cvt/ctftools.h b/usr/src/tools/ctf/cvt/ctftools.h
index b15ef89b69..76bd58292e 100644
--- a/usr/src/tools/ctf/cvt/ctftools.h
+++ b/usr/src/tools/ctf/cvt/ctftools.h
@@ -428,11 +428,11 @@ void tdata_label_newmax(tdata_t *, int);
/* util.c */
int streq(char *, char *);
-int findelfsecidx(Elf *, char *);
+int findelfsecidx(Elf *, const char *, const char *);
char *mktmpname(const char *, const char *);
void terminate(char *, ...);
+void aborterr(char *, ...);
void set_terminate_cleanup(void (*)());
-void vaterminate(char *, va_list);
void elfterminate(const char *, const char *, ...);
void warning(char *, ...);
void vadebug(int, char *, va_list);
diff --git a/usr/src/tools/ctf/cvt/dwarf.c b/usr/src/tools/ctf/cvt/dwarf.c
index 1ce0aafb1c..c8ad300354 100644
--- a/usr/src/tools/ctf/cvt/dwarf.c
+++ b/usr/src/tools/ctf/cvt/dwarf.c
@@ -1778,7 +1778,7 @@ elf_ptrsz(Elf *elf)
if (gelf_getehdr(elf, &ehdr) == NULL) {
terminate("failed to read ELF header: %s\n",
- elf_errmsg(elf_errno()));
+ elf_errmsg(-1));
}
if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
diff --git a/usr/src/tools/ctf/cvt/input.c b/usr/src/tools/ctf/cvt/input.c
index 664a7ba8f8..d901e5340b 100644
--- a/usr/src/tools/ctf/cvt/input.c
+++ b/usr/src/tools/ctf/cvt/input.c
@@ -92,7 +92,7 @@ read_file(Elf *elf, char *file, char *label, read_cb_f *func, void *arg,
int ctfscnidx;
tdata_t *td;
- if ((ctfscnidx = findelfsecidx(elf, ".SUNW_ctf")) < 0) {
+ if ((ctfscnidx = findelfsecidx(elf, file, ".SUNW_ctf")) < 0) {
if (require_ctf &&
(built_source_types(elf, file) & SOURCE_C)) {
terminate("Input file %s was partially built from "
@@ -294,7 +294,7 @@ count_files(char **files, int n)
if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
warning("Can't open input file %s: %s\n", file,
- elf_errmsg(elf_errno()));
+ elf_errmsg(-1));
err++;
(void) close(fd);
continue;
@@ -345,7 +345,7 @@ symit_new(Elf *elf, const char *file)
Elf_Scn *scn;
int symtabidx;
- if ((symtabidx = findelfsecidx(elf, ".symtab")) < 0)
+ if ((symtabidx = findelfsecidx(elf, file, ".symtab")) < 0)
return (NULL);
si = xcalloc(sizeof (symit_data_t));
diff --git a/usr/src/tools/ctf/cvt/merge.c b/usr/src/tools/ctf/cvt/merge.c
index 8cc11deb1a..2af28b65a2 100644
--- a/usr/src/tools/ctf/cvt/merge.c
+++ b/usr/src/tools/ctf/cvt/merge.c
@@ -476,7 +476,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
* exhaustive search through the entire graph. This usually
* means that the "name" hash function is broken.
*/
- terminate("Second pass for %d (%s) == %d\n", ctdp->t_id,
+ aborterr("Second pass for %d (%s) == %d\n", ctdp->t_id,
tdesc_name(ctdp), ed.ed_tgt->t_id);
} else {
int id = mcd->md_tgt->td_nextid++;
@@ -518,7 +518,7 @@ map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
* through the entire hash. This usually means that the hash
* function is broken.
*/
- terminate("Self-unique second pass for %d (%s) == %d\n",
+ aborterr("Self-unique second pass for %d (%s) == %d\n",
ctdp->t_id, tdesc_name(ctdp), ed.ed_tgt->t_id);
} else {
int id = mcd->md_tgt->td_nextid++;
@@ -696,7 +696,7 @@ remap_node(tdesc_t **tgtp, tdesc_t *oldtgt, int selftid, tdesc_t *newself,
}
if ((template.t_id = get_mapping(mcd->md_ta, oldid)) == 0)
- terminate("failed to get mapping for tid %d\n", oldid);
+ aborterr("failed to get mapping for tid %d\n", oldid);
if (!hash_find(mcd->md_parent->td_idhash, (void *)&template,
(void *)&tgt) && (!(mcd->md_flags & MCD_F_REFMERGE) ||
@@ -917,7 +917,7 @@ redir_mstr_fwd_cb(void *name, void *value, void *arg)
if (!hash_find(rmd->rmd_tgt->td_idhash, (void *)&template,
(void *)&defn)) {
- terminate("Couldn't unforward %d (%s)\n", defnid,
+ aborterr("Couldn't unforward %d (%s)\n", defnid,
tdesc_name(defn));
}
@@ -1062,7 +1062,7 @@ merge_types(hash_t *src, merge_cb_data_t *mcd)
debug(3, "add_tdtbr_cb added %d items\n", tdrc);
if (list_count(*mcd->md_tdtbr) != 0)
- terminate("Couldn't remap all nodes\n");
+ aborterr("Couldn't remap all nodes\n");
/*
* We now have an alist of master forwards and the ids of the new master
diff --git a/usr/src/tools/ctf/cvt/output.c b/usr/src/tools/ctf/cvt/output.c
index 4ecc47bc8f..ea7469b282 100644
--- a/usr/src/tools/ctf/cvt/output.c
+++ b/usr/src/tools/ctf/cvt/output.c
@@ -344,7 +344,8 @@ sort_iidescs(Elf *elf, const char *file, tdata_t *td, int fuzzymatch,
match.iim_fuzzy = fuzzymatch;
match.iim_file = NULL;
- if ((stidx = findelfsecidx(elf, dynsym ? ".dynsym" : ".symtab")) < 0)
+ if ((stidx = findelfsecidx(elf, file,
+ dynsym ? ".dynsym" : ".symtab")) < 0)
terminate("%s: Can't open symbol table\n", file);
scn = elf_getscn(elf, stidx);
data = elf_getdata(scn, NULL);
@@ -626,7 +627,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
}
if (symtab_idx == -1) {
- terminate("Cannot find %s section\n",
+ terminate("%s: Cannot find %s section\n", srcname,
dynsym ? "SHT_DYNSYM" : "SHT_SYMTAB");
}
diff --git a/usr/src/tools/ctf/cvt/stabs.c b/usr/src/tools/ctf/cvt/stabs.c
index 79a93e026b..666afe871c 100644
--- a/usr/src/tools/ctf/cvt/stabs.c
+++ b/usr/src/tools/ctf/cvt/stabs.c
@@ -174,7 +174,7 @@ fnarg_free(iidesc_t *ii)
* assembled under an iidesc list.
*/
int
-stabs_read(tdata_t *td, Elf *elf, const char *filename)
+stabs_read(tdata_t *td, Elf *elf, const char *file)
{
Elf_Scn *scn;
Elf_Data *data;
@@ -190,18 +190,18 @@ stabs_read(tdata_t *td, Elf *elf, const char *filename)
int nstabs, rc, i;
int scope = 0;
- if (!((stabidx = findelfsecidx(elf, ".stab.excl")) >= 0 &&
- (stabstridx = findelfsecidx(elf, ".stab.exclstr")) >= 0) &&
- !((stabidx = findelfsecidx(elf, ".stab")) >= 0 &&
- (stabstridx = findelfsecidx(elf, ".stabstr")) >= 0)) {
+ if (!((stabidx = findelfsecidx(elf, file, ".stab.excl")) >= 0 &&
+ (stabstridx = findelfsecidx(elf, file, ".stab.exclstr")) >= 0) &&
+ !((stabidx = findelfsecidx(elf, file, ".stab")) >= 0 &&
+ (stabstridx = findelfsecidx(elf, file, ".stabstr")) >= 0)) {
errno = ENOENT;
return (-1);
}
file_stack = stack_new(free);
- stack_push(file_stack, (void *)filename);
- curhdr = filename;
+ stack_push(file_stack, (void *)file);
+ curhdr = file;
debug(3, "Found stabs in %d, strings in %d\n", stabidx, stabstridx);
@@ -249,8 +249,8 @@ stabs_read(tdata_t *td, Elf *elf, const char *filename)
if ((str = elf_strptr(elf, stabstridx,
(size_t)stab->n_strx)) == NULL) {
- terminate("Can't find string at %u for stab %d\n",
- stab->n_strx, i);
+ terminate("%s: Can't find string at %u for stab %d\n",
+ file, stab->n_strx, i);
}
if (stab->n_type == N_BINCL) {
@@ -265,8 +265,8 @@ stabs_read(tdata_t *td, Elf *elf, const char *filename)
continue;
} else if (stab->n_type == N_OPT) {
if (strcmp(str, "gcc2_compiled.") == 0) {
- terminate("GCC-generated stabs are "
- "unsupported. Use DWARF instead.\n");
+ terminate("%s: GCC-generated stabs are "
+ "unsupported. Use DWARF instead.\n", file);
}
continue;
}
@@ -312,9 +312,12 @@ stabs_read(tdata_t *td, Elf *elf, const char *filename)
ofstr = fstr;
iidescp = NULL;
- if ((rc = parse_stab(stab, fstr, &iidescp)) < 0)
- terminate("Couldn't parse stab \"%s\" (file %s)\n",
- str, curhdr);
+
+ if ((rc = parse_stab(stab, fstr, &iidescp)) < 0) {
+ terminate("%s: Couldn't parse stab \"%s\" "
+ "(source file %s)\n", file, str, curhdr);
+ }
+
if (rc == 0)
goto parse_loop_end;
@@ -356,7 +359,8 @@ stabs_read(tdata_t *td, Elf *elf, const char *filename)
iidesc_free(iidescp, NULL);
break;
default:
- terminate("Unknown iidesc type %d\n", iidescp->ii_type);
+ aborterr("invalid ii_type %d for stab type %d",
+ iidescp->ii_type, stab->n_type);
}
parse_loop_end:
diff --git a/usr/src/tools/ctf/cvt/util.c b/usr/src/tools/ctf/cvt/util.c
index 6b4f4f2d9c..c7857fb1ab 100644
--- a/usr/src/tools/ctf/cvt/util.c
+++ b/usr/src/tools/ctf/cvt/util.c
@@ -61,24 +61,29 @@ streq(char *s1, char *s2)
}
int
-findelfsecidx(Elf *elf, char *tofind)
+findelfsecidx(Elf *elf, const char *file, const char *tofind)
{
Elf_Scn *scn = NULL;
GElf_Ehdr ehdr;
GElf_Shdr shdr;
- if (gelf_getehdr(elf, &ehdr) == NULL) {
- terminate("gelf_getehdr: %s\n", elf_errmsg(elf_errno()));
- }
+ if (gelf_getehdr(elf, &ehdr) == NULL)
+ elfterminate(file, "Couldn't read ehdr");
while ((scn = elf_nextscn(elf, scn)) != NULL) {
char *name;
- if (gelf_getshdr(scn, &shdr) == NULL ||
- (name = elf_strptr(elf, ehdr.e_shstrndx,
+ if (gelf_getshdr(scn, &shdr) == NULL) {
+ elfterminate(file,
+ "Couldn't read header for section %d",
+ elf_ndxscn(scn));
+ }
+
+ if ((name = elf_strptr(elf, ehdr.e_shstrndx,
(size_t)shdr.sh_name)) == NULL) {
- terminate("gelf_getehdr: %s\n",
- elf_errmsg(elf_errno()));
+ elfterminate(file,
+ "Couldn't get name for section %d",
+ elf_ndxscn(scn));
}
if (strcmp(name, tofind) == 0)
@@ -102,12 +107,6 @@ whine(char *type, char *format, va_list ap)
}
void
-vaterminate(char *format, va_list ap)
-{
- whine("ERROR", format, ap);
-}
-
-void
set_terminate_cleanup(void (*cleanup)())
{
terminate_cleanup = cleanup;
@@ -117,22 +116,35 @@ set_terminate_cleanup(void (*cleanup)())
void
terminate(char *format, ...)
{
- if (format) {
- va_list ap;
+ va_list ap;
- va_start(ap, format);
- whine("ERROR", format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ whine("ERROR", format, ap);
+ va_end(ap);
if (terminate_cleanup)
terminate_cleanup();
+ if (getenv("CTF_ABORT_ON_TERMINATE") != NULL)
+ abort();
exit(1);
}
/*PRINTFLIKE1*/
void
+aborterr(char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ whine("ERROR", format, ap);
+ va_end(ap);
+
+ abort();
+}
+
+/*PRINTFLIKE1*/
+void
warning(char *format, ...)
{
va_list ap;
@@ -193,7 +205,7 @@ elfterminate(const char *file, const char *fmt, ...)
vsnprintf(msgbuf, sizeof (msgbuf), fmt, ap);
va_end(ap);
- terminate("%s: %s: %s\n", file, msgbuf, elf_errmsg(elf_errno()));
+ terminate("%s: %s: %s\n", file, msgbuf, elf_errmsg(-1));
}
const char *