From owner-freebsd-dtrace@freebsd.org Fri Aug 4 10:46:24 2017 Return-Path: Delivered-To: freebsd-dtrace@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 7CE6ADD29CA for ; Fri, 4 Aug 2017 10:46:24 +0000 (UTC) (envelope-from longwitz@incore.de) Received: from dss.incore.de (dss.incore.de [195.145.1.138]) (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 CD9C63F4E; Fri, 4 Aug 2017 10:46:23 +0000 (UTC) (envelope-from longwitz@incore.de) Received: from inetmail.dmz (inetmail.dmz [10.3.0.3]) by dss.incore.de (Postfix) with ESMTP id DEDC267998; Fri, 4 Aug 2017 12:46:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at incore.de Received: from dss.incore.de ([10.3.0.3]) by inetmail.dmz (inetmail.dmz [10.3.0.3]) (amavisd-new, port 10024) with LMTP id etuQfI4PTqbs; Fri, 4 Aug 2017 12:46:19 +0200 (CEST) Received: from mail.local.incore (fwintern.dmz [10.0.0.253]) by dss.incore.de (Postfix) with ESMTP id 7D208679B3; Fri, 4 Aug 2017 12:46:18 +0200 (CEST) Received: from bsdlo.incore (bsdlo.incore [192.168.0.84]) by mail.local.incore (Postfix) with ESMTP id 53D9D508A1; Fri, 4 Aug 2017 12:46:18 +0200 (CEST) Message-ID: <5984507A.3090104@incore.de> Date: Fri, 04 Aug 2017 12:46:18 +0200 From: Andreas Longwitz User-Agent: Thunderbird 2.0.0.19 (X11/20090113) MIME-Version: 1.0 To: Mark Johnston CC: "freebsd-dtrace@freebsd.org" Subject: Re: g_journal_read has broken argument list in V10 References: <596F2CDA.1000705@incore.de> <598343D8.8060101@incore.de> <20170803171011.GB4968@wkstn-mjohnston.west.isilon.com> In-Reply-To: <20170803171011.GB4968@wkstn-mjohnston.west.isilon.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2017 10:46:24 -0000 Hello, thanks for answer. >> >> The function g_journal_read() is the only one in g_journal.c that shows >> the described problem. I can not decide, if the object module >> g_journal.o is broken or if ctfconvert does something wrong. > > It's possible that the compiler is reordering arguments. CTF is > generated from DWARF info, so the way to determine if this is the case > is to inspect the dwarf tags with dwarfdump or readelf -w and check the > parameter order there. I don't know why the arguments would be getting > reordered in this case, but I've seen it happen before, particularly in > functions that take struct values as parameters. Specifically, on amd64 > such parameters are moved to the end of the list so other parameters may > be passed in registers. > > FWIW, with clang 5.0 on ~CURRENT I get the expected parameter order: > > [23] FUNC (g_journal_read) returns: 1 args: (1090, 988, 332, 332) Yes, dwarfdump shows the problem is in g_journal.o, the list of formal parameters is reordered by the compiler: < 1><0x0000cb4f> DW_TAG_subprogram DW_AT_name g_journal_read DW_AT_decl_file 0x00000001 /usr/src/sys/geom/journal/g_journal.c DW_AT_decl_line 0x0000061f DW_AT_prototyped yes(1) DW_AT_low_pc 0x00008ad0 DW_AT_high_pc 0x0000915c DW_AT_frame_base DW_OP_reg6 < 2><0x0000cb6a> DW_TAG_formal_parameter DW_AT_name sc DW_AT_decl_file 0x00000001 /usr/src/sys/geom/journal/g_journal.c DW_AT_decl_line 0x0000061f DW_AT_type <0x0000949a> DW_AT_location [ 0]< offset pair low-off : 0x00008ad0 addr 0x00008ad0 high-off 0x00008b35 addr 0x00008b35>DW_OP_reg5 [ 1]< offset pair low-off : 0x00008b35 addr 0x00008b35 high-off 0x00008b35 addr 0x00008b35>DW_OP_breg6-104 < 2><0x0000cb7a> DW_TAG_formal_parameter DW_AT_name ostart DW_AT_decl_file 0x00000001 /usr/src/sys/geom/journal/g_journal.c DW_AT_decl_line 0x0000061f DW_AT_type <0x00003b31> DW_AT_location [ 0]< offset pair low-off : 0x00008ad0 addr 0x00008ad0 high-off 0x00008bb8 addr 0x00008bb8>DW_OP_reg14 < 2><0x0000cb8a> DW_TAG_formal_parameter DW_AT_name oend DW_AT_decl_file 0x00000001 /usr/src/sys/geom/journal/g_journal.c DW_AT_decl_line 0x00000620 DW_AT_type <0x00003b31> DW_AT_location [ 0]< offset pair low-off : 0x00008ad0 addr 0x00008ad0 high-off 0x00008b35 addr 0x00008b35>DW_OP_reg2 < 2><0x0000cb9a> DW_TAG_formal_parameter DW_AT_name pbp DW_AT_decl_file 0x00000001 /usr/src/sys/geom/journal/g_journal.c DW_AT_decl_line 0x0000061f DW_AT_type <0x00005de4> By the way, the following patch solves the problem with the wrong argument counts in ctfdump: --- dump.c.1st 2015-07-03 16:39:24.000000000 +0200 +++ dump.c 2017-08-04 10:56:21.563805000 +0200 @@ -364,7 +364,8 @@ (void) printf(" [%lu] FUNC ", id); if (name != NULL) (void) printf("(%s) ", name); - (void) printf("returns: %u args: (", *fp++); + (void) printf("returns: %u args: (", n); + fp++; if (n != 0) { (void) printf("%u", *fp++); -- Andreas Longwitz