| 10 | |
| 11 | class TestKSyms(TestCase): |
| 12 | def grab_sym(self): |
| 13 | address = "" |
| 14 | aliases = [] |
| 15 | |
| 16 | # Grab the first symbol in kallsyms that has type 't' or 'T'. |
| 17 | # Also, find all aliases of this symbol which are identifiable |
| 18 | # by the same address. |
| 19 | with open("/proc/kallsyms", "rb") as f: |
| 20 | for line in f: |
| 21 | |
| 22 | # Extract the first 3 columns only. The 4th column |
| 23 | # containing the module name may not exist for all |
| 24 | # symbols. |
| 25 | (addr, t, name) = line.strip().split()[:3] |
| 26 | if t == b"t" or t == b"T": |
| 27 | if not address: |
| 28 | address = addr |
| 29 | if addr == address: |
| 30 | aliases.append(name) |
| 31 | |
| 32 | # Return all aliases of the first symbol. |
| 33 | return (address, aliases) |
| 34 | |
| 35 | def test_ksymname(self): |
| 36 | sym = BPF.ksymname(b"__kmalloc") |