0

I have scenario like this:

int open_ext2 () {}
int close_ext2 () {}
int read_ext2 () {}
int write_ext2 () {}


const struct fs_callbacks FS = {
    open_file: open_ext2,
    close_file: close_ext2,
    read_bytes: read_ext2,
    write_bytes: write_ext2
};

void main(){
    FS.close_file();
}

When I look at the gimple representation (compiled with -fdump-tree-all) I see something like this:

D.1796 = close_ext2;
D.1796 ();

What I do not get is where happens the assignment open_file: open_ext2

My questions

  • How GCC is doing this?
  • In what pass does it happen ?
  • Is there a way to figure out the mapping label -> member function?
artless noise
  • 21,212
  • 6
  • 68
  • 105
Markus
  • 21
  • 1
  • 4
  • It is probably optimized away since it isn't used – Ctx Nov 06 '17 at 15:11
  • The gimple shows me that it was used. – Markus Nov 06 '17 at 15:30
  • Rather than edit the question to add the solution, post it as answer! Answering your own question is not forbidden (there is even an option to answer the question directly at the [Ask a Question](https://stackoverflow.com/questions/ask) page) – Filnor Nov 07 '17 at 13:25
  • I modified the post and posted an answer. – Markus Nov 08 '17 at 08:33

1 Answers1

2

Found the answer

The gcc option -fdump-tree-original-raw dumps the info

With GCC plugin:

  • Use the pass PLUGIN_FINISH_DECL
  • Have a look in GCC source for the function debug_variable in file: gcc/tree-dfa.c
Markus
  • 21
  • 1
  • 4