問題描述
每次 gdb 捕獲異常時,我都會收到一個煩人的錯誤.我已經運行了以下示例程序
運行 gdb 的結果是
這還不算太糟,因為我確實得到了我需要的信息,只是讓我煩惱...
有人知道如何解決這個問題嗎?
要在 Ubuntu 上對 C 庫進行完整的源代碼調試,只需幾個步驟:
安裝 libc6 的 debuginfo 版本.
它可能已經安裝 - Ubuntu 上的 gdb 軟件包依賴于它 - 但如果沒有,請運行
sudo apt install libc6-dbg
.準備包系統以下載和處理源代碼包(如果之前尚未完成).
Grep 的輸出應該顯示(并且可能還有我們不需要擔心的其他匹配項):
<塊引用>如果 grep 顯示這些
<塊引用>deb-src
行用#
注釋掉:然后編輯
/etc/apt/sources.list
刪除這些行開頭的#
,然后運行sudo apt update
.下載與安裝的C庫版本對應的源代碼.
首先,在任何地方創建一個目錄 - 我將在這里使用
/opt/src
.然后執行以下操作:
如果
的錯誤信息<塊引用>apt
命令給出類似E:您必須在您的 sources.list 中放入一些源"URI
那么我在第 2 步中的說明可能已經過時了;在這里發表評論.
下載完成后,運行:
記住這個名字 - 它類似于
/opt/src/glibc-2.23
確定 gdb 希望在哪里找到源代碼并進行適當的調整.
運行 gdb,讓它運行你的程序直到它停止,然后在 gdb 提示符下執行以下操作:
所以 gdb 期望源代碼在
/build/glibc-KM3i_a/glibc-2.23
中.有兩種方法可以解決此問題:- 移動(或使用符號鏈接)使源代碼位于(或看起來)位于
/build/glibc-KM3i_a/glibc-2.23
中.或者
告訴 gdb 如何替換正確的源目錄路徑名:
現在,回到你的框架,gdb 應該顯示源代碼行:
- 移動(或使用符號鏈接)使源代碼位于(或看起來)位于
I'm getting an an annoying error every time gdb catches an exception. I've run the following example program
And the result from running gdb is
It's not all that bad, as I do get the information I need, it's just bugging me...
Do anyone know how to fix this?
To do full source code debugging of the C library on Ubuntu, there are just a few steps to take:
Install the debuginfo version of libc6.
It's probably already installed - the gdb package on Ubuntu has a dependency on it - but in case it isn't, run
sudo apt install libc6-dbg
.Prepare the package system to download and process source code packages, if this hasn't previously been done.
Grep's output should show (and there may be additional matches that we don't need to worry about):
If the grep shows that these
deb-src
lines are commented out with#
:then edit
/etc/apt/sources.list
to remove the#
at the beginning of these lines and then runsudo apt update
.Download the source code corresponding to the installed version of the C library.
First, create a directory anywhere - I'll use
/opt/src
here.Then do the following:
If the
apt
command gives an error message likeE: You must put some 'source' URIs in your sources.list
then my instructions in step 2 may have become outdated; post a comment here.
When the download is complete, run this:
Remember this name - it'll be something like
/opt/src/glibc-2.23
Determine where gdb expects to find the source code and make appropriate adjustments.
Run gdb, have it run your program until it stops, and at the gdb prompt do this:
So gdb is expecting the source code to be in
/build/glibc-KM3i_a/glibc-2.23
. There are two ways to fix this:- Move (or use a symlink) so that the source code is (or appears to be) in
/build/glibc-KM3i_a/glibc-2.23
.or
Tell gdb how to substitute the correct source directory pathname:
Now, go back to your frame, and gdb should show the source code line:
- Move (or use a symlink) so that the source code is (or appears to be) in
這篇關于GDB 抱怨缺少 raise.c的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!