From owner-svn-src-stable@freebsd.org Fri Aug 19 07:56:09 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E1F5BBF45C; Fri, 19 Aug 2016 07:56:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 DFFF61F5A; Fri, 19 Aug 2016 07:56:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7J7u8TG003060; Fri, 19 Aug 2016 07:56:08 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7J7u8ia003059; Fri, 19 Aug 2016 07:56:08 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201608190756.u7J7u8ia003059@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 19 Aug 2016 07:56:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r304450 - stable/11/lib/libsysdecode X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2016 07:56:09 -0000 Author: kib Date: Fri Aug 19 07:56:07 2016 New Revision: 304450 URL: https://svnweb.freebsd.org/changeset/base/304450 Log: MFC r303991: Decode 32bit utrace records on the 64bit host. Modified: stable/11/lib/libsysdecode/utrace.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libsysdecode/utrace.c ============================================================================== --- stable/11/lib/libsysdecode/utrace.c Fri Aug 19 07:48:32 2016 (r304449) +++ stable/11/lib/libsysdecode/utrace.c Fri Aug 19 07:56:07 2016 (r304450) @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #define UTRACE_DLOPEN_START 1 @@ -59,6 +59,18 @@ struct utrace_rtld { char name[MAXPATHLEN]; }; +#ifdef __LP64__ +struct utrace_rtld32 { + char sig[4]; /* 'RTLD' */ + int event; + uint32_t handle; + uint32_t mapbase; + uint32_t mapsize; + int refcnt; + char name[MAXPATHLEN]; +}; +#endif + static int print_utrace_rtld(FILE *fp, void *p) { @@ -145,6 +157,14 @@ struct utrace_malloc { void *r; }; +#ifdef __LP64__ +struct utrace_malloc32 { + uint32_t p; + uint32_t s; + uint32_t r; +}; +#endif + static void print_utrace_malloc(FILE *fp, void *p) { @@ -163,6 +183,12 @@ print_utrace_malloc(FILE *fp, void *p) int sysdecode_utrace(FILE *fp, void *p, size_t len) { +#ifdef __LP64__ + struct utrace_rtld ur; + struct utrace_rtld32 *pr; + struct utrace_malloc um; + struct utrace_malloc32 *pm; +#endif if (len == sizeof(struct utrace_rtld) && bcmp(p, "RTLD", 4) == 0) { return (print_utrace_rtld(fp, p)); @@ -172,6 +198,32 @@ sysdecode_utrace(FILE *fp, void *p, size print_utrace_malloc(fp, p); return (1); } - + +#ifdef __LP64__ + if (len == sizeof(struct utrace_rtld32) && bcmp(p, "RTLD", 4) == 0) { + pr = p; + memset(&ur, 0, sizeof(ur)); + memcpy(ur.sig, pr->sig, sizeof(ur.sig)); + ur.event = pr->event; + ur.handle = (void *)(uintptr_t)pr->handle; + ur.mapbase = (void *)(uintptr_t)pr->mapbase; + ur.mapsize = pr->mapsize; + ur.refcnt = pr->refcnt; + memcpy(ur.name, pr->name, sizeof(ur.name)); + return (print_utrace_rtld(fp, &ur)); + } + + if (len == sizeof(struct utrace_malloc32)) { + pm = p; + memset(&um, 0, sizeof(um)); + um.p = pm->p == (uint32_t)-1 ? (void *)(intptr_t)-1 : + (void *)(uintptr_t)pm->p; + um.s = pm->s; + um.r = (void *)(uintptr_t)pm->r; + print_utrace_malloc(fp, &um); + return (1); + } +#endif + return (0); }