你如何使用Linux的调试器

时间:2016-07-04 01:25:24

标签: c debugging

我在使用我的调试器为linux mint 17.2时遇到问题。每次我尝试使用gdb调试器的Linux。这是我用来尝试调试代码的命令的语法(通过代码在C中的方式,如果有帮助的话)

     gcc frec2.c -g frec2

这就是出现的内容

frec2: In function `__x86.get_pc_thunk.bx':
(.text+0x30): multiple definition of `__x86.get_pc_thunk.bx'
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_info): relocation 0 has invalid symbol index 8
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_info): relocation 1 has invalid symbol index 9
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_info): relocation 2 has invalid symbol index 10
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_ranges): relocation 0 has invalid symbol index 4
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_ranges): relocation 1 has invalid symbol index 4
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_ranges): relocation 2 has invalid symbol index 5
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_ranges): relocation 3 has invalid symbol index 5
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_ranges): relocation 4 has invalid symbol index 6
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_ranges): relocation 5 has invalid symbol index 6
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o:(.gnu.linkonce.t.__x86.get_pc_thunk.bx+0x0): first defined here
frec2: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o:(.fini+0x0): first defined here
frec2: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 21 has invalid symbol index 22
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o:(.data+0x0): first defined here
frec2: In function `data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib/gcc/i686-linux-gnu/4.8/crtbegin.o:(.data+0x0): first defined here
frec2:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
frec2: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o:/build/eglibc-X4bnBz/eglibc-2.19/csu/../sysdeps/i386/start.S:115: first defined here
frec2:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o:(.rodata+0x0): first defined here
frec2: In function `main':
(.text+0xfd): multiple definition of `main'
/tmp/cc2ZLuY7.o:/home/linuxmint/Documents/frec2.c:3: first defined here
frec2: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_line): relocation 0 has invalid symbol index 4
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_line): relocation 1 has invalid symbol index 5
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crti.o(.debug_line): relocation 2 has invalid symbol index 6
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o:/build/eglibc-X4bnBz/eglibc-2.19/csu/../sysdeps/i386/crti.S:63: first defined here
/usr/lib/gcc/i686-linux-gnu/4.8/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
frec2:(.data+0x8): first defined here
/usr/bin/ld: error in frec2(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status

我不知道该怎么做任何帮助都会非常感激。

1 个答案:

答案 0 :(得分:4)

对于编译或调试会话,该命令看起来不正确。试试:

gcc -Wall -g frec2.c -o frec
gdb frec