Python Error in LLDB on Mac M1 with Xcode Command Line Tools
rochus-keller opened this issue · 1 comments
On my old x86 Mac mini everything works fine. When starting the debugger on my M1 Mac mini the debugger just hangs on startup and the debugger log is below.
I also tried the workaround recommended in https://stackoverflow.com/questions/56687820/qt-creator-fails-to-start-debugging-on-mac with both Python 2 and 3 without success. The x86_64 version running under Rosetta behaves exactly the same.
Maybe there is a difference when running with the full Xcode deployment instead only the command line tools, but this is my Mac mini I use for my music and thus don't want to install arbitrary stuff.
Could anyone please try on their Macs and give feedback whether it works with their configuration, thanks.
sStarting debugger "LldbEngine" for ABI "arm-macos-generic-mach_o-64bit"...
dStart parameters: 'hello' mode: 1
dABI: arm-macos-generic-mach_o-64bit
dLanguages: c++
dExecutable: /Users/rochus/Downloads/busy/build-LeanQt-Desktop-Debug/examples/hello
dDirectory: /Users/rochus/Downloads/busy/build-LeanQt-Desktop-Debug/examples
dDebugger: /Library/Developer/CommandLineTools/usr/bin/lldb
dProject: /Users/rochus/Downloads/busy/LeanQtAddtional Search Directories:
dSysroot:
dDebug Source Location:
dDebugger settings:
dQmlInspector.ShowAppOnTop: false (default: false)
dBreakOnWarning: false (default: false)
dBreakOnFatal: false (default: false)
dBreakOnAbort: false (default: false)
dShowQmlObjectTree: true (default: true)
dNoPluginBreakpoints: false (default: false)
dSelectedPluginBreakpointsPattern: .* (default: .*)
dBreakOnThrow: false (default: false)
dBreakOnCatch: false (default: false)
dAllPluginBreakpoints: true (default: true)
dSelectedPluginBreakpoints: false (default: false)
dAdjustBreakpointLocations: true (default: true)
dMaximalStringLength: 10000 (default: 10000)
dDisplayStringLimit: 100 (default: 100)
dSkipKnownFrames: false (default: false)
dEnableReverseDebugging: false (default: false)
dShowStandardNamespace: true (default: true)
dShowQtNamespace: true (default: true)
dSortStructMembers: true (default: true)
dAutoDerefPointers: true (default: true)
dIdentifyDebugInfoPackages: false (default: false)
dMaximalStackDepth: 20 (default: 20)
dTargetAsync: false (default: false)
dWarnOnReleaseBuilds: true (default: true)
dMultiInferior: false (default: false)
dIntelFlavor: false (default: false)
dGdbPostAttachCommands: (default: )
dWatchdogTimeout: 20 (default: 20)
dAutoEnrichParameters: true (default: true)
dUseDynamicType: true (default: true)
dLoadGdbInit: true (default: true)
dLoadGdbDumpers2: false (default: false)
dAttemptQuickStart: false (default: false)
dGdbStartupCommands: (default: )
dBreakOnCrtDbgReport: false (default: false)
dCDB_Console: false (default: false)
dBreakpointCorrection: true (default: true)
dIgnoreFirstChanceAccessViolation: false (default: false)
dAdditionalArguments: (default: )
dSymbolPaths: (default: )
dSourcePaths: (default: )
dBreakEvent: (default: )
dAlwaysAdjustColumnWidths: true (default: true)
dExtraDumperFile: (default: )
dGdbCustomDumperCommands: (default: )
dUseToolTipsInBreakpointsView: false (default: false)
dUseToolTipsInBreakpointsView: false (default: true) ***
dUseAddressInBreakpointsView: false (default: false)
dUseAddressInStackView: false (default: false)
dUseCodeModel: true (default: true)
dShowThreadNames: false (default: false)
dUseToolTips: true (default: true)
dUseToolTipsInLocalsView: false (default: false)
dBreakpointsFullPath: false (default: false)
dRaiseOnInterrupt: true (default: true)
dStationaryEditorWhileStepping: false (default: false)
dUseDebuggingHelper: true (default: true)
dCloseBuffersOnExit: false (default: false)
dCloseMemoryBuffersOnExit: true (default: true)
dSwitchModeOnExit: false (default: false)
dAutoQuit: false (default: false)
dLogTimeStamps: false (default: false)
dVerboseLog: false (default: false)
dUseAlternatingRowColours: false (default: false)
dFontSizeFollowsEditor: false (default: false)
dUseMessageBoxForSignals: true (default: true)
dState changed from DebuggerNotReady(0) to EngineSetupRequested(1) [master]
dQUEUE: SETUP ENGINE
dCALL: SETUP ENGINE
dSTARTING LLDB: /Library/Developer/CommandLineTools/usr/bin/lldb
>(lldb) sc print('@\nlldbstartupok@\n')
>@
>lldbstartupok@
>
dADAPTER STARTED
sSetting up inferior...
>(lldb) script sys.path.insert(1, '/var/folders/86/95rc7rvs2_z7x7wlzbhnys9h0000gn/T/LeanCreator-Cw57Iw/')
>(lldb) script from lldbbridge import *
>(lldb) script print(dir())
>['Array10000Format', 'Array1000Format', 'Array100Format', 'Array10Format', 'ArrayPlotFormat', 'AttachCore', 'AttachCrashedExternal', 'AttachExternal', 'AttachToRemoteProcess', 'AttachToRemoteServer', 'AutomaticFormat', 'Base64Encoded16Bit', 'Base64Encoded16BitWithQuotes', 'Base64Encoded32BitWithQuotes', 'Base64Encoded8Bit', 'Base64Encoded8BitWithQuotes', 'Blob', 'BreakpointAtCatch', 'BreakpointAtExec', 'BreakpointAtFork', 'BreakpointAtJavaScriptThrow', 'BreakpointAtMain', 'BreakpointAtSysCall', 'BreakpointAtThrow', 'BreakpointByAddress', 'BreakpointByFileAndLine', 'BreakpointByFunction', 'BreakpointOnQmlSignalEmit', 'Children', 'CompactMapFormat', 'DateTimeInternal', 'DirectQListStorageFormat', 'DisplayImageData', 'DisplayImageFile', 'DisplayLatin1String', 'DisplayPlotData', 'DisplayUtf16String', 'DisplayUtf8String', 'Dumper', 'DumperBase', 'EnhancedFormat', 'Hex2EncodedFloat4', 'Hex2EncodedFloat8', 'Hex2EncodedInt1', 'Hex2EncodedInt2', 'Hex2EncodedInt4', 'Hex2EncodedInt8', 'Hex2EncodedLatin1', 'Hex2EncodedLocal8Bit', 'Hex2EncodedUInt1', 'Hex2EncodedUInt2', 'Hex2EncodedUInt4', 'Hex2EncodedUInt8', 'Hex2EncodedUtf8', 'Hex2EncodedUtf8WithoutQuotes', 'Hex4EncodedBigEndian', 'Hex4EncodedLittleEndian', 'Hex4EncodedLittleEndianWithoutQuotes', 'Hex8EncodedBigEndian', 'Hex8EncodedLittleEndian', 'IPv6AddressAndHexScopeId', 'IndirectQListStorageFormat', 'JulianDate', 'JulianDateAndMillisecondsSinceMidnight', 'Latin1StringFormat', 'Local8BitStringFormat', 'MillisecondsSinceMidnight', 'NoAddress', 'NoStartMode', 'PairedChildren', 'PairedChildrenData', 'RawFormat', 'ReportItem', 'SeparateFormat', 'SeparateLatin1StringFormat', 'SeparateUtf8StringFormat', 'SimpleFormat', 'SpecialEmptyStructureValue', 'SpecialEmptyValue', 'SpecialInvalidValue', 'SpecialItemCountValue', 'SpecialMinimumItemCountValue', 'SpecialNotAccessibleValue', 'SpecialNotCallableValue', 'SpecialNullReferenceValue', 'SpecialOptimizedOutValue', 'SpecialUninitializedValue', 'StartExternal', 'StartInternal', 'StartRemoteProcess', 'StopDisplay', 'SubItem', 'Tester', 'TopLevelItem', 'Ucs4StringFormat', 'Unencoded8Bit', 'UnknownType', 'UnnamedSubItem', 'Utf16StringFormat', 'Utf8StringFormat', 'Value', 'WatchpointAtAddress', 'WatchpointAtExpression', '__builtins__', 'arrayForms', 'base64', 'check', 'copy', 'fileNameAsString', 'impl_SBValue__add__', 'impl_SBValue__deref', 'impl_SBValue__float__', 'impl_SBValue__getitem__', 'impl_SBValue__int__', 'impl_SBValue__le__', 'impl_SBValue__long__', 'impl_SBValue__sub__', 'inspect', 'json', 'keyword', 'lldb', 'mapForms', 'os', 'platform', 'pydoc', 'qqWatchpointOffset', 're', 'reload_module', 'run_one_line', 'run_python_interpreter', 'showException', 'struct', 'sys', 'threading', 'time', 'toInteger', 'uuid', 'verbosity', 'warn', 'xrange']
>(lldb) script theDumper = Dumper()
eERROR: Lldb stderr: error: cannot delete one or more categories
eerror: cannot delete one or more categories
>@
>lldbversion="lldb-1316.0.9.41
>Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)"@
>@
>state="enginesetupok"@
dNOTE: ENGINE SETUP OK
dState changed from EngineSetupRequested(1) to EngineSetupOk(3) [master]
dQUEUE: SETUP INFERIOR
dState changed from EngineSetupOk(3) to InferiorSetupRequested(4) [master]
dQUEUE: SETUP INFERIOR
dCALL: SETUP INFERIOR
<1executeDebuggerCommand({"command":"settings set target.env-vars BUSY_RUN_FILE_PATH=/Users/rochus/Downloads/busy/build-LeanQt-Desktop-Debug/examples/hello","token":1})
<2executeDebuggerCommand({"command":"settings set target.env-vars PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin","token":2})
<3loadDumpers({"token":3})
<4setupInferior({"attachpid":-1,"breakonmain":0,"dyldframeworkpath":"","dyldimagesuffix":"","dyldlibrarypath":"","executable":"/Users/rochus/Downloads/busy/build-LeanQt-Desktop-Debug/examples/hello","nativemixed":0,"platform":"","processargs":[],"remotechannel":"","startmode":1,"sysroot":"","token":4,"useterminal":0})
>(lldb) script theDumper.executeDebuggerCommand({"command":"settings set target.env-vars BUSY_RUN_FILE_PATH=/Users/rochus/Downloads/busy/build-LeanQt-Desktop-Debug/examples/hello","token":1})
>@
>token("1")@
>@
>success="1",output="",error=""@
>(lldb) script theDumper.executeDebuggerCommand({"command":"settings set target.env-vars PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin","token":2})
>@
>token("2")@
>@
>success="1",output="",error=""@
>(lldb) script theDumper.loadDumpers({"token":3})
>@
>result={token="3",dumpers=[{type="QVariant (QVariantMap)",formats="17"},{type="QAtomicInt"},{type="QBasicAtomicInt"},{type="QAtomicPointer"},{type="QByteArray",formats="5, 6, 7, 8"},{type="QByteArrayData"},{type="QChar"},{type="QAbstractItemModel",formats="2, 3"},{type="QModelIndex",formats="2, 3"},{type="QDate"},{type="QTime"},{type="QTimeZone"},{type="QDateTime"},{type="QDir"},{type="QFile"},{type="QFileInfo"},{type="QFixed"},{type="QFiniteStack",formats="16"},{type="QFlags"},{type="QHash",formats="17"},{type="QHashNode",formats="17"},{type="QHash__const_iterator"},{type="QHash__iterator"},{type="QHostAddress"},{type="QIPv6Address"},{type="QList",formats="18, 19"},{type="QImage",formats="2, 4"},{type="QLinkedList"},{type="QLocale"},{type="QMapNode"},{type="QMap",formats="17"},{type="QMultiMap",formats="17"},{type="QVariantMap",formats="17"},{type="QMetaObjectPrivate"},{type="QMetaObject"},{type="QPixmap"},{type="QPoint"},{type="QPointF"},{type="QRect"},{type="QRectF"},{type="QRegExp"},{type="QRegion"},{type="QScopedPointer"},{type="QSet"},{type="QSharedData"},{type="QSharedDataPointer"},{type="QSharedPointer"},{type="QSize"},{type="QSizeF"},{type="QStack",formats="16"},{type="QPolygonF"},{type="QPolygon"},{type="QGraphicsPolygonItem"},{type="QStandardItem"},{type="QString",editable="true",formats="2, 4"},{type="QStringData"},{type="QHashedString"},{type="QQmlRefCount"},{type="QStringRef"},{type="QStringList"},{type="QTemporaryFile"},{type="QTextCodec"},{type="QTextCursor"},{type="QTextDocument"},{type="QUrl",formats="2, 4"},{type="QUuid"},{type="QVariant"},{type="QVector",editable="true",formats="16"},{type="QVarLengthArray"},{type="QWeakPointer"},{type="QXmlAttributes"},{type="QXmlStreamStringRef"},{type="QXmlStreamAttribute"},{type="QV4__Object"},{type="QV4__FunctionObject"},{type="QV4__CompilationUnit"},{type="QV4__CallContext"},{type="QV4__ScriptFunction"},{type="QV4__SimpleScriptFunction"},{type="QV4__ExecutionContext"},{type="QV4__TypedValue"},{type="QV4__CallData"},{type="QV4__String"},{type="QV4__Value"},{type="QTJSC__JSValue"},{type="QScriptValue"},{type="QQmlAccessorProperties__Properties"},{type="QJsonPrivate__qle_bitfield"},{type="QJsonPrivate__qle_signedbitfield"},{type="QJsonPrivate__q_littleendian"},{type="QJsonValue"},{type="QJsonArray"},{type="QJsonObject"},{type="std__array",formats="16"},{type="std____1__array",formats="16"},{type="std__complex"},{type="std__deque"},{type="std__deque__QNX"},{type="std____debug__deque"},{type="std__list"},{type="std__list__QNX"},{type="std____debug__list"},{type="std____cxx11__list"},{type="std__map",formats="17"},{type="std__map__QNX"},{type="std____debug__map"},{type="std____debug__set"},{type="std__multiset"},{type="std____cxx1998__map"},{type="std__multimap",formats="17"},{type="std___Rb_tree_iterator"},{type="std___Rb_tree_const_iterator"},{type="std__map__iterator"},{type="__gnu_debug___Safe_iterator"},{type="std__map__const_iterator"},{type="std__set__iterator"},{type="std__set__const_iterator"},{type="std____cxx1998__set"},{type="std__set"},{type="std__set__QNX"},{type="std____1__set"},{type="std__stack"},{type="std____debug__stack"},{type="std__string",editable="true",formats="5, 6, 7, 8"},{type="std__stringHelper1"},{type="std__stringHelper1__QNX"},{type="std____1__string"},{type="std____1__wstring"},{type="std__shared_ptr"},{type="std____1__shared_ptr"},{type="std__unique_ptr"},{type="std____1__unique_ptr"},{type="std__unordered_map",formats="17"},{type="std____debug__unordered_map",formats="17"},{type="std__unordered_set"},{type="std____1__unordered_map",formats="17"},{type="std____1__unordered_set"},{type="std____debug__unordered_set"},{type="std__vector",editable="true",formats="16"},{type="std__vector__QNX"},{type="std____1__vector"},{type="std____debug__vector",formats="16"},{type="string",editable="true"},{type="std__wstring",formats="2, 4"},{type="std__basic_string"},{type="std____cxx11__basic_string"},{type="std____cxx11__string",formats="5, 6, 7, 8"},{type="std____cxx11__wstring",formats="2, 4"},{type="std____1__basic_string"},{type="wstring"},{type="__gnu_cxx__hash_set"},{type="uint8_t"},{type="int8_t"},{type="__m128"},{type="__m256"},{type="__m512"},{type="__m128d"},{type="__m256d"},{type="__m512d"},{type="__m128i"},{type="__m256i"},{type="__m512i"},{type="Eigen__Matrix"},{type="KDSoapValue1"},{type="KDSoapValue"},{type="boost__bimaps__bimap"},{type="boost__optional"},{type="boost__shared_ptr"},{type="boost__container__list"},{type="boost__gregorian__date"},{type="boost__posix_time__ptime"},{type="boost__posix_time__time_duration"},{type="boost__unordered__unordered_set"},{type="Core__Id"},{type="Debugger__Internal__GdbMi"},{type="Debugger__Internal__DisassemblerLine"},{type="Debugger__Internal__WatchData"},{type="Debugger__Internal__WatchItem"},{type="Debugger__Internal__BreakpointModelId"},{type="Debugger__Internal__ThreadId"},{type="CPlusPlus__ByteArrayRef"},{type="CPlusPlus__Identifier"},{type="CPlusPlus__Symbol"},{type="CPlusPlus__Class"},{type="CPlusPlus__IntegerType"},{type="CPlusPlus__FullySpecifiedType"},{type="CPlusPlus__NamedType"},{type="CPlusPlus__PointerType"},{type="CPlusPlus__TemplateNameId"},{type="CPlusPlus__QualifiedNameId"},{type="CPlusPlus__Literal"},{type="CPlusPlus__StringLiteral"},{type="CPlusPlus__Internal__Value"},{type="Utils__FileName"},{type="Utils__ElfSection"},{type="CPlusPlus__Token"},{type="CPlusPlus__Internal__PPToken"},{type="ProString"},]}@
>3^
>(lldb) script theDumper.setupInferior({"attachpid":-1,"breakonmain":0,"dyldframeworkpath":"","dyldimagesuffix":"","dyldlibrarypath":"","executable":"/Users/rochus/Downloads/busy/build-LeanQt-Desktop-Debug/examples/hello","nativemixed":0,"platform":"","processargs":[],"remotechannel":"","startmode":1,"sysroot":"","token":4,"useterminal":0})
>@
>result={token="4",success="1",msg="success",exe="/Users/rochus/Downloads/busy/build-LeanQt-Desktop-Debug/examples/hello"}@
>4^
dNOTE: INFERIOR SETUP OK
dState changed from InferiorSetupRequested(4) to InferiorSetupOk(6) [master]
dState changed from InferiorSetupOk(6) to EngineRunRequested(7) [master]
dQUEUE: RUN ENGINE
dCALL: RUN ENGINE
sRunning requested...
<5runEngine({"token":5})
>(lldb) script theDumper.runEngine({"token":5})
>Traceback (most recent call last):
> File "<input>", line 1, in <module>
> File "/var/folders/86/95rc7rvs2_z7x7wlzbhnys9h0000gn/T/LeanCreator-Cw57Iw/lldbbridge.py", line 708, in runEngine
> self.prepare(args)
> File "/var/folders/86/95rc7rvs2_z7x7wlzbhnys9h0000gn/T/LeanCreator-Cw57Iw/lldbbridge.py", line 744, in prepare
> launchInfo = lldb.SBLaunchInfo(self.processArgs_)
> File "/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 6660, in __init__
> _lldb.SBLaunchInfo_swiginit(self, _lldb.new_SBLaunchInfo(argv))
>TypeError: not a list
`
After spending a lot of time trying to understand the complex interaction between Qt Creator and LLDB and how to fix the problems, I concluded that the only way to master the problems was to massively simplify this interaction.
Reuse of the GDB/MI protocol was not possible for several reasons. Although there is a working version of QtCreator that can only be used via GDB/MI (up to version 3.0.1); the code is so different from version 3.6 that a migration seemed too costly. And unfortunately LLDB-MI does not work reliably yet, and it has already been kicked out of the LLVM project and thus is no longer available on Apple. And using LLDB-MI on Debian with LeanCreator to simulate GDB didn't work anyway, because the Python based protocol is not compatible. I had no luck with lldbmi2 either; there were even more errors than with LLDB-MI, since only part of the interface is supported.
I also looked at the new DAP protocol from Microsoft. DAP is huge and for LLDB so far only supported by codelldb. I didn't manage to access it outside of VSCode and all in all it seems way too early to get into DAP; in a few years maybe.
Finally, I implemented a new LLDB adapter for LeanCreator myself, which simply communicates with LLDB via the console. I even managed to implement a reasonable formatting of the variables for QByteArray and QString completely without Python; this worked quite well on Linux, but the Mac unfortunately failed because of the additional interactions with the console; something is blocking communication there; so it was with reluctance that I started using Python for the value summaries and synthetic children.
I have been successful with this approach on Mac and Linux. At the moment, however, I only support a subset of the possible features, and there are still a few bugs. But essentially I can already debug with it on Mac, which was my primary goal. I therefore close this issue.