Intel® System Debugger User Guide

ID 648476
Date 06/13/2024
Confidential
Document Table of Contents

Break at the Initialization of a Linux* Kernel Module

You can use the following script to automate breaking at the initialization of an out-of-tree (separately compiled) Linux* kernel module.

def linux_module_break(name):
     # get do_init_module function address
     addr = con.threads[0].evaluate('&do_init_module')
     # place a brekapoint on it
     bp = con.set_breakpoint(address=int(addr, 16))
     # loop until the desired breakpoint is hit (should be just 1 iteration)
     while True:
          # run until the breakpoint gets hit on any of the threads
          hit = con.run_until(bp, 300)

          # ## insert the module on your Linux target now ###

          # get the thread on which the breakpoint got hit
          t = con.threads[bp.index(hit)]
          # check if the name of the module is the expected one and break
          if t.evaluate('mod->name') == ('\"%s\"' % name):
               break

     # get the address of the module's init function
     initaddr = t.evaluate('mod->init')
     # set a breakpoint on it
     initbp = t.set_breakpoint(address=int(initaddr, 16))
     # run until the breakpoint gets hit
     t.run_until(initbp, 300)

     ### now, the GUI can be used to load the symbols for the module