Skip to content

Fresh MSYS2 gdb cannot set a breakpoint in Rust executables #79112

Closed
@petrochenkov

Description

@petrochenkov

Reproduction:

// main.c

#include <stdio.h>

int main() {
    printf("Hello world!\n");
}
// main.rs

fn main() {
    println!("Hello world!");
}
# script.gdb

break main
run
quit
# reproduce.sh

set -x

gcc --version
rustc --version
/mingw64/bin/gdb --version
/usr/bin/gdb --version

gcc -g main.c -o mainc
rustc -g main.rs -o mainrs

/mingw64/bin/gdb -q -x script.gdb ./mainc
/mingw64/bin/gdb -q -x script.gdb ./mainrs
/usr/bin/gdb -q -x script.gdb ./mainc
/usr/bin/gdb -q -x script.gdb ./mainrs

Output on my machine:

++ gcc --version
gcc.exe (Rev5, Built by MSYS2 project) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

++ rustc --version
rustc 1.50.0-nightly (74f7e32f4 2020-11-13)
++ /mingw64/bin/gdb --version
GNU gdb (GDB) 9.2
Copyright (C) 2020 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.
++ /usr/bin/gdb --version
GNU gdb (GDB) 9.2
Copyright (C) 2020 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.
++ gcc -g main.c -o mainc
++ rustc -g main.rs -o mainrs
++ /mingw64/bin/gdb -q -x script.gdb ./mainc
Reading symbols from ./mainc...
Breakpoint 1 at 0x4015a1: file main.c, line 6.

Breakpoint 1, main () at main.c:6
6           printf("Hello world!\n");
++ /mingw64/bin/gdb -q -x script.gdb ./mainrs
Reading symbols from ./mainrs...
Breakpoint 1 at 0x4015a7: main. (2 locations)

Breakpoint 1, 0x00000000013515fa in main ()
++ /usr/bin/gdb -q -x script.gdb ./mainc
Traceback (most recent call last):
  File "<string>", line 3, in <module>
ModuleNotFoundError: No module named 'libstdcxx'
/etc/gdbinit:6: Error in sourced command file:
Error while executing Python code.
Reading symbols from ./mainc...
Breakpoint 1 at 0x4015a1: file main.c, line 6.

Breakpoint 1, main () at main.c:6
6           printf("Hello world!\n");
++ /usr/bin/gdb -q -x script.gdb ./mainrs
Traceback (most recent call last):
  File "<string>", line 3, in <module>
ModuleNotFoundError: No module named 'libstdcxx'
/etc/gdbinit:6: Error in sourced command file:
Error while executing Python code.
Reading symbols from ./mainrs...
Breakpoint 1 at 0x4015a7: main. (2 locations)
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x4015a7
Cannot insert breakpoint 1.
Cannot access memory at address 0x4015f0

script.gdb:4: Error in sourced command file:
Command aborted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.O-windows-gnuToolchain: GNU, Operating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions