سؤال

I was recently running my iOS app, and I saw this in the debug console:

warning: 'libsystem_network' contains a debug script. To run this script in this debug session:

    command script import "/usr/lib/system/libcompiler_rt.dylib"

To run all discovered debug scripts in this session:

    settings set target.load-script-from-symbol-file true

I ignored it because I didn't know what it was, and haven't gotten anything like it since then. I googled, but found absolutely nothing. What does this mean?

هل كانت مفيدة؟

المحلول

You can put Python scripts in a .dSYM bundle which are automatically loaded & executed when the dSYM is needed in a debug session. Very handy for defining custom formatters for your projects, custom commands that many people use while debugging your framework, etc. This introduces some obvious security issues, so by default lldb will not automatically load & execute these files -- instead, it prints the message you saw above.

In your particular case, I think there's a very rare bug where you can see this message even though there aren't Python resource files in any of your dSYMs. Notice that the message says there is Python in /usr/lib/system/libcompiler_rt.dylib - but of course there isn't, that's a shared library.

For instance, here's how I can create a python file that will set a breakpoint on main when it is loaded:

% echo 'int main () {}' > a.c
% clang -g a.c
% mkdir a.out.dSYM/Contents/Resources/Python
% cat > a.out.dSYM/Contents/Resources/Python/a_out.py
def __lldb_init_module(debugger, internal_dict):
  debugger.HandleCommand("br s -n main")
^D
% lldb a.out
warning: 'a' contains a debug script. To run this script in this debug session:

    command script import "/private/tmp/a.out.dSYM/Contents/Resources/Python/a_out.py"

To run all discovered debug scripts in this session:

settings set target.load-script-from-symbol-file true

Current executable set to 'a.out' (x86_64).

(lldb) settings set target.load-script-from-symbol-file true
Breakpoint 1: where = a.out`main + 9 at a.c:1, address = 0x0000000100000f99
(lldb) 

I had to call the script a_out.py because there couldn't be any . chars in the python filename. But otherwise it's pretty clear.

If you want to throw caution to the wind, you can put this settings set target.load-script-from-symbol-file true line in your ~/.lldbinit file -- but for most of the time, you can enable it at runtime and the commands will be loaded, like you can see in the above example.

The one caveat is if the Python files define their own OperatingSystem plugin. This is very rare for user process debugging. In that case, for correct operation from the initial attach, you need to have the script loading enabled via your ~/.lldbinit file for the OS plugin to be correctly initialized/used in the first stop event. This issue will not apply to people doing plain old user process app/program debugging.

In your specific example above, you seem to have a libsystem_network.dylib or libcompiler_rt.dylib (your example mentions both) with an associated dSYM bundle and there must be a python resource file in that dSYM.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top