Re: [問題] gdb/strace 一問

看板Linux作者時間15年前 (2008/10/01 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/6 (看更多)
※ 引述《mystea.bbs@ptt.cc (mystea)》之銘言: > 我現在在debug的程式, 能compile, > 能執行, 但是不會做我要他做的事. > 最糟糕的是, 當他結束時, gdb告訴我Program exited normally. > 因為如此, 我好像沒有辦法知道他是從那一行離開的. > 有辦法可以用gdb知道嗎? > 我還使用了strace, 結果有找到程式結束執行前的call: > munmap(0xb7fde000, 4096) = 0 (這行停了好久) > 然後我打enter, 隔一陣子吐出了很多行, 最後 > exit_group(o) = ? > Process 15004 detached > 結束. > 請問這個資訊要怎麼跟我的原始碼扯上關係呢? compile 的時候有加 -g 參數嗎? ex: gcc -g -o 123 123.c 有 -g 才會有 debug info gdb abc (gdb) b main (gdb) r (gdb) c Program exited normally b 是 break 的意思,main 就是在 main 斷點,r 是 run, 所以到 main 的地方就會先停下來,此時可以 print a,代表 print a 變數 c 是 continue 繼續執行,直到這中間有 break 或者跑到程式結束 -- ╭───╮╭───╮ ╭───╮ ██◣█ ████ ██ █ .尋找今晚屬於你的夢境. └┤ ████ ██ ██ █ ╭──────────────────╯ ████ ████ ██ █ 尋夢位址:61-229-217-116.dynamic.hinet.ne ██◥█ ██ ████ │國立虎尾科技大學.尋夢園 bbs.nfu.edu.tw ╰───╯╰──╯ ╰───╯ ╰────────────────────
文章代碼(AID): #18ucbW00 (Linux)
文章代碼(AID): #18ucbW00 (Linux)