openjdk-7 gdb 清單錯誤:“main.c:沒有這樣的檔案或目錄”

openjdk-7 gdb 清單錯誤:“main.c:沒有這樣的檔案或目錄”

我目前正在努力在 Trusty Tahr 中調試 openjdk。我已經安裝了opejdk-7-jdk並且openjdk-7-dbg.當我發出問題時gdb java,我看到它正確讀取了符號,但是當我要求列出代碼時,它抱怨找不到 main.c。我設法在 CentOS 中進行調試,並且可以列出檔案 main.c,但我想讓它在 Ubuntu 上運行,因為它是我的主要發行版。

原始輸出:

GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from java...Reading symbols from /usr/lib/debug//usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java...done.
done.
(gdb) l
85  ../../../../src/share/bin/main.c: No such file or directory.
(gdb) 

我需要做一些額外的事情來將 main.c 放在可以找到的地方嗎?

答案1

您應該修改source pathgdb 使用的內容來尋找原始檔案。

根據gdb手冊:

可執行程式有時不會記錄編譯它們的原始檔案的目錄,而只記錄名稱。即使這樣做,目錄也可以在編譯和偵錯會話之間移動。 GDB有一個目錄列表來搜尋原始檔;這稱為來源路徑。

您首先需要找出來源檔案在系統上的位置:

 locate main.c

然後使用dir dirname命令:

將目錄 dirname 加入到來源路徑的前面。可以為此命令指定多個目錄名稱,以“:”(在 MS-DOS 和 MS-Windows 上為“;”,其中“:”通常作為絕對檔案名稱的一部分出現)或空格分隔。您可以指定來源路徑中已有的目錄;這會向前移動,因此 GDB 會更快地搜尋它。

仔細閱讀上面的 gdb 手冊連結以了解如何source path使用它。

相關內容