gdb:如何在带空格的文件中设置断点

时间:2012-02-29 14:22:49

标签: gdb

如何在文件名或路径中有空格的文件中设置断点?

GDB似乎无法做到这一点,或者我错过了什么?

/tmp$ g++ -g debugee\ space.cpp 
/tmp$ gdb ./a.out 
GNU gdb (GDB) 7.4
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /tmp/a.out...done.
(gdb) break "/tmp/debugee space.cpp:4"
Breakpoint 1 at 0x4007e3: file debugee space.cpp, line 4.
(gdb) break "/tmp/debugee space.cpp":4
Note: breakpoint 1 also set at pc 0x4007e3.
Breakpoint 2 at 0x4007e3: file debugee space.cpp, line 4.
(gdb) run
Starting program: /tmp/a.out 
Error in re-setting breakpoint 1: Function "/tmp/debugee space.cpp:4" not defined.
Error in re-setting breakpoint 2: Function "/tmp/debugee space.cpp:4" not defined.
Hello, world!
[Inferior 1 (process 14188) exited normally]
(gdb) 

2 个答案:

答案 0 :(得分:1)

对我而言,这看起来像是gdb 7.4中的回归。我报告了这个错误:http://sourceware.org/bugzilla/show_bug.cgi?id=13798

答案 1 :(得分:0)

适用于我(tm),虽然没有尝试使用c ++ ...

cat space\ spaces.c 
#include <stdio.h>

int tmp(void) {
    int a = 42;
    printf("%d", a);
}

int main(void) {
    tmp();

    return 0;
}

$ gdb -q a.out 
Reading symbols from /home/user/slask/gdb/a.out...done.
(gdb) b "space spaces.c":5
Breakpoint 1 at 0x4004f3: file space spaces.c, line 5.
(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000000004004f3 in tmp at space spaces.c:5
(gdb) run
Starting program: /home/user/slask/gdb/a.out 

Breakpoint 1, tmp () at space spaces.c:5
5       printf("%d", a);
(gdb) 
相关问题