Skip to content

gdb doesn't understand function pointers #14361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jdm opened this issue May 22, 2014 · 2 comments
Closed

gdb doesn't understand function pointers #14361

jdm opened this issue May 22, 2014 · 2 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@jdm
Copy link
Contributor

jdm commented May 22, 2014

struct Foo {
    dtor: extern "C" fn(),
}

extern "C" fn dtor() {
}

fn main() {
    let foo = Foo { dtor: dtor };
    let foo2 = Some(dtor);
    let foo3 = dtor;
    println!("{:?}", foo);
}
[jdm@rosencrantz tmp]$ gdb dtor
(gdb) break dtor.rs:12
Breakpoint 1 at 0x405068: dtor.rs:12. (2 locations)
(gdb) r
Starting program: /tmp/dtor 
Breakpoint 1, dtor::main () at dtor.rs:12
12      println!("{:?}", foo);
(gdb) p foo
$1 = {
  dtor = <error reading variable>
(gdb) p foo2
$2 = {
  <error reading variable>
(gdb) p foo3
$3 = {void ()} 0x7fffffffdca8
(gdb) 

cc @michaelwoerister

@michaelwoerister
Copy link
Member

Thanks for the filing the issue, Josh!

@steveklabnik
Copy link
Member

rust-gdb now prints

(gdb) p foo
$1 = Foo = {dtor = {void (void)} 0x7fffffffe088}
(gdb) p foo2
$2 = Some = {{void (void)} 0x7fffffffe080}
(gdb) pfoo3
Undefined command: "pfoo3".  Try "help".
(gdb) p foo3
$3 = {void (void)} 0x7fffffffe078
(gdb) p foo2
$2 = Some = {{void (void)} 0x7fffffffe080}
(gdb) p foo3
$3 = {void (void)} 0x7fffffffe078

So seems good!

bors added a commit to rust-lang-ci/rust that referenced this issue Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)
Projects
None yet
Development

No branches or pull requests

3 participants