aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2017-12-31 09:23:19 +0000
committerColin Percival <cperciva@FreeBSD.org>2017-12-31 09:23:19 +0000
commita21a2da5995538bf8d02f31aa77ac1ccc00f0b24 (patch)
tree94663108f9b639ec5c92adfaa8ad9cfb8aab8217
parent95e678f96e8df33773582f7e43f8e3a9a86a8d11 (diff)
downloadsrc-a21a2da5995538bf8d02f31aa77ac1ccc00f0b24.tar.gz
src-a21a2da5995538bf8d02f31aa77ac1ccc00f0b24.zip
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.
Notes
Notes: svn path=/head/; revision=327428
-rw-r--r--sys/kern/device_if.m17
-rw-r--r--sys/tools/makeobjops.awk24
2 files changed, 38 insertions, 3 deletions
diff --git a/sys/kern/device_if.m b/sys/kern/device_if.m
index 305110fc67fc..e58d39d68178 100644
--- a/sys/kern/device_if.m
+++ b/sys/kern/device_if.m
@@ -39,6 +39,11 @@
*/
INTERFACE device;
+# Needed for timestamping device probe/attach calls
+HEADER {
+ #include <sys/tslog.h>
+}
+
#
# 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;
};
diff --git a/sys/tools/makeobjops.awk b/sys/tools/makeobjops.awk
index 367354148a3e..225e48d43497 100644
--- a/sys/tools/makeobjops.awk
+++ b/sys/tools/makeobjops.awk
@@ -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;