C++ C程序终止

C++ C程序终止,c++,c,linux,C++,C,Linux,我正在尝试用C语言编写一个程序(使用64位Linux和GCC4.1.2) 试图通过gdb调试该问题,但在该行之后 sprintf(cmdbuf, "/bin/ps -eo comm | /bin/grep -c '%'",cmdname); 程序没有越过上面的行,抛出下面的行 Executing new program: /bin/bash Error in re-setting breakpoint 1: No symbol table is loaded. Use the "file

我正在尝试用C语言编写一个程序(使用64位Linux和GCC4.1.2)

试图通过gdb调试该问题,但在该行之后

sprintf(cmdbuf, "/bin/ps -eo comm | /bin/grep -c '%'",cmdname);  
程序没有越过上面的行,抛出下面的行

Executing new program: /bin/bash Error in re-setting breakpoint 1: No symbol table is loaded. Use the "file" command. [New process 2437] Executing new program: /bin/ps 正在执行新程序:/bin/bash 重新设置断点1时出错:未加载符号表。使用“文件”命令。 [新流程2437] 正在执行新程序:/bin/ps
请帮助我们解决此问题。

尝试使用-g编译代码并删除-O[编译器标志]。优化编译器(gcc)时,更改指令顺序以提高速度。重新编译后,再次附加调试器

你的名字有多长?您可能正在冲刺cmdbuf的末尾。“请帮助我们解决此问题”-哪个问题?GDB中的挂起或消息?这是C,不是真正的C++,如果你添加TAGROB,你可能会更快地得到答案:程序崩溃了。即Hang@user1774057:崩溃和挂起是两种不同类型的故障。使用错误的术语会让人们很难帮助你。再次,我要说的是我在这种情况下通常会做什么。请使用类似这样的日志,并尝试在调试器外部运行它:printf(“%s:%d\n”、\uuu文件、\uuu行);把这条线放在你们认为问题发生的地方前后 Executing new program: /bin/bash Error in re-setting breakpoint 1: No symbol table is loaded. Use the "file" command. [New process 2437] Executing new program: /bin/ps