I'm in the process of writing a DriverKit USBHostInterface driver, and while I'm finally starting to get there, I've run into a bit of a frustration with logging.
Naturally I have a liberal amount of os_log calls that I'm using to troubleshoot my driver. However I've noticed that they don't show up until after the first time my driver has loaded.
Meaning, for example, suppose I make a new build of my driver and it's bundled user-mode app, install the bundle to /Applications, run the installer, verify it took with systemextensionsctl list, fire up Console and start streaming log entries, then plug in my device.
I can see the log entries that show that my driver is loaded, etc., then a bunch of kernel -> <private> log entries, but none of my Start method log entries.
If I unplug my device and plug it in again, my log entries show up as expected.
Why is this and, more importantly, how can I fix it? I'd like to see those log entries the first time the driver loads, if I could.
Why is this and
To be perfectly honest, I have no idea.
There's a thread about logging in DriverKit logging here that might be worth reviewing, but that's primarily about issues with IOLog redaction, which is different than you're describing. I can't think of any reason why we'd redact the first run but not later runs. I suspect there is some kind of bug involved, but I'm going to run this by Quinn to see what he thinks.
Bonus Thought:
How are you signing your DEXT? Are you using automatic signing with the Development Only profiles (modern/good) or disabling SIP (old/bad)? This a blind guess, but it's possible the old (SIP disabled) approach might cause something weird like this, depending on exactly how the build was signed. See this post for more information on how to sign DEXT.
However, I do have two ideas for this:
more importantly, how can I fix it?
The post above mentions this in passing, but Quinn's "Recording Private Data in the System Log" post describes how you can manually control how redaction works and the "Sysdiagnose (Unredacted)" profile applies that approach to "everything". Theoretically, either approach should get you around whatever is going on.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware