2015-07-21 72 views
1

雖然試圖調試我試圖把break語句代碼通過gdb的代碼,但由於某些原因,GDB看不到源文件,雖然它的存在。我第一次使用gdb,所以不知道這是否正確。下面是終端消息:GDB看不到源文件

~$ cd ~/projects/bison/sandbox/2D-RZ_rodlet_10pellets 
~/projects/bison/sandbox/2D-RZ_rodlet_10pellets$ gdb ../../bison-dbg 
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 ../../bison-dbg...done. 
(gdb) break ~/projects/bison/src/materials/NewMaterial.C:166 
No source file named ~/projects/bison/src/materials/NewMaterial.C. 
Make breakpoint pending on future shared library load? (y or [n]) 

我可以找到源文件:

~/projects/bison/src/materials$ ls | grep New 
NewMaterial.C 
NewMaterial.C~ 
NewMaterial.x86_64-unknown-linux-gnu.dbg.lo 
NewMaterial.x86_64-unknown-linux-gnu.dbg.lo.d 
NewMaterial.x86_64-unknown-linux-gnu.opt.lo 
NewMaterial.x86_64-unknown-linux-gnu.opt.lo.d 

吉安

+0

嘗試從根開始給出完整路徑。 gdb無法找到該文件。完整路徑可能對此有幫助。 –

+0

你用調試選項編譯過嗎? –

+0

提供完整路徑但不工作;給出相同的錯誤信息。是的,我在調試模式下編譯:'METHOD = dbg make'但是這是在gdb之外完成的。 – gyan

回答

1
  1. 不要~字符使用的文件名。 Gdb不會將它們擴展到您的HOME位置。
  2. 確保您的代碼編譯爲-g標誌。
  3. 儘量只使用文件名,如果不是曖昧,所以:
    break NewMaterial.C:166
  4. 如果它是不明確的,嘗試與路徑相關的「編制根」(例如項目的根使用它,只是因爲它是傳遞給編譯器)。
  5. 作爲最後的手段 - 使用完整路徑(但字面意思:完整路徑,沒有~標誌)。