簡體   English   中英

調試gdb - 列出正在使用的源目錄

[英]Debugging gdb - listing source directories in use

試圖調試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 GNAT Pro 6.4.2(20110614-45)上托管的GPS 2017(20170515)中推出的。

您似乎沒有給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

您還可以使用symbol-file命令告訴gdb要運行的程序文件:

(gdb) symbol-file myprog
Reading symbols from myprog...done.

如果你的程序被剝離,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, 
...

您可能使用的另一個有趣的命令是信息文件 這將告訴您已使用關聯的符號文件標識的程序部分。 如果你有動態庫,你也應該在那里看到它們。

(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
...

暫無
暫無

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

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