diff options
author | johnlev <none@none> | 2006-04-25 05:46:11 -0700 |
---|---|---|
committer | johnlev <none@none> | 2006-04-25 05:46:11 -0700 |
commit | 4d232658ec6831daceb12672726ce4cabe270c23 (patch) | |
tree | 10d70f3505d6a1c3cdfd97b7924426eed045c23a /usr/src/tools/ctf | |
parent | b2e86e7ad265f48a862ed7380c720874c018bf2f (diff) | |
download | illumos-gate-4d232658ec6831daceb12672726ce4cabe270c23.tar.gz |
5100576 The ctfmerge should use better temporary file name
6314988 ctfconvert's debug option can coredump
6321459 resurrect_functions doesn't skip ignored symbols
6326300 tdtrav_su can return an initialized value
6409619 write_ctf() should behave more like ld and open O_RDWR
6415503 strtab_write() reads stack garbage, bravely staggers on
Diffstat (limited to 'usr/src/tools/ctf')
-rw-r--r-- | usr/src/tools/ctf/cvt/ctf.c | 38 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/ctftools.h | 8 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/dwarf.c | 39 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/input.c | 12 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/merge.c | 29 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/output.c | 9 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/st_parse.c | 31 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/stabs.c | 13 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/tdata.c | 9 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/traverse.c | 9 | ||||
-rw-r--r-- | usr/src/tools/ctf/cvt/util.c | 26 |
11 files changed, 102 insertions, 121 deletions
diff --git a/usr/src/tools/ctf/cvt/ctf.c b/usr/src/tools/ctf/cvt/ctf.c index b428a31c77..d16febcd72 100644 --- a/usr/src/tools/ctf/cvt/ctf.c +++ b/usr/src/tools/ctf/cvt/ctf.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. */ @@ -420,8 +419,7 @@ write_type(tdesc_t *tp, ctf_buf_t *b) warning("Can't write unknown type %d\n", tp->t_type); } - debug(3, "Wrote type %d %s\n", tp->t_id, - (tp->t_name ? tp->t_name : "(anon)")); + debug(3, "Wrote type %d %s\n", tp->t_id, tdesc_name(tp)); return (1); } @@ -458,9 +456,10 @@ compress_start(resbuf_t *rb) parseterminate("zlib start failed: %s", zError(rc)); } -static void -compress_buffer(caddr_t buf, size_t n, resbuf_t *rb) +static ssize_t +compress_buffer(const void *buf, size_t n, void *data) { + resbuf_t *rb = (resbuf_t *)data; int rc; rb->rb_zstr.next_out = (Bytef *)rb->rb_ptr; @@ -476,6 +475,8 @@ compress_buffer(caddr_t buf, size_t n, resbuf_t *rb) parseterminate("zlib deflate failed: %s", zError(rc)); } rb->rb_ptr = (caddr_t)rb->rb_zstr.next_out; + + return (n); } static void @@ -524,11 +525,13 @@ pad_buffer(ctf_buf_t *buf, int align) } } -static void -bcopy_data(void *buf, size_t n, caddr_t *posp) +static ssize_t +bcopy_data(const void *buf, size_t n, void *data) { + caddr_t *posp = (caddr_t *)data; bcopy(buf, *posp, n); *posp += n; + return (n); } static caddr_t @@ -541,11 +544,10 @@ write_buffer(ctf_header_t *h, ctf_buf_t *buf, size_t *resszp) + buf->ctb_strtab.str_size); bufpos = outbuf; - bcopy_data(h, sizeof (ctf_header_t), &bufpos); - bcopy_data(buf->ctb_base, buf->ctb_ptr - buf->ctb_base, + (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, (ssize_t (*)())bcopy_data, - &bufpos) < 0) + if (strtab_write(&buf->ctb_strtab, bcopy_data, &bufpos) < 0) terminate("strtab_write failed\n"); *resszp = bufpos - outbuf; return (outbuf); @@ -567,10 +569,10 @@ write_compressed_buffer(ctf_header_t *h, ctf_buf_t *buf, size_t *resszp) resbuf.rb_ptr = resbuf.rb_base + sizeof (ctf_header_t); compress_start(&resbuf); - compress_buffer(buf->ctb_base, buf->ctb_ptr - buf->ctb_base, &resbuf); + (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, (ssize_t (*)())compress_buffer, - &resbuf) < 0) + if (strtab_write(&buf->ctb_strtab, compress_buffer, &resbuf) < 0) terminate("strtab_write failed\n"); compress_end(&resbuf); @@ -1133,7 +1135,7 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize, debug(3, "Resurrected %d %stype %s (%d)\n", tdp->t_type, (CTF_INFO_ISROOT(ctt->ctt_info) ? "root " : ""), - (tdp->t_name ? tdp->t_name : "(anon)"), tdp->t_id); + tdesc_name(tdp), tdp->t_id); } debug(3, "Resurrected %d types (%d were roots)\n", tcnt, iicnt); diff --git a/usr/src/tools/ctf/cvt/ctftools.h b/usr/src/tools/ctf/cvt/ctftools.h index a1004afe85..b15ef89b69 100644 --- a/usr/src/tools/ctf/cvt/ctftools.h +++ b/usr/src/tools/ctf/cvt/ctftools.h @@ -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. */ @@ -412,6 +411,7 @@ const char *dw_tag2str(uint_t); tdata_t *tdata_new(void); void tdata_free(tdata_t *); void tdata_build_hashes(tdata_t *td); +const char *tdesc_name(tdesc_t *); int tdesc_idhash(int, void *); int tdesc_idcmp(void *, void *); int tdesc_namehash(int, void *); diff --git a/usr/src/tools/ctf/cvt/dwarf.c b/usr/src/tools/ctf/cvt/dwarf.c index 5766066929..1ce0aafb1c 100644 --- a/usr/src/tools/ctf/cvt/dwarf.c +++ b/usr/src/tools/ctf/cvt/dwarf.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 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -754,7 +753,7 @@ die_array_resolve(tdesc_t *tdp, tdesc_t **tdpp, void *private) if ((sz = tdesc_size(tdp->t_ardef->ad_contents)) == 0) { debug(3, "unable to resolve array %s (%d) contents %d\n", - (tdp->t_name == NULL ? "(anon)" : tdp->t_name), tdp->t_id, + tdesc_name(tdp), tdp->t_id, tdp->t_ardef->ad_contents->t_id); dw->dw_nunres++; @@ -779,8 +778,7 @@ die_array_failed(tdesc_t *tdp, tdesc_t **tdpp, void *private) return (1); fprintf(stderr, "Array %d: failed to size contents type %s (%d)\n", - tdp->t_id, (cont->t_name == NULL ? "(anon)" : cont->t_name), - cont->t_id); + tdp->t_id, tdesc_name(cont), cont->t_id); return (1); } @@ -883,12 +881,12 @@ die_enum_resolve(tdesc_t *tdp, tdesc_t **tdpp, void *private) * so don't even try. */ if (full == NULL) { - terminate("tdp %u: enum %s has no members\n", - tdp->t_id, (tdp->t_name == NULL ? "(anon)" : tdp->t_name)); + terminate("tdp %u: enum %s has no members\n", tdp->t_id, + tdesc_name(tdp)); } debug(3, "tdp %u: enum %s redirected to %u\n", tdp->t_id, - (tdp->t_name == NULL ? "(anon)" : tdp->t_name), full->t_id); + tdesc_name(tdp), full->t_id); tdp->t_flags |= TDESC_F_RESOLVED; @@ -901,7 +899,7 @@ die_fwd_map(void *arg1, void *arg2) tdesc_t *fwd = arg1, *sou = arg2; debug(3, "tdp %u: mapped forward %s to sou %u\n", fwd->t_id, - fwd->t_name, sou->t_id); + tdesc_name(fwd), sou->t_id); fwd->t_tdesc = sou; return (0); @@ -925,7 +923,7 @@ die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp, debug(3, "die %llu: creating %s %s\n", off, (tdp->t_type == FORWARD ? "forward decl" : typename), - (tdp->t_name == NULL ? "(anon)" : tdp->t_name)); + tdesc_name(tdp)); if (tdp->t_type == FORWARD) { hash_add(dw->dw_fwdhash, tdp); @@ -1013,13 +1011,12 @@ die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp, * change the name. */ if (tdp->t_members == NULL) { - char *old = (tdp->t_name == NULL ? "" : tdp->t_name); + const char *old = tdesc_name(tdp); size_t newsz = 7 + strlen(old) + 1; char *new = xmalloc(newsz); (void) snprintf(new, newsz, "orphan %s", old); - debug(3, "die %llu: worked around %s %s\n", off, typename, - (tdp->t_name == NULL ? "<anon>" : tdp->t_name)); + debug(3, "die %llu: worked around %s %s\n", off, typename, old); if (tdp->t_name != NULL) free(tdp->t_name); @@ -1060,7 +1057,7 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp, void *private) if (tdp->t_flags & TDESC_F_RESOLVED) return (1); - debug(3, "resolving sou %s\n", tdp->t_name); + debug(3, "resolving sou %s\n", tdesc_name(tdp)); for (ml = tdp->t_members; ml != NULL; ml = ml->ml_next) { if (ml->ml_size == 0) { @@ -1110,8 +1107,7 @@ die_sou_failed(tdesc_t *tdp, tdesc_t **tdpp, void *private) if (ml->ml_size == 0) { fprintf(stderr, "%s %d: failed to size member %s of " "type %s (%d)\n", typename, tdp->t_id, ml->ml_name, - (ml->ml_type->t_name == NULL ? "(anon)" : - ml->ml_type->t_name), ml->ml_type->t_id); + tdesc_name(ml->ml_type), ml->ml_type->t_id); } } @@ -1393,7 +1389,7 @@ die_base_create(dwarf_t *dw, Dwarf_Die base, Dwarf_Off off, tdesc_t *tdp) if ((intr = die_base_name_parse(tdp->t_name, &new)) != NULL) { /* Found it. We'll use the parsed version */ debug(3, "die %llu: name \"%s\" remapped to \"%s\"\n", off, - tdp->t_name, new); + tdesc_name(tdp), new); free(tdp->t_name); tdp->t_name = new; @@ -1403,7 +1399,7 @@ die_base_create(dwarf_t *dw, Dwarf_Die base, Dwarf_Off off, tdesc_t *tdp) * based on the DWARF data. */ debug(3, "die %llu: using dwarf data for base \"%s\"\n", off, - tdp->t_name); + tdesc_name(tdp)); intr = die_base_from_dwarf(dw, base, off, sz); } @@ -1601,7 +1597,8 @@ die_fwd_resolve(tdesc_t *fwd, tdesc_t **fwdp, void *private) return (1); if (fwd->t_tdesc != NULL) { - debug(3, "tdp %u: unforwarded %s\n", fwd->t_id, fwd->t_name); + debug(3, "tdp %u: unforwarded %s\n", fwd->t_id, + tdesc_name(fwd)); *fwdp = fwd->t_tdesc; } diff --git a/usr/src/tools/ctf/cvt/input.c b/usr/src/tools/ctf/cvt/input.c index a29e35a1a5..664a7ba8f8 100644 --- a/usr/src/tools/ctf/cvt/input.c +++ b/usr/src/tools/ctf/cvt/input.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. */ @@ -40,6 +39,7 @@ #include "ctftools.h" #include "memory.h" +#include "symbol.h" typedef int read_cb_f(tdata_t *, char *, void *); @@ -386,6 +386,7 @@ GElf_Sym * symit_next(symit_data_t *si, int type) { GElf_Sym sym; + int check_sym = (type == STT_OBJECT || type == STT_FUNC); for (; si->si_next < si->si_nument; si->si_next++) { gelf_getsym(si->si_symd, si->si_next, &si->si_cursym); @@ -399,6 +400,9 @@ symit_next(symit_data_t *si, int type) sym.st_shndx == SHN_UNDEF) continue; + if (check_sym && ignore_symbol(&sym, si->si_curname)) + continue; + si->si_next++; return (&si->si_cursym); diff --git a/usr/src/tools/ctf/cvt/merge.c b/usr/src/tools/ctf/cvt/merge.c index 177dc8be6d..8cc11deb1a 100644 --- a/usr/src/tools/ctf/cvt/merge.c +++ b/usr/src/tools/ctf/cvt/merge.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. */ @@ -453,8 +452,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private) ed.ed_node = ctdp; ed.ed_selfuniquify = 0; - debug(3, "map_td_tree_post on %d %s\n", ctdp->t_id, - ctdp->t_name == NULL ? "(anon)" : ctdp->t_name); + debug(3, "map_td_tree_post on %d %s\n", ctdp->t_id, tdesc_name(ctdp)); if (hash_find_iter(mcd->md_parent->td_layouthash, ctdp, equiv_cb, &ed) < 0) { @@ -479,7 +477,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private) * means that the "name" hash function is broken. */ terminate("Second pass for %d (%s) == %d\n", ctdp->t_id, - (ctdp->t_name ? ctdp->t_name : "(anon)"), ed.ed_tgt->t_id); + tdesc_name(ctdp), ed.ed_tgt->t_id); } else { int id = mcd->md_tgt->td_nextid++; @@ -521,8 +519,7 @@ map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private) * function is broken. */ terminate("Self-unique second pass for %d (%s) == %d\n", - ctdp->t_id, (ctdp->t_name ? ctdp->t_name : "(anon)"), - ed.ed_tgt->t_id); + ctdp->t_id, tdesc_name(ctdp), ed.ed_tgt->t_id); } else { int id = mcd->md_tgt->td_nextid++; @@ -878,8 +875,7 @@ fwd_redir(tdesc_t *fwd, tdesc_t **fwdp, void *private) if (!alist_find(map, (void *)fwd, (void **)&defn)) return (0); - debug(3, "Redirecting an edge to %s\n", - (defn->t_name ? defn->t_name : "(anon)")); + debug(3, "Redirecting an edge to %s\n", tdesc_name(defn)); *fwdp = defn; @@ -922,11 +918,10 @@ 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, - (defn->t_name ? defn->t_name : "(anon)")); + tdesc_name(defn)); } - debug(3, "Forward map: resolved %d to %s\n", - defnid, (defn->t_name ? defn->t_name : "(anon)")); + debug(3, "Forward map: resolved %d to %s\n", defnid, tdesc_name(defn)); alist_add(rmd->rmd_map, (void *)fwd, (void *)defn); @@ -993,8 +988,7 @@ add_tdesc(tdesc_t *oldtdp, int newid, merge_cb_data_t *mcd) (void *)&template, NULL) == 0); debug(3, "trying to conjure %d %s (%d) as %d\n", - oldtdp->t_type, (oldtdp->t_name ? oldtdp->t_name : "(anon)"), - oldtdp->t_id, newid); + oldtdp->t_type, tdesc_name(oldtdp), oldtdp->t_id, newid); if ((newtdp = tdesc_ops[oldtdp->t_type].conjure(oldtdp, newid, mcd)) == NULL) @@ -1032,8 +1026,7 @@ add_tdtbr_cb(void *data, void *arg) tdesc_t **tdpp = data; merge_cb_data_t *mcd = arg; - debug(3, "Remapping %s (%d)\n", - ((*tdpp)->t_name ? (*tdpp)->t_name : "(anon)"), (*tdpp)->t_id); + debug(3, "Remapping %s (%d)\n", tdesc_name(*tdpp), (*tdpp)->t_id); if (!remap_node(tdpp, *tdpp, -1, NULL, mcd)) return (0); diff --git a/usr/src/tools/ctf/cvt/output.c b/usr/src/tools/ctf/cvt/output.c index 7065daca0d..4ecc47bc8f 100644 --- a/usr/src/tools/ctf/cvt/output.c +++ b/usr/src/tools/ctf/cvt/output.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. */ @@ -708,7 +707,7 @@ write_ctf(tdata_t *td, const char *curname, const char *newname, int flags) if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) elfterminate(curname, "Cannot re-read"); - if ((tfd = open(newname, O_WRONLY | O_CREAT | O_TRUNC, st.st_mode)) < 0) + if ((tfd = open(newname, O_RDWR | O_CREAT | O_TRUNC, st.st_mode)) < 0) terminate("Cannot open temp file %s for writing", newname); if ((telf = elf_begin(tfd, ELF_C_WRITE, NULL)) == NULL) elfterminate(curname, "Cannot write"); diff --git a/usr/src/tools/ctf/cvt/st_parse.c b/usr/src/tools/ctf/cvt/st_parse.c index 589e89459f..04bb40579e 100644 --- a/usr/src/tools/ctf/cvt/st_parse.c +++ b/usr/src/tools/ctf/cvt/st_parse.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. */ @@ -372,8 +371,7 @@ parse_sou(char *cp, iidesc_t *idp) tdp->t_tdesc = rtdp; addhash(tdp, tid); /* for *(x,y) types */ parse_debug(3, NULL, " %s defined as %s(%d)", - idp->ii_name, (rtdp->t_name != NULL) ? - rtdp->t_name : "anon", tid); + idp->ii_name, tdesc_name(rtdp), tid); } else if (rtdp->t_name == NULL) { rtdp->t_name = xstrdup(idp->ii_name); addhash(rtdp, tid); @@ -561,11 +559,9 @@ tagadd(char *w, int h, tdesc_t *tdp) addhash(tdp, h); else if (otdp != tdp) { warning("duplicate entry\n"); - warning(" old: %s %d (%d,%d)\n", - otdp->t_name ? otdp->t_name : "(anon)", + warning(" old: %s %d (%d,%d)\n", tdesc_name(otdp), otdp->t_type, TYPEFILE(otdp->t_id), TYPENUM(otdp->t_id)); - warning(" new: %s %d (%d,%d)\n", - tdp->t_name ? tdp->t_name : "(anon)", + warning(" new: %s %d (%d,%d)\n", tdesc_name(tdp), tdp->t_type, TYPEFILE(tdp->t_id), TYPENUM(tdp->t_id)); return (-1); } @@ -912,8 +908,7 @@ soudef(char *cp, stabtype_t type, tdesc_t **rtdp) cp += 3; } - parse_debug(3, cp, "soudef: %s size=%d", - (*rtdp)->t_name ? (*rtdp)->t_name : "(anonsou)", + parse_debug(3, cp, "soudef: %s size=%d", tdesc_name(*rtdp), (*rtdp)->t_size); prev = &((*rtdp)->t_members); @@ -954,8 +949,7 @@ soudef(char *cp, stabtype_t type, tdesc_t **rtdp) } } else { parse_debug(3, NULL, " refers to %s (%d, %s)", - w ? w : "anon", h, - tdp->t_name ? tdp->t_name : "anon"); + w ? w : "anon", h, tdesc_name(tdp)); } cp = offsize(cp, mlp); @@ -964,7 +958,7 @@ soudef(char *cp, stabtype_t type, tdesc_t **rtdp) if (itdp->t_type == INTRINSIC) { if (mlp->ml_size != itdp->t_intr->intr_nbits) { parse_debug(4, cp, "making %d bit intrinsic " - "from %s", mlp->ml_size, itdp->t_name); + "from %s", mlp->ml_size, tdesc_name(itdp)); mlp->ml_type = bitintrinsic(itdp, mlp->ml_size); } else mlp->ml_type = tdp; @@ -1037,8 +1031,7 @@ enumdef(char *cp, tdesc_t **rtdp) cp = name(cp, &w); elp->el_name = w; cp = number(cp, &elp->el_number); - parse_debug(3, NULL, "enum %s: %s=%d", - (*rtdp)->t_name ? (*rtdp)->t_name : "(anon enum)", + parse_debug(3, NULL, "enum %s: %s=%d", tdesc_name(*rtdp), elp->el_name, elp->el_number); prev = &elp->el_next; if (*cp++ != ',') @@ -1171,11 +1164,11 @@ resolve_typed_bitfields_cb(mlist_t *ml, void *private) case INTRINSIC: if (ml->ml_size != tdp->t_intr->intr_nbits) { debug(3, "making %d bit intrinsic from %s", - ml->ml_size, tdp->t_name); + ml->ml_size, tdesc_name(tdp)); ml->ml_type = bitintrinsic(tdp, ml->ml_size); } else { debug(3, "using existing %d bit %s intrinsic", - ml->ml_size, tdp->t_name); + ml->ml_size, tdesc_name(tdp)); ml->ml_type = tdp; } return (1); diff --git a/usr/src/tools/ctf/cvt/stabs.c b/usr/src/tools/ctf/cvt/stabs.c index b6857a6e2b..79a93e026b 100644 --- a/usr/src/tools/ctf/cvt/stabs.c +++ b/usr/src/tools/ctf/cvt/stabs.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. */ @@ -64,8 +63,7 @@ resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private) { tdesc_t *new; - debug(3, "Trying to resolve %s (%d)\n", - (node->t_name ? node->t_name : "(anon)"), node->t_id); + debug(3, "Trying to resolve %s (%d)\n", tdesc_name(node), node->t_id); new = lookup(node->t_id); if (new == NULL) { @@ -85,8 +83,7 @@ resolve_fwd_node(tdesc_t *node, tdesc_t **nodep, void *private) { tdesc_t *new = lookupname(node->t_name); - debug(3, "Trying to unforward %s (%d)\n", - (node->t_name ? node->t_name : "(anon)"), node->t_id); + debug(3, "Trying to unforward %s (%d)\n", tdesc_name(node), node->t_id); if (!new || (new->t_type != STRUCT && new->t_type != UNION)) return (0); diff --git a/usr/src/tools/ctf/cvt/tdata.c b/usr/src/tools/ctf/cvt/tdata.c index fd37d1e142..32d84829d7 100644 --- a/usr/src/tools/ctf/cvt/tdata.c +++ b/usr/src/tools/ctf/cvt/tdata.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. */ @@ -181,7 +180,7 @@ tdesc_print(void *data, void *private) { tdesc_t *tdp = data; - printf("%7d %s\n", tdp->t_id, (tdp->t_name ? tdp->t_name : "(anon)")); + printf("%7d %s\n", tdp->t_id, tdesc_name(tdp)); return (1); } diff --git a/usr/src/tools/ctf/cvt/traverse.c b/usr/src/tools/ctf/cvt/traverse.c index 98f1373c23..b415b35af6 100644 --- a/usr/src/tools/ctf/cvt/traverse.c +++ b/usr/src/tools/ctf/cvt/traverse.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. */ @@ -95,7 +94,7 @@ static int tdtrav_su(tdesc_t *this, tdtrav_data_t *tdtd) { mlist_t *ml; - int rc; + int rc = 0; for (ml = this->t_members; ml; ml = ml->ml_next) { if ((rc = tdtraverse(ml->ml_type, &ml->ml_type, tdtd)) < 0) diff --git a/usr/src/tools/ctf/cvt/util.c b/usr/src/tools/ctf/cvt/util.c index 2add463248..6b4f4f2d9c 100644 --- a/usr/src/tools/ctf/cvt/util.c +++ b/usr/src/tools/ctf/cvt/util.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. */ @@ -175,18 +174,11 @@ debug(int level, char *format, ...) char * mktmpname(const char *origname, const char *suffix) { - const char *dot; char *newname; - size_t newlen; - - if (!(dot = strrchr(origname, '.'))) - dot = origname + strlen(origname); - - newlen = dot - origname + strlen(suffix) + 1; - newname = xmalloc(newlen); - snprintf(newname, newlen, "%*.*s%s", dot - origname, dot - origname, - origname, suffix); + newname = xmalloc(strlen(origname) + strlen(suffix) + 1); + (void) strcpy(newname, origname); + (void) strcat(newname, suffix); return (newname); } @@ -203,3 +195,9 @@ elfterminate(const char *file, const char *fmt, ...) terminate("%s: %s: %s\n", file, msgbuf, elf_errmsg(elf_errno())); } + +const char * +tdesc_name(tdesc_t *tdp) +{ + return (tdp->t_name == NULL ? "(anon)" : tdp->t_name); +} |