Debugging 调试gdb-列出正在使用的源目录

Debugging 调试gdb-列出正在使用的源目录,debugging,gdb,ada,Debugging,Gdb,Ada,试图调试ada程序时,gdb似乎无法找到源代码。我确实确认了正在运行的可执行文件与刚才构建的相同。附加时,它会在控制台中显示以下内容,而不是将我带到源代码中的当前位置: (gdb) attach 804 0x0000003de620b68c in ?? () (gdb) frame 1 #1 0x0000000000000000 in ?? () (gdb) frame 0 #0 0x0000003de620b68c in ?? () 有没有办法让gdb告诉我它正在使用哪个源目录?或者是

试图调试ada程序时,gdb似乎无法找到源代码。我确实确认了正在运行的可执行文件与刚才构建的相同。附加时,它会在控制台中显示以下内容,而不是将我带到源代码中的当前位置:

(gdb) attach 804 
0x0000003de620b68c in ?? ()
(gdb) frame 1
#1  0x0000000000000000 in ?? ()
(gdb) frame 0
#0  0x0000003de620b68c in ?? ()
有没有办法让gdb告诉我它正在使用哪个源目录?或者是否有其他解决此问题的方法

我将在x86_64-pc-linux-gnu上的2017年全球定位系统(20170515)中发布此版本
GNAT Pro 6.4.2(20110614-45)。

似乎您没有给gdb符号表,或者您的程序被剥离

当您附加到一个程序时,您应该告诉gdb您附加了什么可执行文件,以便它读取符号表。您应该使用-g(调试支持)编译程序,并确保链接过程不会删除符号。然后,按如下方式运行gdb:

gdb myprog -p 804
但是,您也可以不附加(这就是您所做的)而运行,然后附加

gdb myprog
GNU gdb (GDB) 7.10 for GNAT GPL 2017 [rev=gdb-7.10-ref-199-g7cfc608]
Copyright (C) 2015 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.
See your support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty for this version of GDB.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from prog...done.
(gdb) attach 804
如果您的程序被剥离,gdb将打印

Reading symbols from prog...(no debugging symbols found)...done.
读取符号表后,可以使用info sources命令列出gdb识别的源文件。这将告诉您已在符号表中标识的源文件

(gdb) info sources
Source files for which symbols have been read in:

.../b__myprog.adb, 
.../b__myprog.ads, 
/build/eglibc-SvCtMH/eglibc-2.19/elf/rtld.c, 
/build/eglibc-SvCtMH/eglibc-2.19/elf/../sysdeps/generic/_itoa.h, 
/build/eglibc-SvCtMH/eglibc-2.19/elf/../sysdeps/unix/sysv/linux/dl-osinfo.h, 
...
您可能使用的另一个有趣的命令是info files。这将告诉您已使用关联符号文件标识的程序节。如果您有动态库,您也应该在那里看到它们

(gdb) info files
Symbols from "myprog".
Native process:
    Using the running image of child Thread 0x7ffff7fb4780 (LWP 32214).
    While running this, GDB does not access memory from...
Local exec file:
    `myprog', file type elf64-x86-64.
    Entry point: 0x40ac5e
    0x0000000000400238 - 0x0000000000400254 is .interp
    0x0000000000400254 - 0x0000000000400274 is .note.ABI-tag
    0x0000000000400278 - 0x0000000000400cb4 is .hash
    0x0000000000400cb8 - 0x0000000000403148 is .dynsym
    0x0000000000403148 - 0x00000000004046b5 is .dynstr
    0x00000000004046b6 - 0x00000000004049c2 is .gnu.version
...

似乎您没有给gdb符号表,或者您的程序被剥离了

当您附加到一个程序时,您应该告诉gdb您附加了什么可执行文件,以便它读取符号表。您应该使用-g(调试支持)编译程序,并确保链接过程不会删除符号。然后,按如下方式运行gdb:

gdb myprog -p 804
但是,您也可以不附加(这就是您所做的)而运行,然后附加

gdb myprog
GNU gdb (GDB) 7.10 for GNAT GPL 2017 [rev=gdb-7.10-ref-199-g7cfc608]
Copyright (C) 2015 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.
See your support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty for this version of GDB.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from prog...done.
(gdb) attach 804
如果您的程序被剥离,gdb将打印

Reading symbols from prog...(no debugging symbols found)...done.
读取符号表后,可以使用info sources命令列出gdb识别的源文件。这将告诉您已在符号表中标识的源文件

(gdb) info sources
Source files for which symbols have been read in:

.../b__myprog.adb, 
.../b__myprog.ads, 
/build/eglibc-SvCtMH/eglibc-2.19/elf/rtld.c, 
/build/eglibc-SvCtMH/eglibc-2.19/elf/../sysdeps/generic/_itoa.h, 
/build/eglibc-SvCtMH/eglibc-2.19/elf/../sysdeps/unix/sysv/linux/dl-osinfo.h, 
...
您可能使用的另一个有趣的命令是info files。这将告诉您已使用关联符号文件标识的程序节。如果您有动态库,您也应该在那里看到它们

(gdb) info files
Symbols from "myprog".
Native process:
    Using the running image of child Thread 0x7ffff7fb4780 (LWP 32214).
    While running this, GDB does not access memory from...
Local exec file:
    `myprog', file type elf64-x86-64.
    Entry point: 0x40ac5e
    0x0000000000400238 - 0x0000000000400254 is .interp
    0x0000000000400254 - 0x0000000000400274 is .note.ABI-tag
    0x0000000000400278 - 0x0000000000400cb4 is .hash
    0x0000000000400cb8 - 0x0000000000403148 is .dynsym
    0x0000000000403148 - 0x00000000004046b5 is .dynstr
    0x00000000004046b6 - 0x00000000004049c2 is .gnu.version
...

您似乎有一个比“不定位源”更基本的问题——GDB不知道您的进程在哪里。这很可能与您调用GDB的方式有关。请尝试使用
gdb-p804
来代替。我从GPS的菜单中调用它……您似乎有一个比“不定位源”更基本的问题——gdb不知道您的进程在哪里。这很可能与您调用GDB的方式有关。试试gdb-P804。我在GPS的菜单中调用它…这里有很多好信息-谢谢。我会让你知道如果这让我有任何进展。这里有很多好信息-谢谢。如果这对我有帮助,我会告诉你的。