开发者

Setting a breakpoint with gdb when the same source file is used multiple times

I have a foo.c source file which has the following function implementation:

#include "header.h"
void PREFIX(function_name)(){
   ...
}

I'll copy this file into two directories (dir1 and dir2). In dir1, I have header.h like this:

#define PREFIX(a) prefix1_ ## a

and in dir2, I have header.h like:

#define PREFIX(a) prefix2_ ## a

Therefore, during the linking process, I'll have two different function names.

My problem comes up when I want to use gdb to debug this function and I need to set a breakpoint in a specific line within this function. If I do:

b f开发者_如何学Gooo.c:235

and 235 is a line inside the function implementation, in which function is gdb going to actually set the breakpoint? prefix1_function_name or prefix2_function_name ?

Is there a way to make gdb set the breakpoint on both ?

Thanks!


Why not just try it out? When I tried it, it set a break point in both files:

(gdb) break a.c:5
Breakpoint 1 at 0x100000e87: file 3/a.c, line 5.
Breakpoint 2 at 0x100000e75: file 2/a.c, line 5.
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.

If you want to break in only a specific file, just use the full path name to that file to disambiguate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜