From owner-svn-src-head@FreeBSD.ORG Sun May 10 21:39:25 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 61930776; Sun, 10 May 2015 21:39:25 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 35E161F04; Sun, 10 May 2015 21:39:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4ALdPxB082745; Sun, 10 May 2015 21:39:25 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4ALdPXD082744; Sun, 10 May 2015 21:39:25 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201505102139.t4ALdPXD082744@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 10 May 2015 21:39:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282739 - head/cddl/contrib/opensolaris/common/ctf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 May 2015 21:39:25 -0000 Author: markj Date: Sun May 10 21:39:24 2015 New Revision: 282739 URL: https://svnweb.freebsd.org/changeset/base/282739 Log: ctf_add_type(): when looking up an integer or floating point type in the list of pending dynamic type definitions, a match on the type name is not sufficient - we need to compare the type encodings as well. For example, bitfields have their own distinct type definitions which share the name of the underlying integer type, and these types aren't generally interchangeable. This bug was causing the following libdtrace error when attempting to trace the th_flags member of a struct tcphdr: cg: bad field: off 104 type <32877> bits 539620016 Reported by: rwatson MFC after: 3 weeks Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c ============================================================================== --- head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Sun May 10 21:26:07 2015 (r282738) +++ head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Sun May 10 21:39:24 2015 (r282739) @@ -1328,15 +1328,28 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_fil * we are looking for. This is necessary to permit ctf_add_type() to * operate recursively on entities such as a struct that contains a * pointer member that refers to the same struct type. + * + * In the case of integer and floating point types, we match using the + * type encoding as well - else we may incorrectly return a bitfield + * type, for instance. */ if (dst_type == CTF_ERR && name[0] != '\0') { for (dtd = ctf_list_prev(&dst_fp->ctf_dtdefs); dtd != NULL && CTF_TYPE_TO_INDEX(dtd->dtd_type) > dst_fp->ctf_dtoldid; dtd = ctf_list_prev(dtd)) { - if (CTF_INFO_KIND(dtd->dtd_data.ctt_info) == kind && - dtd->dtd_name != NULL && - strcmp(dtd->dtd_name, name) == 0) - return (dtd->dtd_type); + if (CTF_INFO_KIND(dtd->dtd_data.ctt_info) != kind || + dtd->dtd_name == NULL || + strcmp(dtd->dtd_name, name) != 0) + continue; + if (kind == CTF_K_INTEGER || kind == CTF_K_FLOAT) { + if (ctf_type_encoding(src_fp, src_type, + &src_en) != 0) + continue; + if (bcmp(&src_en, &dtd->dtd_u.dtu_enc, + sizeof (ctf_encoding_t)) != 0) + continue; + } + return (dtd->dtd_type); } }