Strawberry
Strawberry

Reputation: 67888

Why is my gdb debugger setting 2 break points?

Is this normal? I swear it was setting only 1 break point until recently. How do I make it only set a breakpoint in my running file and not the source file.

(gdb) break main
Breakpoint 1 at 0x1dbf
Breakpoint 2 at 0x1ed8: file arrays.c, line 17.
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb) 

Upvotes: 1

Views: 956

Answers (1)

sehe
sehe

Reputation: 393114

There are multiple main symbols :) Perhaps look at 'info breakpoints' in gdb or

objdump -C -t myprog

to see why/where.

Use cscope to interactively search for declarations.

ctags -R . && grep -w main tags
[ -x /usr/bin/vim ] && vim +'tj main'

Should be helpful as well if you have ctags (and optionally, vim) installed

If all else fails, brute force grep -RIw main . should work. If even that fails, you should find yourself with very strange external header #defines or even a (static) library with a surplus main symbol. To brute force search for the main identifier through the preprocessed sources:

find -name '*.c'    -print0 | xargs -0n1 -iQ cpp -I/usr/include/... -DDEBUG Q Q.ii
find -name '*.c.ii' -print0 | xargs grep -wI main

(replace -I/usr/include/... -DDEBUG with the relevant preprocessor defines)

Upvotes: 2

Related Questions