gdb: “No symbol table is loaded”

gdb: “No symbol table is loaded”

Ask Question

up vote68down votefavorite

15

I keep getting this error mesage when trying to add a breakpoint in gdb.

I've used these commands to compile:

gcc -g main.c utmpib2.c -o main.o
and:
cc -g main.c utmpib2.c -o main.o
and also:
g++ -g main.c utmpib2.c -o main.o

I also tried "-ggdb" instead of "-g" and I still get that error message.

I then execute gdb:

$gdb

In gdb:

(gdb)exec-file main.o
(gdb)break 59
No symbol table is loaded. Use the "file" command.

c gdb

shareimprove this question

edited Feb 12 '12 at 2:03

asked Feb 12 '12 at 1:38

user994165

3,4321560101

  • Oh I meant main.o. I updated it. I tried also using "-ggdb" and it is still giving me the same problem. – user994165 Feb 12 '12 at 1:51

  • Show us exactly how are you invoking gcc and gdb. Copy-paste to avoid any erors. – Piotr Praszmo Feb 12 '12 at 1:53

  • 1

    I updated my commands. This is really weird. It just started working. I know previously I was accessing gdb using "gdb a.out" and I was getting an error message about a.out not existing or something. Then I switched to the "exec-file". Now I tried with a.out and it says "This GDB was configured as "i486-linux-gnu" " and breakpoints can be set. – user994165 Feb 12 '12 at 2:08

  • oh duh I was specifying the wrong file a.out. I followed along a gdb tutorial without thinking to change the filename to my own. – user994165 Feb 12 '12 at 2:12

add a comment

4 Answers

activeoldestvotes

up vote48down voteaccepted

First of all, what you have is a fully compiled program, not an object file, so drop the .o extension. Now, pay attention to what the error message says, it tells you exactly how to fix your problem: "No symbol table is loaded. Use the "file" command."

(gdb) exec-file test
(gdb) b 2
No symbol table is loaded.  Use the "file" command.
(gdb) file test
Reading symbols from /home/user/test/test...done.
(gdb) b 2
Breakpoint 1 at 0x80483ea: file test.c, line 2.
(gdb) 

 exec-file test(编译程序)

 file test

Or just pass the program on the command line.

$ gdb test
GNU gdb (GDB) 7.4
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[...]
Reading symbols from /home/user/test/test...done.
(gdb) b 2
Breakpoint 1 at 0x80483ea: file test.c, line 2.
(gdb) 

shareimprove this answer

edited Jan 14 '14 at 3:51

answered Feb 12 '12 at 4:10

Kevin

37.2k974104

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值