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

gdb:如何在带有空格的文件中设置断点,gdb,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

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

这似乎是不可能的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) /tmp$g++-g debugee\space.cpp /tmp$gdb./a.out GNU gdb(gdb)7.4 版权所有(C)2012免费软件基金会。 许可证GPLv3+:GNU GPL版本3或更高版本 这是自由软件:您可以自由更改和重新发布它。 在法律允许的范围内,不存在任何担保。键入“显示复制” 和“显示保修”了解详细信息。 此GDB配置为“x86_64-unknown-linux-gnu”。 有关错误报告说明,请参阅: ... 从/tmp/a.out读取符号…完成。 (gdb)中断“/tmp/debugee空间。cpp:4” 断点1位于0x4007e3:文件debugee space.cpp,第4行。 (gdb)中断“/tmp/debugee space.cpp”:4 注意:断点1也设置在pc 0x4007e3上。 断点2位于0x4007e3:文件debugee space.cpp,第4行。 (gdb)运行 启动程序:/tmp/a.out 重新设置断点1时出错:函数“/tmp/debugee space.cpp:4”未定义。 重新设置断点2时出错:函数“/tmp/debugee space.cpp:4”未定义。 你好,世界! [次1(进程14188)正常退出] (gdb)

为我工作(TM),虽然没有尝试用C++……< /P>

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) 
cat space\spaces.c
#包括
int tmp(无效){
INTA=42;
printf(“%d”,a);
}
内部主(空){
tmp();
返回0;
}
$gdb-q a.out
从/home/user/slask/gdb/a.out读取符号…完成。
(gdb)b“spaces.c”:5
断点1位于0x4004f3:文件空间spaces.c,第5行。
(gdb)IB
Num Type Disp Enb地址什么
1个断点将y 0x00000000004004f3保留在tmp中的空格处。c:5
(gdb)运行
启动程序:/home/user/slask/gdb/a.out
断点1,tmp()位于空格处。c:5
5 printf(“%d”,a);
(gdb)
<代码> > P>为我工作(TM),虽然没有尝试用C++……< /P>
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) 
cat space\spaces.c
#包括
int tmp(无效){
INTA=42;
printf(“%d”,a);
}
内部主(空){
tmp();
返回0;
}
$gdb-q a.out
从/home/user/slask/gdb/a.out读取符号…完成。
(gdb)b“spaces.c”:5
断点1位于0x4004f3:文件空间spaces.c,第5行。
(gdb)IB
Num Type Disp Enb地址什么
1个断点将y 0x00000000004004f3保留在tmp中的空格处。c:5
(gdb)运行
启动程序:/home/user/slask/gdb/a.out
断点1,tmp()位于空格处。c:5
5 printf(“%d”,a);
(gdb)

在我看来,这就像GDB7.4中的回归。我报告了这个bug:

对我来说,这看起来像是GDB7.4中的回归。我报告了错误:

您使用的是哪个版本的gdb?我在你的应用程序和使用gcc编译时遇到了相同的错误。我有gdb 7.4同样的问题:重新设置断点1时出错:函数“/tmp/space test.c:5”未定义。(GDB7.4)您使用的是什么版本的gdb?我在你的应用程序和使用gcc编译时遇到了相同的错误。我有gdb 7.4同样的问题:重新设置断点1时出错:函数“/tmp/space test.c:5”未定义。(gdb 7.4)