2012-10-08 38 views
2

我正在使用Xcode 4.5中的X86_64程序。我在_NSWarnForDrawingImageWithNoCurrentContext上得到警告,并停止在没有上下文的情况下进行绘图调用。该调用发生在深层的CALayer/NSView调用中。我想知道这与什么观点有关。检查lldb帧堆栈上系统调用的参数

#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:剪辑:正在呼吁?

我试图切换到第29帧,然后做一个p/x $arg1但提供了错误

error: Couldn't materialize struct: Couldn't read rdi (materialize)

我只找到源代码,并提交与此相关的错误日志和无法弄清楚什么它的意思是。任何帮助将不胜感激,因为这也有助于避免使用过时的调用给出警告的Apple代码消息。

回答

3

您可以尝试使用“register read”命令,如“reg read arg1”,但真正的问题在于rdi是SysV x86_64 ABI的易失性寄存器。这意味着无论何时进行函数调用,rdi的内容都可能被覆盖而不保存在任何地方。一旦帧29被称为帧28,调试器将假定rdi已被覆盖(帧29可能将其本身作为arg存储到帧28),并且将不能检索帧29已经存在的rdi的先前内容条目。

即使在堆栈中间,名为“非易失性”或“被保存的被保护”的寄存器也能保证可检索。在x86_64上,这些包括rbx和r12-r15。如果第29帧使用r12来保存一个变量,调用帧28和帧28想要使用r12,它必须将旧值保存到堆栈,然后在返回到帧29之前恢复该值。调试器知道如何找到这个保存位置,并可以在第29帧中向您显示r12的内容 - 通过查看第28帧在哪里保存并检索值。 (1)在第29帧上放置一个断点并在该点输出arg1的值,或者(2)查看第29帧的汇编指令,并查看该函数是否保存了第一个参数在某处(在堆栈上,在非易失性寄存器中),您仍然可以检查。否则,当你更深层次的28个栈帧时,参数寄存器的内容早已消失。