2013-09-30 60 views
0

我有一個自定義的C++容器類型,並且想要在Xcode變量視圖中改變外觀方式。需要做一些類似於NSArraystd::vector那樣的東西。XLD中的LLDB容器類型彙總

現在一個只能改變彙總字符串輸出容器大小,並不知道如何安排容器的孩子在一個樹索引。默認視圖輸出容器ivars。

是否可以使用LLDB Python腳本在樹中輸出容器子項?

回答

0

是的,的確如此。

您正在查找的功能稱爲「合成兒童」,它基本上涉及將Python類綁定到您的數據類型。然後LLDB會在需要出售子對象(容器中的元素)時詢問您的類,而不是像當前正在執行的那樣信任調試信息。 有一點區別[1],這與LLDB對NSArray,std :: vector和其他幾個人的做法是一樣的。

[1]衆所周知的系統類型的合成兒童提供者用C++編寫,屬於在LLDB核心,主要是出於性能的考慮

爲了推出自己的,你需要實現一類服從該規格:

class SyntheticChildrenProvider: 
    def __init__(self, valobj, internal_dict): 
     this call should initialize the Python object using valobj as the variable to provide synthetic children for 
    def num_children(self): 
     this call should return the number of children that you want your object to have 
    def get_child_index(self,name): 
     this call should return the index of the synthetic child whose name is given as argument 
    def get_child_at_index(self,index): 
     this call should return a new LLDB SBValue object representing the child at the index given as argument 
    def update(self): 
     this call should be used to update the internal state of this Python object whenever the state of the variables in LLDB changes.[1] 
    def has_children(self): 
     this call should return True if this object might have children, and False if this object can be guaranteed not to have children.[2] 

[1]這種方法是可選的。另外,它可以選擇返回一個值(從SVN rev153061/LLDB-134開始)。如果它返回一個值,並且該值爲True,則LLDB將被允許緩存子項,並且子項會對之前獲得的值進行計數,並且不會返回提供者類來詢問。如果沒有返回任何內容,None或True以外的任何內容,LLDB將丟棄緩存的信息並詢問。無論如何,只要有必要,LLDB都會致電更新。 [2]此方法是可選的(從SVN rev166495/LLDB-175開始)。儘管以num_children的形式實現它是可以接受的,但鼓勵實現者在合理的時候尋找優化的編碼替代方案。

詳細信息在http://lldb.llvm.org/varformats.html,包括指向可用作起始點的幾個示例實現的鏈接。

如果您有任何其他問題或需要更多指導,請隨時回覆!