flutter_lldb_helper.py 1.2 KB

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