作者fishxd1096 (費許差D)
看板C_and_CPP
標題[問題] CMake在vscode中debug出現錯誤
時間Sat Jun 19 16:42:36 2021
開發平台(Platform): (Ex: Win10, Linux, ...)
Linux
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
GCC
問題(Question):
我照著VSCODE官方的CMake Hello World教學操作,可以編譯、可以執行,但是進行debug時出現錯誤。
(我不會用CMake,只知道是用來Build專案的工具,所以想透過這個hello world開始學習)
我選擇的Kit
https://imgur.com/FNCF113
Build訊息
https://imgur.com/rwZKcCJ
可以在斷點停下
https://imgur.com/ZQo2hgq
Debug訊息
https://imgur.com/sSEm6x5
但按下Step後就錯誤了
https://imgur.com/19nicB8
我在該路徑應該放什麼檔案嗎?我的根目錄沒有build這個資料夾
https://imgur.com/BT7GIU4
我前陣子google了很久還是不知道怎麼解決,所以決定詢問大家
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.174.74.29 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1624092158.A.1AC.html
→ Sanvean: 你是用 Step in, Step out 還是 Step over? 我猜是用到 06/19 17:15
→ Sanvean: Step in,然後進到沒有 debug 資訊的 library 裡了。 06/19 17:18
啊!確實是因為我按了Step in,我按了Step over就沒問題了,天啊我被這個問題卡好久....
但想進一步問「進到沒有debug資訊的library」是什麼意思?
我的猜測是standard library和我的hello world連結時,用的是非debug的obj,所以當我想step into時就會出現錯誤?
是這樣嗎?
※ 編輯: fishxd1096 (1.174.74.29 臺灣), 06/19/2021 18:10:23
推 Sanvean: 當你在 cout 那一行要 Step in 的時候應該會進到 06/19 18:31
→ Sanvean: Standard Library,如果沒有特別安裝或自己編譯,stdlib 06/19 18:33
→ Sanvean: 不是沒有 debug 資訊就是沒有對應可以 debug 的原始碼。 06/19 18:34
了解了,謝謝解答!
※ 編輯: fishxd1096 (1.174.74.29 臺灣), 06/19/2021 18:45:24