2015-07-09 43 views
1

例如,與源代碼main.cLLDB:一個行輸出`print`和`display`

#include <stdio.h> 

int main() 
{ 
    int a[10] = {0,1,2,3,4,5,6,7,8,9}; 
    int b = 2; 
    printf("line 7\n"); 
    printf("line 8\n"); 
    return 0; 
} 

隨着LLDB調試器,print a農產品:

(int [10]) $0 = { 
    [0] = 0 
    [1] = 1 
    [2] = 2 
    [3] = 3 
    [4] = 4 
    [5] = 5 
    [6] = 6 
    [7] = 7 
    [8] = 8 
    [9] = 9 
} 

問題0 :我怎樣才能得到一個更緊湊的打印上一個行print,像GDB

$1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} 

隨着LLDB調試器,display adisplay b農產品:

- Hook 1 (expr -- a) 
(int [10]) $0 = { 
    [0] = 0 
    [1] = 1 
    [2] = 2 
    [3] = 3 
    [4] = 4 
    [5] = 5 
    [6] = 6 
    [7] = 7 
    [8] = 8 
    [9] = 9 
} 

- Hook 2 (expr -- b) 
(int) $1 = 2 

問題1:我怎樣才能在兩行的小型印刷爲display,像GDB

2: b = 2 
1: a = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} 
+0

我不知道答案,但你爲什麼你要嗎? –

+3

BTW,問題(S)的漂亮的索引... :-) –

+0

@SouravGhosh我調試代碼並希望顯示17個變數。在GDB中,12行中的輸出。在LLDB,很多線路,這是很難讀,我必須滾動我的屏幕 – user744629

回答

1

默認做什麼類型的,但沒有得到「一線」打印在FormatManager硬編碼的決定:: ShouldPrintAsOn eLiner

,用戶可以相對於該調整的唯一設置是

(lldb) settings show auto-one-line-summaries 
auto-one-line-summaries (boolean) = true 

充當全局殺開關的特徵(true表示「允許」)

甲快速修復你的問題是手動添加摘要所有INT數組,正是如此:

(lldb) type summary add -x "int \[[0-9]+]" -c 

即說,對於所有類型的名稱匹配的正則表達式INT [後面跟着一個或E多的數字後面是],然後強制單行格式

就這樣,我得到

(lldb) fr var x 
(int [10]) x = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9) 
(lldb) expr x 
(int [10]) $2 = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9) 

與所有的說,我覺得你是在一箇舊版本LLDB

的在一個相當新構建的調試器,我得到一個行顯示,即使沒有自定義格式:

(lldb) expr x 
(int [10]) $0 = ([0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9)