检查lldb中帧堆栈上系统调用的参数

时间:2012-10-08 17:36:36

标签: objective-c lldb

我正在使用Xcode 4.5中的X86_64程序。我收到警告要打破_NSWarnForDrawingImageWithNoCurrentContext并停止进行没有上下文的绘图调用。呼叫发生在一组深入的CALayer / NSView呼叫中。我想找出与此相关的观点。

#0  0x00007fff9033f823 in _NSWarnForDrawingImageWithNoCurrentContext ()
#1  0x00007fff8ffd2cf3 in -[NSImageRep drawInRect:fromRect:operation:fraction:respectFlipped:hints:] ()
#2  0x00007fff901444ea in -[NSImageRep _newCGImageForProposedRect:context:hints:flipped:] ()
#3  0x00007fff8ffd3acb in -[NSImageRep CGImageForProposedRect:context:hints:] ()
#4  0x00007fff9006be1d in -[NSImageRep CGImageForProposedRect:context:hints:flipped:] ()
#5  0x00007fff900f0346 in -[NSImage _newSnapshotRepForRep:rect:context:processedHints:] ()
#6  0x00007fff900923c8 in -[NSImage _snapshotRepForRep:rect:context:processedHints:] ()
#7  0x00007fff9006bd77 in __48-[NSImage CGImageForProposedRect:context:hints:]_block_invoke_0 ()
#8  0x00007fff8ffd14d6 in -[NSImage _usingBestRepresentationForRect:context:hints:body:] ()
#9  0x00007fff9006b9e5 in -[NSImage CGImageForProposedRect:context:hints:] ()
#10 0x00007fff8ff14754 in -[_NSImageLayerContents CA_copyRenderValue] ()
#11 0x00007fff890350c3 in -[CALayer(CALayerPrivate) _copyRenderLayer:layerFlags:commitFlags:] ()
#12 0x00007fff89034a7c in CA::Context::commit_layer(CA::Layer*, unsigned int, unsigned int, void*) ()
#13 0x00007fff890349a4 in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#14 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#15 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#16 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#17 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#18 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#19 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#20 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#21 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#22 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#23 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#24 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#25 0x00007fff8903492f in CA::Layer::commit_if_needed(CA::Transaction*, void (*)(CA::Layer*, unsigned int, unsigned int, void*), void*) ()
#26 0x00007fff890258d6 in CA::Context::commit_transaction(CA::Transaction*) ()
#27 0x00007fff89025423 in CA::Transaction::commit() ()
#28 0x00007fff9010f032 in -[NSView(NSLayerKitGlue) _drawRectAsLayerTree:] ()
#29 0x00007fff8ffbe35a in -[NSView _drawRect:clip:] ()
#30 0x00007fff8ffbb093 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#31 0x00007fff8ffbbb24 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#32 0x00007fff8ffba223 in -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] ()
#33 0x00007fff8ffb5e4d in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] ()
#34 0x00007fff8ff7fd73 in -[NSView displayIfNeeded] ()
#35 0x00007fff8ff7f2ac in _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints ()
#36 0x00007fff9054a971 in __83-[NSWindow _postWindowNeedsDisplayOrLayoutOrUpdateConstraintsUnlessPostingDisabled]_block_invoke_01208 ()

如何查看_drawRect:clip:正在调用哪个视图?

我已尝试切换到第29帧,然后执行p/x $arg1,但会出现错误

  

错误:无法实现struct:无法读取rdi(materialize)

我只找到源代码并提交与此错误相关的日志,但无法弄清楚它的含义。任何帮助都将不胜感激,因为这也有助于避免使用有关警告的弃用调用的Apple代码消息。

1 个答案:

答案 0 :(得分:3)

您可以尝试使用"注册读取"命令,如" reg读取arg1",但这里真正的问题是rdi是一个带有SysV x86_64 ABI的易失性寄存器。这意味着无论何时进行函数调用,rdi的内容都可能被覆盖而不会保存在任何地方。一旦第29帧调用第28帧,调试器就会假设rdi已经被覆盖(第29帧可能存储了一些东西作为arg到第28帧)并且将无法检索第29帧所具有的先前rdi内容。条目。

寄存器称为"非易失性"或" callee保留"保证即使在堆栈中间也可以检索。在x86_64上,这些包括rbx和r12-r15。如果第29帧使用r12来保存变量,则调用第28帧和第28帧想要使用r12,它必须将旧值保存到堆栈,然后在它返回到第29帧之前恢复该值。调试器知道如何找到这个保存位置,并可以在第29帧中显示r12的内容 - 通过查看第28帧保存它的位置并检索值。

你唯一的希望是(1)在第29帧放置断点并在该点打印arg1的值,或者(2)查看第29帧的汇编指令并查看函数是否保存了第一个参数你仍然可以检查的某个地方(在堆栈上,在非易失性寄存器中)。否则,当你更深入地堆叠帧时,参数寄存器的内容早已消失。