Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't step into printf() function GDB. WSL2 Ubuntu 24.04

Tags:

c

ubuntu

gdb

wsl2

I'm currently running wsl2 ubuntu 24.04. I want to view the definition of the printf() function in GDB ( gdb ./main). But when I type the step command into printf(). It show this: enter image description here

GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./main...
(gdb) start
Temporary breakpoint 1 at 0x1151: file main.c, line 5.
Starting program: /home/mak/C/main

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.ubuntu.com>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, main () at main.c:5
5               printf("Hello World!\n");
(gdb) step
Download failed: Invalid argument.  Continuing without source file ./libio/./libio/ioputs.c.
0x00007ffff7e2dbf8 in __GI__IO_puts (str=0x555555556004 "Hello World!") at ./libio/ioputs.c:35
warning: 35     ./libio/ioputs.c: No such file or directory
(gdb)

I wasn't really sure what was happening. It worked on my fedora41 when I was dualbooting window11/fedora.

This is my main.c file

#include <stdio.h>

int main(void) {

    printf("Hello World!\n");
    return 0;
}

Compiled it like this:

gcc -ggdb -O0 main.c -o main

I have also installed:

sudo apt install build-essential

Pasted this is my ~/.bashrc

export DEBUGINFOD_URLS="https://debuginfod.ubuntu.com"

Can someone help me?

I have tried export DEBUGINFOD_URLS="https://debuginfod.ubuntu.com" Even reinstall my wsl2.

like image 368
Mak Sriraksa Avatar asked Dec 05 '25 15:12

Mak Sriraksa


1 Answers

Ubuntu's debuginfod landing page says:

About debuginfod

Currently, the service only provides DWARF information. There are plans for it to also index and serve source-code in the future.

So no source code for now. You will need to locally install the GLIBC source code and point gdb to it. See How can I get glibc/libstdc++ sources and set them up for gdb to find?

like image 116
Mike Kinghan Avatar answered Dec 08 '25 07:12

Mike Kinghan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!