Skip to content

Instantly share code, notes, and snippets.

@wholivesinapineappleunderthesea
Created March 20, 2025 21:49
Show Gist options
  • Save wholivesinapineappleunderthesea/24a93adcbafb08705e542bd0fc5e815f to your computer and use it in GitHub Desktop.
Save wholivesinapineappleunderthesea/24a93adcbafb08705e542bd0fc5e815f to your computer and use it in GitHub Desktop.
#pragma D option destructive
#pragma D option quiet
dtrace:::BEGIN
{
printf("Begin\n");
}
pid$target:dxasm:*:entry
{
/*
printf("function %s @ %i\n", probefunc, timestamp);
*/
self->kthread = (struct nt`_KTHREAD *)curthread;
/*
printf("ETHREAD: %p\n", self->kthread);
*/
self->threadcounters = (struct nt`_KTHREAD_COUNTERS *)self->kthread->ThreadCounters;
/*
printf("KTHREAD_COUNTERS: %p\n", self->threadcounters);
*/
self->hwcnts = (int)self->threadcounters->HardwareCounters;
printf("HardwareCounters: %i\n", self->hwcnts);
self->hw0 = (struct nt`_COUNTER_READING )self->threadcounters->HwCounter[0];
self->hw0start = (int)self->hw0.Start;
self->hw0total = (int)self->hw0.Total;
printf("HwCounter 0: %i -> %i\n", self->hw0start, self->hw0total);
self->hw1 = (struct nt`_COUNTER_READING )self->threadcounters->HwCounter[1];
self->hw1start = (int)self->hw1.Start;
self->hw1total = (int)self->hw1.Total;
printf("HwCounter 1: %i -> %i\n", self->hw1start, self->hw1total);
self->hw2 = (struct nt`_COUNTER_READING )self->threadcounters->HwCounter[2];
self->hw2start = (int)self->hw2.Start;
self->hw2total = (int)self->hw2.Total;
printf("HwCounter 2: %i -> %i\n", self->hw2start, self->hw2total);
self->hw3 = (struct nt`_COUNTER_READING )self->threadcounters->HwCounter[3];
self->hw3start = (int)self->hw3.Start;
self->hw3total = (int)self->hw3.Total;
printf("HwCounter 3: %i -> %i\n", self->hw3start, self->hw3total);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment