1

I am a novice developer in Linux/C. Recently, I am developing a file system using libfuse in WSL2 Ubuntu 20.04.6 in C language, and I need to debug the code of libfuse to see the exact calling procedure. But when I try to load the .so file in GDB, it shows message 'You can't do that when your target is `exec''.

Here is the GDB message.

(gdb)  dir /lib/x86_64-linux-gnu
Source directories searched: /lib/x86_64-linux-gnu:$cdir:$cwd
(gdb) load libfuse.so.2
You can't do that when your target is `exec'

And I used pkg-config fuse --cflags --libs in Makefile to link the library during compiling .

I need to run the program in the debug mode. And I don't know how to step into the code of libfuse, but the GDB shows the follow information.

(gdb) n
Single stepping until exit from function fuse_fs_write_buf,
which has no line number information.
0x00007ffff755558b in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
(gdb) n
Cannot find bounds of current function

How can I deal with it?

Yuki Lau
  • 11
  • 2
  • 2
    You don't need to use any special command to load it, it will be loaded automatically when the program starts. But you want it to be compiled in a debug mode, otherwise debugging it will be pretty tough. – n. m. could be an AI May 06 '23 at 14:02
  • @n. m. Yes, I need to run the program in a debug mode, and I need to step into some functions of fuse, but I failed. – Yuki Lau May 06 '23 at 14:38
  • 1
    "I need to run the program in a debug mode" you need to *build your shared library* in debug mode. The one you install with `apt` isn't built like that, so you want to download the source code and build it. – n. m. could be an AI May 06 '23 at 14:48
  • Good first question. Thanks for learning how to do the formatting by yourself! I agree that you need to locally (re)compile your library with debugging enabled. Shouldn't be hard to find out how to do that. Good luck with your debugging. – shellter May 06 '23 at 16:11

1 Answers1

1

You need install debug information for libfuse sudo apt install libfuse-dev.

If you can't install, then build it from sources with debug info.

uis
  • 126
  • 1
  • 9