Debug with GDB does not work in Linux

I compiled the “Hello World” application in the Linux command line:

zig build-exe hello.zig

Tried to debug with GDB, but does not work.
This is the output:

^M-?ELF^B^A^A

According to the documentation the default output contains debug information.
I tested GDB with a C program, it works just fine. I am using WLS under Win11.

I haven’t tried gdb, however lldb seemed to work for me, maybe you can try that instead?

Thanks for the advise, it works OK.

hmmm… I use gdb all the time, works all right.

The output when using which command? On my Ubuntu box, gdb works.

% zig build-exe hello.zig 

% ./hello 
Hello, world!

% gdb hello
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
...
Reading symbols from hello...
(gdb) run
Starting program: /home/stephane/src/Zig/essais/hello 
Hello, world!
[Inferior 1 (process 137401) exited normally]
(gdb) quit
1 Like