[Debug] 在編譯時 p7zip 時保留 debug symbols

[Debug] 在編譯時 p7zip 時保留 debug symbols

最近在整合 lib7zip 和 p7zip,有時 API 的呼叫不如預期,

還是得去 trace 一下 lib7zip 和 p7zip 的程式碼…

lib7zip 比較簡單,預設狀況似乎都有 debug symbol,但 p7zip 就沒有了,

導致 gdb 只要進到呼叫 p7zip 的部分,就沒辦法進去單步執行了…

 

找到了 p7zip debug help 這篇上面有解答,

原來只要將 makefile.machine 檔案裡的 OPTFLAGS 設成 -g2,

並且把 -s 從 ALLFLAGS 中拿掉,就能在 p7zip 中保留 debug symbol 了:

OPTFLAGS=-g2
ALLFLAGS=${OPTFLAGS} -pipe \
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-DNDEBUG -D_REENTRANT -DENV_UNIX \
-D_7ZIP_LARGE_PAGES \
$(LOCAL_FLAGS)

 

註:在 gcc 中,-s 是代表 Remove all symbol table and relocation information from the executable

因此所有的 debug symbol 都會被移除囉~

(本頁面已被瀏覽過 66 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料