lldb KDK vs python

OK I somehow managed to break lldb loading KDKs, and my best guess is it picks the wrong python framework.



lldb /Library/Developer/KDKs/KDK_10.14_18A336e.kdk/System/Library/Kernels/kernel
(lldb) target create "/Library/Developer/KDKs/KDK_10.14_18A336e.kdk/System/Library/Kernels/kernel"
unable to load scripting data for module kernel - error reported was Missing parentheses in call to 'print'. Did you mean print("Loading kernel debugging from %s" % __file__)? (kernel.py, line 69)
  File "temp.py", line 1, in



# which lldb

/usr/bin/lldb

# which python

/usr/bin/python


Clearing PATH and PYTHONPATH, or setting thing appears to make no changes.


Any clues?

Accepted Reply

Ah, just noticed you’re using a 10.14.x KDK. What do you see if you try a 10.15.x KDK?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

which python
doesn’t help much because that’s a symlink. What you need is
--version
. This is what I’d expect to see on a stock 10.15.4 machine:
% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.4
BuildVersion:   19E266
% which python
/usr/bin/python
% ls -l /usr/bin/python
lrwxr-xr-x  1 root  wheel  75 Oct  8  2019 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
% python --version
Python 2.7.16

Judging by the error, my guess is that someone has changed the default

python
to 3.x.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

# mv python pythonold

# ln -s ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 python

# sw_vers

ProductName: Mac OS X

ProductVersion: 10.14.6

BuildVersion: 18G4032


# which python

/usr/bin/python


# ls -l /usr/bin/python

lrwxr-xr-x 1 root wheel 75 May 5 06:31 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7


# python --version

Python 2.7.16


# lldb /Library/Developer/KDKs/KDK_10.14.6_18G2016.kdk/System/Library/Kernels/kernel

(lldb) target create "/Library/Developer/KDKs/KDK_10.14.6_18G2016.kdk/System/Library/Kernels/kernel"

unable to load scripting data for module kernel - error reported was Missing parentheses in call to 'print'. Did you mean print("Loading kernel debugging from %s" % __file__)? (kernel.py, line 69)

File "temp.py", line 1, in <module>



It is stubborn alright.

It seems rather determined to run python3:


# /usr/bin/lldb -P

/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python3


# /usr/bin/lldb --version

lldb-1100.0.30.12

Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)


However:


# /Library/Developer/CommandLineTools/usr/bin/lldb -P

/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Resources/Python


# /Library/Developer/CommandLineTools/usr/bin/lldb --version

lldb-1001.0.13.3

Swift-5.0


# /Library/Developer/CommandLineTools/usr/bin/lldb /Library/Developer/KDKs/KDK_10.14.6_18G2016.kdk/System/Library/Kernels/kernel

(lldb) target create "/Library/Developer/KDKs/KDK_10.14.6_18G2016.kdk/System/Library/Kernels/kernel"

Loading kernel debugging from /Library/Developer/KDKs/KDK_10.14.6_18G2016.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/Python/kernel.py

LLDB version lldb-1001.0.13.3

Swift-5.0

settings set target.process.python-os-plugin-path "/Library/Developer/KDKs/KDK_10.14.6_18G2016.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/Python/lldbmacros/core/operating_system.py"

settings set target.trap-handler-names hndl_allintrs hndl_alltraps trap_from_kernel hndl_double_fault hndl_machine_check _fleh_prefabt _ExceptionVectorsBase _ExceptionVectorsTable _fleh_undef _fleh_dataabt _fleh_irq _fleh_decirq _fleh_fiq_generic _fleh_dec

command script import "/Library/Developer/KDKs/KDK_10.14.6_18G2016.kdk/System/Library/Kernels/kernel.dSYM/Contents/Resources/Python/lldbmacros/xnu.py"

xnu debug macros loaded successfully. Run showlldbtypesummaries to enable type summaries.

settings set target.process.optimization-warnings false


So I have a way to keep running KDKs.. Sorry for the noise.

Ah, just noticed you’re using a 10.14.x KDK. What do you see if you try a 10.15.x KDK?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

/usr/bin/lldb fail, but with additional message


WARNING! Python version 3 is not supported for xnu lldbmacros.

Please restart your debugging session with the following workaround



defaults write com.apple.dt.lldb DefaultPythonVersion 2



So that is all the clues one needs maybe, using the /Library/Developer/CommandLineTools/usr/bin/lldb

everything works like before.