From owner-svn-src-vendor@FreeBSD.ORG Sat Apr 6 08:06:27 2013 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 05F0AA5A; Sat, 6 Apr 2013 08:06:27 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DCC0D3D2; Sat, 6 Apr 2013 08:06:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3686Qng005693; Sat, 6 Apr 2013 08:06:26 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3686QAP005690; Sat, 6 Apr 2013 08:06:26 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201304060806.r3686QAP005690@svn.freebsd.org> From: Martin Matuska Date: Sat, 6 Apr 2013 08:06:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r249187 - in vendor/illumos/dist: cmd/dtrace/test/tst/common/print lib/libdtrace/common X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Apr 2013 08:06:27 -0000 Author: mm Date: Sat Apr 6 08:06:25 2013 New Revision: 249187 URL: http://svnweb.freebsd.org/changeset/base/249187 Log: Update vendor/illumos/dist to illumos-gate 14004:dd91fed709a7 Illumos DTrace issues: 3675 DTrace print() should try to resolve function pointers 3676 dt_print_enum hardcodes a value of zero Added: vendor/illumos/dist/cmd/dtrace/test/tst/common/print/tst.enum.d vendor/illumos/dist/cmd/dtrace/test/tst/common/print/tst.enum.d.out Modified: vendor/illumos/dist/lib/libdtrace/common/dt_print.c Added: vendor/illumos/dist/cmd/dtrace/test/tst/common/print/tst.enum.d ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/illumos/dist/cmd/dtrace/test/tst/common/print/tst.enum.d Sat Apr 6 08:06:25 2013 (r249187) @@ -0,0 +1,33 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +enum simpson { + homer, + marge, + bart, + lisa, + maggie, + snowball_ii, + santas_little_helper +}; + +BEGIN +{ + print(bart); + print((enum simpson)4); + print(snowball_ii); + exit(0); +} Added: vendor/illumos/dist/cmd/dtrace/test/tst/common/print/tst.enum.d.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/illumos/dist/cmd/dtrace/test/tst/common/print/tst.enum.d.out Sat Apr 6 08:06:25 2013 (r249187) @@ -0,0 +1,4 @@ +enum simpson bart +enum simpson maggie +enum simpson snowball_ii + Modified: vendor/illumos/dist/lib/libdtrace/common/dt_print.c ============================================================================== --- vendor/illumos/dist/lib/libdtrace/common/dt_print.c Sat Apr 6 08:02:10 2013 (r249186) +++ vendor/illumos/dist/lib/libdtrace/common/dt_print.c Sat Apr 6 08:06:25 2013 (r249187) @@ -25,6 +25,9 @@ /* * Copyright (c) 2011 by Delphix. All rights reserved. */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ /* * DTrace print() action @@ -93,6 +96,7 @@ * Print structure passed down recursively through printing algorithm. */ typedef struct dt_printarg { + dtrace_hdl_t *pa_dtp; /* libdtrace handle */ caddr_t pa_addr; /* base address of trace data */ ctf_file_t *pa_ctfp; /* CTF container */ int pa_depth; /* member depth */ @@ -303,8 +307,8 @@ dt_print_float(ctf_id_t base, ulong_t of } /* - * A pointer is printed as a fixed-size integer. This is used both for - * pointers and functions. + * A pointer is generally printed as a fixed-size integer. If we have a + * function pointer, we try to look up its name. */ static void dt_print_ptr(ctf_id_t base, ulong_t off, dt_printarg_t *pap) @@ -313,8 +317,23 @@ dt_print_ptr(ctf_id_t base, ulong_t off, ctf_file_t *ctfp = pap->pa_ctfp; caddr_t addr = pap->pa_addr + off / NBBY; size_t size = ctf_type_size(ctfp, base); - - dt_print_hex(fp, addr, size); + ctf_id_t bid = ctf_type_reference(ctfp, base); + uint64_t pc; + dtrace_syminfo_t dts; + GElf_Sym sym; + + if (bid == CTF_ERR || ctf_type_kind(ctfp, bid) != CTF_K_FUNCTION) { + dt_print_hex(fp, addr, size); + } else { + /* LINTED - alignment */ + pc = *((uint64_t *)addr); + if (dtrace_lookup_by_addr(pap->pa_dtp, pc, &sym, &dts) != 0) { + dt_print_hex(fp, addr, size); + } else { + (void) fprintf(fp, "%s`%s", dts.dts_object, + dts.dts_name); + } + } } /* @@ -459,8 +478,31 @@ dt_print_enum(ctf_id_t base, ulong_t off FILE *fp = pap->pa_file; ctf_file_t *ctfp = pap->pa_ctfp; const char *ename; + ssize_t size; + caddr_t addr = pap->pa_addr + off / NBBY; int value = 0; + /* + * The C standard says that an enum will be at most the sizeof (int). + * But if all the values are less than that, the compiler can use a + * smaller size. Thanks standards. + */ + size = ctf_type_size(ctfp, base); + switch (size) { + case sizeof (uint8_t): + value = *(uint8_t *)addr; + break; + case sizeof (uint16_t): + value = *(uint16_t *)addr; + break; + case sizeof (int32_t): + value = *(int32_t *)addr; + break; + default: + (void) fprintf(fp, "", (uint_t)size); + return; + } + if ((ename = ctf_enum_name(ctfp, base, value)) != NULL) (void) fprintf(fp, "%s", ename); else @@ -635,6 +677,7 @@ dtrace_print(dtrace_hdl_t *dtp, FILE *fp } /* setup the print structure and kick off the main print routine */ + pa.pa_dtp = dtp; pa.pa_addr = addr; pa.pa_ctfp = dt_module_getctf(dtp, dmp); pa.pa_nest = 0;