加载标记为&#34的gdb源;按需读取"

时间:2016-10-20 08:32:22

标签: gdb debug-symbols

我在GDB中调试C应用程序(postgres)。当我遇到断点时,堆栈的顶部框架将始终具有源信息,但较低的帧通常不会:

(gdb) bt
#0  findTargetlistEntrySQL99 (pstate=0x555555ef8f78, node=0x555555ef8c08, tlist=0x555555ef90d0, exprKind=EXPR_KIND_GROUP_BY) at /home/sergei/postgresql/src/backend/parser/parse_clause.c:1775
#1  0x00005555556c6e9d in findTargetlistEntrySQL92 (pstate=<optimized out>, node=<optimized out>, tlist=<optimized out>, exprKind=<optimized out>) at /home/sergei/postgresql/src/backend/parser/parse_clause.c:1744
#2  0x00005555556c72d5 in transformGroupClauseExpr (flatresult=flatresult@entry=0x7fffffffd0a0, seen_local=seen_local@entry=0x0, pstate=pstate@entry=0x555555ef8f78, gexpr=gexpr@entry=0x555555ef8c08, targetlist=targetlist@entry=0x555555ef90d0, sortClause=sortClause@entry=0x0, exprKind=EXPR_KIND_GROUP_BY, useSQL99=0 '\000', toplevel=1 '\001') at /home/sergei/postgresql/src/backend/parser/parse_clause.c:1970
#3  0x00005555556c9192 in transformGroupClause (pstate=0x555555ef8f78, grouplist=<optimized out>, groupingSets=0x555555ef90f0, targetlist=0x555555ef90d0, sortClause=0x0, exprKind=EXPR_KIND_GROUP_BY, useSQL99=0 '\000') at /home/sergei/postgresql/src/backend/parser/parse_clause.c:2287
#4  0x00005555556aa111 in transformStmt ()
#5  0x00005555556abe6d in parse_analyze ()
#6  0x000055555574c50e in DefineView ()
#7  0x0000555555867bda in ProcessUtilitySlow.isra.4 ()
#8  0x0000555555866a97 in standard_ProcessUtility ()
#9  0x0000555555864084 in PortalRunUtility ()
#10 0x0000555555864b95 in PortalRunMulti ()
#11 0x00005555558657a4 in PortalRun ()
#12 0x00005555558631f2 in exec_simple_query (query_string=0x555555ea6de0 "-- Statistics views\n\nCREATE VIEW pg_stat_all_tables AS\n    SELECT\n", ' ' <repeats 12 times>, "C.oid AS relid,\n", ' ' <repeats 12 times>, "N.nspname AS schemaname,\n", ' ' <repeats 12 times>, "C.relname AS relname,\n", ' ' <repeats 12 times>, "pg_stat_get_numscans(C."...) at /home/sergei/postgresql/src/backend/tcop/postgres.c:1094
#13 PostgresMain (argc=<optimized out>, argv=<optimized out>, dbname=<optimized out>, username=<optimized out>) at /home/sergei/postgresql/src/backend/tcop/postgres.c:4069
#14 0x00005555555f719d in main ()

起初,我怀疑GDB无法找到较低帧的源文件。但是,情况并非如此: info sources 显示这些源文件,但它们标记为&#34;按需读取&#34;。例如,第6帧中的函数DefineViewview.c中定义。

(gdb) info sources
Source files for which symbols have been read in:
    ...
Source files for which symbols will be read in on demand:
    ... , /home/sergei/postgresql/src/backend/commands/view.c , ...

所有源文件路径(包括view.c)都是正确的。 如何让GDB加载这些源?我正在使用IDE中的GDB,因此需要一次性配置更改的解决方案。

1 个答案:

答案 0 :(得分:1)

命令行选项gdb - readnow ,会导致gdb在发现符号文件时读取它们。