From owner-svn-src-head@freebsd.org Sun Dec 31 09:23:20 2017 Return-Path: Delivered-To: svn-src-head@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 C64A3EAC92A; Sun, 31 Dec 2017 09:23:20 +0000 (UTC) (envelope-from cperciva@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 9E3EA6AFDB; Sun, 31 Dec 2017 09:23:20 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBV9NJ8t046713; Sun, 31 Dec 2017 09:23:19 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBV9NJln046710; Sun, 31 Dec 2017 09:23:19 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201712310923.vBV9NJln046710@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Sun, 31 Dec 2017 09:23:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327428 - in head/sys: kern tools X-SVN-Group: head X-SVN-Commit-Author: cperciva X-SVN-Commit-Paths: in head/sys: kern tools X-SVN-Commit-Revision: 327428 X-SVN-Commit-Repository: base 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.25 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, 31 Dec 2017 09:23:20 -0000 Author: cperciva Date: Sun Dec 31 09:23:19 2017 New Revision: 327428 URL: https://svnweb.freebsd.org/changeset/base/327428 Log: Teach makeobjops.awk to accept PROLOG and EPILOG blocks before METHOD and STATICMETHOD declarations; that code will be inserted into the dispatch function before and after the method call. Use this functionality and the TSLOG framework to record DEVICE_ATTACH and DEVICE_PROBE entry/exit timestamps. Modified: head/sys/kern/device_if.m head/sys/tools/makeobjops.awk Modified: head/sys/kern/device_if.m ============================================================================== --- head/sys/kern/device_if.m Sun Dec 31 09:23:02 2017 (r327427) +++ head/sys/kern/device_if.m Sun Dec 31 09:23:19 2017 (r327428) @@ -39,6 +39,11 @@ */ INTERFACE device; +# Needed for timestamping device probe/attach calls +HEADER { + #include +} + # # Default implementations of some methods. # @@ -142,6 +147,12 @@ CODE { * be returned to indicate the type of error * @see DEVICE_ATTACH(), pci_get_vendor(), pci_get_device() */ +PROLOG { + TSENTER2(device_get_name(dev)); +} +EPILOG { + TSEXIT2(device_get_name(dev)); +} METHOD int probe { device_t dev; }; @@ -199,6 +210,12 @@ STATICMETHOD void identify { * be returned to indicate the type of error * @see DEVICE_PROBE() */ +PROLOG { + TSENTER2(device_get_name(dev)); +} +EPILOG { + TSEXIT2(device_get_name(dev)); +} METHOD int attach { device_t dev; }; Modified: head/sys/tools/makeobjops.awk ============================================================================== --- head/sys/tools/makeobjops.awk Sun Dec 31 09:23:02 2017 (r327427) +++ head/sys/tools/makeobjops.awk Sun Dec 31 09:23:19 2017 (r327428) @@ -326,11 +326,19 @@ function handle_method (static, doc) } printh("{"); printh("\tkobjop_t _m;"); + if (ret != "void") + printh("\t" ret " rc;"); if (!static) firstvar = "((kobj_t)" firstvar ")"; + if (prolog != "") + printh(prolog); printh("\tKOBJOPLOOKUP(" firstvar "->ops," mname ");"); - retrn = (ret != "void") ? "return " : ""; - printh("\t" retrn "((" mname "_t *) _m)(" varname_list ");"); + rceq = (ret != "void") ? "rc = " : ""; + printh("\t" rceq "((" mname "_t *) _m)(" varname_list ");"); + if (epilog != "") + printh(epilog); + if (ret != "void") + printh("\treturn (rc);"); printh("}\n"); } @@ -440,6 +448,8 @@ for (file_i = 0; file_i < num_files; file_i++) { lineno = 0; error = 0; # to signal clean up and gerror setting lastdoc = ""; + prolog = ""; + epilog = ""; while (!error && (getline < src) > 0) { lineno++; @@ -473,10 +483,18 @@ for (file_i = 0; file_i < num_files; file_i++) { else if (/^METHOD/) { handle_method(0, lastdoc); lastdoc = ""; + prolog = ""; + epilog = ""; } else if (/^STATICMETHOD/) { handle_method(1, lastdoc); lastdoc = ""; - } else { + prolog = ""; + epilog = ""; + } else if (/^PROLOG[ ]*{$/) + prolog = handle_code(); + else if (/^EPILOG[ ]*{$/) + epilog = handle_code(); + else { debug($0); warnsrc("Invalid line encountered"); error = 1;