GCC Compiler, Plugins and structures

107 Views Asked by At

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?
1

There are 1 best solutions below

0
Markus On

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