簡體   English   中英

我可以使用linux gdb調試我的cpp代碼嗎? 如果是,我如何在對象上調用的函數上保留斷點

[英]can I debug my cpp code using linux gdb? if yes how can I keep break points on a function which is called over an object

例:

class test_gdb
{
    public:
        void testFun(void)
        {
            cout << "this is test function"<<endl;
        }
};

int main(void)
{
    test_gdb testObj;
    testObj.testFun();
}

在這里,如果我想在testFun保持一個斷點,我該怎么辦呢。 我嘗試過但是使用break testFun但它沒有用。

我該怎么做

幾種方式:

(gdb) break test_gdb::testFun

在所有testFun上設置斷點,無論它們在哪個類中定義:

(gdb) rbreak testFun

如果您有多個具有不同簽名(不同參數類型)的testFun ,則可以使用GDB選項卡完成來選擇一個

(gdb) break 'test_gdb::testFun<TAB>  # GDB will complete or offer multiple choice

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM