When is __lldb_init_module called?

冷暖自知 提交于 2019-12-21 05:12:17

问题


I'm following WWDC session 412 - Debugging in Xcode. There is a demo there about creating custom LLDB summaries for your own classes.

I simply can't get the summaries to show up.

By inserting print calls in the Python script I have been able to determine that:

  1. The script file is getting imported
  2. __lldb_init_module is never called

Any idea about what could prevent __lldb_init_module from being called? Is there a specific time when you need to import the script?


回答1:


For me this worked by adding

command script import /path/to/CustomSummaries.py

to the ~/.lldbinit file and restarting Xcode, or by setting a breakpoint in "main" and executing the import command in the debugger console.

I tested it with a minimal custom description script:

import lldb

def myobject_summary(valueObject, dictionary):

    return 'MyCustomDescription'

def __lldb_init_module(debugger, dict):

    debugger.HandleCommand('type summary add MyObject -F CustomSummaries.myobject_summary')

and this is the view in the Xcode debugger window:

Note that you have to restart Xcode after changes to the script. It also seems that the output of "print" statements in the init method is not shown if the script is imported in the Xcode debugger console.



来源:https://stackoverflow.com/questions/14159070/when-is-lldb-init-module-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!