简体   繁体   中英

GNU debugger __text_start () at wrong filepath

First a little preface: I'm using the Windows Subsystem for Linux and the Gaisler BCC version of GCC for cross-compiling (aka " machine-gcc " where the machine is sparc-gaisler-elf in this case).

I compile a simple hello world program for debugging like this

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

Then I open the simulator for the particular processor with the GNU debugger (GDB) as a server

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

In another bash session I start a remote GDB and connect to the server

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

This works fine. But if I try to load the hello executable I get a problem

$ 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

Now, with my Windows Subsystem for Linux setup I have the particular file it's looking for at

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

instead of in /opt/bcc-2.0.4-gcc/...

How can I tell it where to find this file?


Update

I tried setting dir as per Employed Russian's answer

(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

Even though it's still saying /opt/... it seems to have found the right file now. However, I don't know why it's giving a segmentation fault.

How can I tell it where to find this file?

With the directory command.

(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

See also source path and set substitite-path .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM