|
| 1 | +# |
| 2 | +# Generated file, do not edit. |
| 3 | +# |
| 4 | + |
| 5 | +import lldb |
| 6 | + |
| 7 | +def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict): |
| 8 | + """Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages.""" |
| 9 | + base = frame.register["x0"].GetValueAsAddress() |
| 10 | + page_len = frame.register["x1"].GetValueAsUnsigned() |
| 11 | + |
| 12 | + # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the |
| 13 | + # first page to see if handled it correctly. This makes diagnosing |
| 14 | + # misconfiguration (e.g. missing breakpoint) easier. |
| 15 | + data = bytearray(page_len) |
| 16 | + data[0:8] = b'IHELPED!' |
| 17 | + |
| 18 | + error = lldb.SBError() |
| 19 | + frame.GetThread().GetProcess().WriteMemory(base, data, error) |
| 20 | + if not error.Success(): |
| 21 | + print(f'Failed to write into {base}[+{page_len}]', error) |
| 22 | + return |
| 23 | + |
| 24 | +def __lldb_init_module(debugger: lldb.SBDebugger, _): |
| 25 | + target = debugger.GetDummyTarget() |
| 26 | + # Caveat: must use BreakpointCreateByRegEx here and not |
| 27 | + # BreakpointCreateByName. For some reasons callback function does not |
| 28 | + # get carried over from dummy target for the later. |
| 29 | + bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$") |
| 30 | + bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__)) |
| 31 | + bp.SetAutoContinue(True) |
| 32 | + print("-- LLDB integration loaded --") |
0 commit comments