diff options
Diffstat (limited to 'cddl/contrib/opensolaris/tools/ctf')
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c | 27 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c | 30 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h | 9 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c | 34 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c | 9 |
5 files changed, 78 insertions, 31 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c index d95dd1d..e3ec1e1 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Create and parse buffers containing CTF data. */ @@ -174,6 +172,12 @@ write_functions(iidesc_t *idp, ctf_buf_t *b) } nargs = idp->ii_nargs + (idp->ii_vargs != 0); + + if (nargs > CTF_MAX_VLEN) { + terminate("function %s has too many args: %d > %d\n", + idp->ii_name, nargs, CTF_MAX_VLEN); + } + fdata[0] = CTF_TYPE_INFO(CTF_K_FUNCTION, 1, nargs); fdata[1] = idp->ii_dtype->t_id; ctf_buf_write(b, fdata, sizeof (fdata)); @@ -316,6 +320,11 @@ write_type(void *arg1, void *arg2) for (i = 0, mp = tp->t_members; mp != NULL; mp = mp->ml_next) i++; /* count up struct or union members */ + if (i > CTF_MAX_VLEN) { + terminate("sou %s has too many members: %d > %d\n", + tdesc_name(tp), i, CTF_MAX_VLEN); + } + if (tp->t_type == STRUCT) ctt.ctt_info = CTF_TYPE_INFO(CTF_K_STRUCT, isroot, i); else @@ -398,8 +407,14 @@ write_type(void *arg1, void *arg2) break; case FUNCTION: - ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FUNCTION, isroot, - tp->t_fndef->fn_nargs + tp->t_fndef->fn_vargs); + i = tp->t_fndef->fn_nargs + tp->t_fndef->fn_vargs; + + if (i > CTF_MAX_VLEN) { + terminate("function %s has too many args: %d > %d\n", + i, CTF_MAX_VLEN); + } + + ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FUNCTION, isroot, i); ctt.ctt_type = tp->t_fndef->fn_ret->t_id; write_unsized_type_rec(b, &ctt); @@ -938,7 +953,7 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize, if (CTF_NAME_STID(ctt->ctt_name) != CTF_STRTAB_0) parseterminate( - "Unable to cope with non-zero strtab id"); + "Unable to cope with non-zero strtab id"); if (CTF_NAME_OFFSET(ctt->ctt_name) != 0) { tdp->t_name = xstrdup(sbuf + CTF_NAME_OFFSET(ctt->ctt_name)); diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c index 546dcdf..fa4fbeb 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -650,6 +650,7 @@ wq_init(workqueue_t *wq, int nfiles) wq->wq_wip = xcalloc(sizeof (wip_t) * nslots); wq->wq_nwipslots = nslots; wq->wq_nthreads = MIN(sysconf(_SC_NPROCESSORS_ONLN) * 3 / 2, nslots); + wq->wq_thread = xmalloc(sizeof (pthread_t) * wq->wq_nthreads); if (getenv("CTFMERGE_INPUT_THROTTLE")) throttle = atoi(getenv("CTFMERGE_INPUT_THROTTLE")); @@ -692,7 +693,6 @@ wq_init(workqueue_t *wq, int nfiles) static void start_threads(workqueue_t *wq) { - pthread_t thrid; sigset_t sets; int i; @@ -703,8 +703,8 @@ start_threads(workqueue_t *wq) pthread_sigmask(SIG_BLOCK, &sets, NULL); for (i = 0; i < wq->wq_nthreads; i++) { - pthread_create(&thrid, NULL, (void *(*)(void *))worker_thread, - wq); + pthread_create(&wq->wq_thread[i], NULL, + (void *(*)(void *))worker_thread, wq); } #if defined(sun) @@ -719,6 +719,16 @@ start_threads(workqueue_t *wq) pthread_sigmask(SIG_UNBLOCK, &sets, NULL); } +static void +join_threads(workqueue_t *wq) +{ + int i; + + for (i = 0; i < wq->wq_nthreads; i++) { + pthread_join(wq->wq_thread[i], NULL); + } +} + static int strcompare(const void *p1, const void *p2) { @@ -728,10 +738,18 @@ strcompare(const void *p1, const void *p2) return (strcmp(s1, s2)); } +/* + * Core work queue structure; passed to worker threads on thread creation + * as the main point of coordination. Allocate as a static structure; we + * could have put this into a local variable in main, but passing a pointer + * into your stack to another thread is fragile at best and leads to some + * hard-to-debug failure modes. + */ +static workqueue_t wq; + int main(int argc, char **argv) { - workqueue_t wq; tdata_t *mstrtd, *savetd; char *uniqfile = NULL, *uniqlabel = NULL; char *withfile = NULL; @@ -913,6 +931,8 @@ main(int argc, char **argv) pthread_cond_wait(&wq.wq_alldone_cv, &wq.wq_queue_lock); pthread_mutex_unlock(&wq.wq_queue_lock); + join_threads(&wq); + /* * All requested files have been merged, with the resulting tree in * mstrtd. savetd is the tree that will be placed into the output file. diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h index 38560ea..ce40803 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.h +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.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 2002-2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -78,6 +77,8 @@ typedef struct workqueue { int wq_nomorefiles; + pthread_t *wq_thread; + barrier_t wq_bar1; barrier_t wq_bar2; } workqueue_t; diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c b/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c index 5364320..1dca82a 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c @@ -19,12 +19,9 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This file is a sewer. */ @@ -481,7 +478,8 @@ whitesp(char *cp) { char c; - for (c = *cp++; isspace(c); c = *cp++); + for (c = *cp++; isspace(c); c = *cp++) + ; --cp; return (cp); } @@ -496,8 +494,8 @@ name(char *cp, char **w) c = *cp++; if (c == ':') *w = NULL; - else if (isalpha(c) || strchr("_.$", c)) { - for (c = *cp++; isalnum(c) || strchr(" _.$", c); c = *cp++) + else if (isalpha(c) || strchr("_.$#", c)) { + for (c = *cp++; isalnum(c) || strchr(" _.$#", c); c = *cp++) ; if (c != ':') reset(); @@ -990,14 +988,28 @@ arraydef(char *cp, tdesc_t **rtdp) expected("arraydef/2", ";", cp - 1); if (*cp == 'S') { - /* variable length array - treat as null dimensioned */ + /* + * variable length array - treat as null dimensioned + * + * For VLA variables on sparc, SS12 generated stab entry + * looks as follows: + * .stabs "buf:(0,28)=zr(0,4);0;S-12;(0,1)", 0x80, 0, 0, -16 + * Whereas SS12u1 generated stab entry looks like this: + * .stabs "buf:(0,28)=zr(0,4);0;S0;(0,1)", 0x80, 0, 0, 0 + * On x86, both versions generate the first type of entry. + * We should be able to parse both. + */ cp++; - if (*cp++ != '-') - expected("arraydef/fpoff-sep", "-", cp - 1); + if (*cp == '-') + cp++; cp = number(cp, &end); end = start; } else { - /* normal fixed-dimension array */ + /* + * normal fixed-dimension array + * Stab entry for this looks as follows : + * .stabs "x:(0,28)=ar(0,4);0;9;(0,3)", 0x80, 0, 40, 0 + */ cp = number(cp, &end); /* upper */ } diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c index 4a0cc79..1ccd6cd 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Routines for manipulating tdesc and tdata structures */ @@ -86,9 +84,10 @@ tdesc_layouthash(int nbuckets, void *node) * Unnamed structures, which cannot have forward * declarations pointing to them. We can therefore * incorporate the name of the first member into - * the hash value. + * the hash value, assuming there are any. */ - name = tdp->t_members->ml_name; + if (tdp->t_members != NULL) + name = tdp->t_members->ml_name; break; case ENUM: /* Use the first element in the hash value */ |