C -GDB报告(带有列表和帧命令)未列出行号



我正在使用GDB来找出我在程序中获得segfault的位置。但是,我的GDB报告未指定行号,它只是名称函数。

root@brute-force-compute:~# gcc -g -pthread program.c -o program -lmysqlclient
root@brute-force-compute:~# gdb program

(gdb) run --journal --day "Tuesday" --job "iOS" --client "SEAS"
Starting program: /root/serapis --journal --day "Tuesday" --job "iOS" --client "SEAS"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
__strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
296 ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: No such file or directory.
(gdb) list
291 in ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S

编辑:使用-g flag

编译
gcc program.c -o program -g -lmysqlclient -l pthread
gdb program
(gdb) run --journal --day "Tuesday" --job "iOS" --client "SEAS"
Program received signal SIGSEGV, Segmentation fault.
__strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
296 ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: No such file or directory.
(gdb) list
291 in ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
(gdb) frame
#0  __strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
296 in ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S

首次尝试:

gcc program.c -o program -lmysqlclient -l pthread
gdb program 
(gdb) run --journal --day "Tuesday" --job "iOS" --client "SEAS"
Starting program: root/program --day "Tuesday" --job "iOS" --client "SEAS"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
__strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
296 ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: No such file or directory.
(gdb) where
#0  __strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
#1  0x0000000000402c69 in init_journal ()
#2  0x00000000004086d4 in main ()
(gdb)list
291 in ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
(gdb) frame
#0  __strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
296 in ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
(gdb) backtrace
#0  __strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:296
#1  0x0000000000402c69 in init_journal ()
#2  0x00000000004086d4 in main ()

main中,我愿意:

if(strcmp(argv[1], "--journal") == 0){
        printf("nInitializing single integral machine..nn");
        char * template = argv[2];
        init_journal(day, job, client);
    }

main中较早设置了一天,工作,客户,例如:

   if(strcmp(argv[i], "--day") == 0){
        day = argv[++i];
   }

我看了不同的帖子,我在这里看到我应该更改我在GDB中的命令行参数的方式:

run $(--journal --day "Tuesday" --job "iOS" --client "SEAS")

然后我得到报告:

Program received signal SIGSEGV, Segmentation fault.
__strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:31
31  ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S: No such file or directory.
(gdb) list
26  in ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S
(gdb) frame
#0  __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:31
31  in ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S

gcc program.c -o程序-lmysqlclient -l pthread

此命令构建您的程序调试信息。在其他方面也是不正确的。

您想要:

gcc -g -pthread program.c -o program -lmysqlclient

我看了不同的帖子,我在这里看到我应该更改我在GDB中的命令行参数的方式:

run $(--journal --day "Tuesday" --job "iOS" --client "SEAS")

完全伪造命令行。您应该不是做。

相关内容

  • 没有找到相关文章

最新更新