GNU调试器__text_start()位于错误的文件路径

时间:2018-11-25 13:10:47

标签: linux gcc gdb windows-subsystem-for-linux sparc

首先要介绍一点:我正在使用Linux的Windows子系统和GCC的Gaisler BCC版本进行交叉编译(又名“ machine-gcc”,其中machinesparc-gaisler-elf在这种情况下)。

我编译了一个简单的hello world程序来进行调试

$ sparc-gaisler-elf-gcc -g hello.c -o hello

然后,我使用GNU调试器(GDB)作为服务器打开特定处理器的模拟器

$ tsim-leon3 -gdb
...
gdb interface: using port 1234
Starting GDB server. Use Ctrl-C to stop waiting for connection.

在另一个bash会话中,我启动一个远程GDB并连接到服务器

$ sparc-gaisler-elf-gdb -ex "target extended-remote localhost:1234"
...
Remote debugging using localhost:1234

这很好。但是,如果我尝试加载hello可执行文件,则会遇到问题

$ sparc-gaisler-elf-gdb -ex "target extended-remote localhost:1234" hello
...
Remote debugging using localhost:1234

__text_start () at /opt/bcc-2.0.4-gcc/src/libbcc/shared/trap/trap_table_mvt.S:167
167  /opt/bcc-2.0.4-gcc/src/libbcc/shared/trap/trap_table_mvt.S: No such file or directory.
     in /opt/bcc-2.0.4-gcc/src/libbcc/shared/trap/trap_table_mvt.S
Current language:  auto; currently asm

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /mnt/c/Users/<username>/bcc-2.0.4-gcc/src/examples/hello/hello

Program received signal SIGSEGV, Segmentation fault.
__text_start () at /opt/bcc-2.0.4-gcc/src/libbcc/shared/trap/trap_table_mvt.S:167
167     in /opt/bcc-2.0.4-gcc/src/libbcc/shared/trap/trap_table_mvt.S

现在,通过用于Linux的Windows子系统设置,我可以找到要查找的特定文件

/mnt/c/Users/<username>/bcc-2.0.4-gcc/src/libbcc/shared/trap/trap_table_mvt.S

代替/opt/bcc-2.0.4-gcc/...

如何告诉它在哪里可以找到该文件?


更新

我尝试根据Employed Russian的答案设置dir

(gdb) dir /mnt/c/Users/<user>/bcc-2.0.4-gcc/src/libbcc/shared/trap
Source directories searched: /mnt/c/Users/<user>/bcc-2.0.4-gcc/src/libbcc/shared/trap:$cdir:$cwd

(gdb) list
162             BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 78 - 7B undefined
163             BAD_TRAP; BAD_TRAP; BAD_TRAP; BAD_TRAP; ! 7C - 7F undefined
164
165             /* trap_instruction 0x80 - 0xFF */
166             /* NOTE: "ta 5" can be generated by compiler. */
167             SOFT_TRAP;                                    !  0 System calls
168             SOFT_TRAP;                                    !  1 Breakpoints
169             SOFT_TRAP;                                    !  2 Division by zero
170             FLW_TRAP;                                     !  3 Flush windows
171             SOFT_TRAP;                                    !  4 Clean windows

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /mnt/c/Users/<user>/bcc-2.0.4-gcc/src/examples/hello/hello

Program received signal SIGSEGV, Segmentation fault.
__text_start () at /opt/bcc-2.0.4-gcc/src/libbcc/shared/trap/trap_table_mvt.S:167
167             SOFT_TRAP;                                    !  0 System calls

即使仍在说/opt/...,它似乎现在也找到了正确的文件。但是,我不知道为什么会出现细分错误。

1 个答案:

答案 0 :(得分:0)

  

如何告诉它在哪里可以找到该文件?

使用directory命令。

(gdb) dir /mnt/c/Users/<username>/bcc-2.0.4-gcc/src/libbcc/shared/trap
(gdb) list  # should find the file in the new location

另请参阅source pathset substitite-path