簡體   English   中英

根據gdb信息源未找到源文件

[英]source file not found according to gdb info source

我正在調試運行帶有動態鏈接的共享庫的C應用程序。 該程序在Ubuntu 14.04 64位上運行良好。 但是當Linux在退出應用程序時終止共享對象時,它將在Ubuntu 16.04上產生分段錯誤。

在gdb內部,我在出現分段錯誤之前設置了一個斷點。 然后,我使用info source檢查源文件信息:

Thread 1 "test" hit Breakpoint 3, _dl_fini () at dl-fini.c:201
(gdb) info source
Current source file is dl-fini.c
Compilation directory is /build/glibc-bfm8X4/glibc-2.23/elf
Located in /build/glibc-bfm8X4/glibc-2.23/elf/dl-fini.c
Source language is c.
Producer is GNU C11 5.4.0 20160609 -mno-mmx -mtune=generic -march=x86-64 -g -O2 -O3 -std=gnu11 -fgnu89-inline -fno-stack-protector -fmerge-all-constants -frounding-math -fPIC -ftls-model=initial-exec.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.

我找不到指定的編譯目錄和源文件的位置。

目錄/build/glibc-bfm8X4/glibc-2.23/elf不存在。 有人對這種情況有任何想法嗎?

提前致謝。

那是編譯glibc的機器上的目錄。 它在我們的機器上不存在。

安裝相關軟件包的-dbg版本(使用sudo apt-get install )-獲取已安裝的調試符號。 獲取庫的源代碼(通過使用apt-get source )-獲取下載到當前目錄中的實際源文件。

對於glibc它是sudo apt-get install libc6-dbgapt-get source libc6

有用的命令:

  • 列出所有軟件包: dpkg -l (然后可以在列表中使用grep以獲得特定的軟件包名稱)
  • 列出軟件包中的文件: dpkg -L <package name>
  • 搜索文件所屬的軟件包: dpkg -S <file path>

~/.gdbinit使用directory <path to source dir>聲明將gdb指向帶有源代碼的正確目錄。

另外,嘗試使用valgrindrr實用程序。

暫無
暫無

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

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