Last active
November 12, 2017 02:44
-
-
Save khanzf/d444f6d4f8e54add26a67af2ecee491d to your computer and use it in GitHub Desktop.
Dtrace and Systemtap scripts used to see what happens between functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/dtrace -qs | |
/* | |
* Run with sudo ./tap_function.d -q | |
*/ | |
dtrace:::BEGIN | |
{ | |
self->start = 0; | |
printf("Start on\t%s\n", "r92c_scan_start"); | |
printf("End on\t%s\n", "r88e_set_bw20"); | |
} | |
fbt::r92c_set_chan:entry | |
{ | |
self->start = 1; | |
printf("Start on %s\n", probefunc); | |
printf("---Beginning of %s stack---\n", probefunc); | |
stack(10); | |
printf("---End of %s stack---\n", probefunc); | |
} | |
fbt::r88e_set_bw20:return | |
{ | |
/* self->rtwn_bb_init = 0; */ | |
printf("Exit on %s\n", probefunc); | |
exit(0); | |
} | |
fbt:kernel:ieee80211*:entry, | |
fbt:kernel:ifioctl:entry, | |
fbt::ieee802*:entry, | |
fbt:rtwn::entry, | |
fbt:if_rtwn_pci::entry /probefunc != "rtwn_pci_read_1" && probefunc != "rtwn_pci_read_2" && probefunc != "rtwn_pci_read_4" && probefunc != "rtwn_pci_write_1" && probefunc != "rtwn_pci_write_2" && probefunc != "rtwn_pci_write_4"/ | |
{ | |
if(self->start == 1) { | |
printf("%s\n", probefunc); | |
} | |
} | |
fbt::rtwn_pci_read_*:entry | |
{ | |
addr = arg1; | |
} | |
fbt::rtwn_pci_write_*:entry | |
{ | |
if (self->start == 1) { | |
addr = arg1; | |
val = arg2; | |
printf("%s( 0x%x 0x%x ) %a\n", probefunc, addr, val, caller) ; | |
} | |
} | |
fbt::rtwn_pci_read_1:return, | |
fbt::rtwn_pci_read_2:return, | |
fbt::rtwn_pci_read_4:return | |
{ | |
if(self->start == 1) { | |
printf("%s( 0x%x ) = 0x%x %a\n", probefunc, addr, args[0], caller); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env stap | |
# | |
# Run as this: | |
# sudo stap -g --suppress-time-limits -D DTP_NO_OVERLOAD -d mac80211 -d rfkill -d rtl8188ee -d rtl_pci -d rtlwifi -d cfg80211 ./rtl8188ee.stp | |
# | |
// Write's | |
probe module("rtl_pci").function("pci_write32_async") | |
{ | |
printf("pci_write32_async( 0x%x 0x%x ) by %s\n", $addr, $val, symname( caller_addr() ) ); | |
} | |
probe module("rtl_pci").function("pci_write16_async") | |
{ | |
printf("pci_write16_async( 0x%x 0x%x ) by %s\n", $addr, $val, symname( caller_addr() ) ); | |
} | |
probe module("rtl_pci").function("pci_write8_async") | |
{ | |
printf("pci_write8_async( 0x%x 0x%x ) by %s\n", $addr, $val, symname( caller_addr() ) ); | |
} | |
// Read's | |
probe module("rtl_pci").function("pci_read32_sync") | |
{ | |
printf("pci_read32_sync( 0x%x )= 0x%x by %s\n", $addr, returnval(), symname( caller_addr() ) ); | |
if ($addr == 0xe08) { | |
printf("XXXXXXXXX\n"); | |
print_backtrace(); | |
} | |
} | |
probe module("rtl_pci").function("pci_read16_sync") | |
{ | |
printf("pci_read16_sync( 0x%x )= 0x%x by %s\n", $addr, returnval(), symname( caller_addr() ) ); | |
} | |
probe module("rtl_pci").function("pci_read8_sync") | |
{ | |
printf("pci_read8_sync( 0x%x )= 0x%x by %s\n", $addr, returnval(), symname(caller_addr())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Haven't figured out how to get command-line arguments working, this seems to be a problem in D.