This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[debug-early] fix -fdump-go-spec


Hi guys!

Despite what Go thinks:

  /* The debug hooks are used to implement -fdump-go-spec because it
     gives a simple and stable API for all the information we need to
     dump.  */

...the debug hooks are not stable... :).

The godump-1.c test is failing in the debug-early branch. It seems that Go is hijacking the debug_hook machinery to access globals generated by the front-ends. In debug-early, things have moved around.

With this patch I have done my best to give Go what it wants without recreating what the front-ends were doing. I've made the go_decl() call work from within the early_global_decl() hook which gets called as we parse (rest_of_decl_compilation). I far as I understand, this hack is a one-time thing for use internally in the build process, so we don't care whether go_decl() will receive location information??

I have also relaxed the condition in rest_of_decl_compilation to allow function prototypes. Go was expecting to be fed function prototypes as part of the global_decl machinery. However, it won't ever see these, as the early_global_decl code iterating through functions uses the symbol table, which does not have prototypes:

  /* Emit early debug for reachable functions, and by consequence,
     locally scoped symbols.  */
  struct cgraph_node *cnode;
  FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode)
    if (!decl_function_context (cnode->decl))
      (*debug_hooks->early_global_decl) (cnode->decl);

(By the way, even iterating through symbols, without regards to gimple body, we end up with nothing...and even before we analyze_functions() and prune unreachable nodes.).

Relaxing the condition does the trick, and the dwarf early_global_decl debug hook just works because it avoids functions with no body anyhow.

In a world with Go and non dwarf (stabs, etc) debug hooks, I may have to adjust the calls to debug_hooks->{early,late}_global_decl a bit more to get all debugging backends to get what they want. This may involve feeding more to the debug hooks while making the individual hooks disregard DECLs they don't want/need.

Is there not a more modern way of Go getting the DECLs it needs without abusing the debug_hook machinery?

Anyways... this is what I have so far. It may change, as I have at least one stabs problem that may regarding tweaking things again.

Committed to branch.

Aldy

Attachment: curr
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]