Related to the libbacktrace patch I submitted earlier (http://gcc.gnu.org/ml/gcc-patches/2013-01/msg00889.html), this patch ensures that the initialization function, created by the Go frontend to handle package imports and run init functions, has line number information. Previously it did not. That was normally fine, but I ran across a case in which one init function was inlined and another one, called first, was not. The first init function called runtime.Callers to get backtrace information, and tried to get information from a function with a line number table but with no line number for the point of the call. The result was that the program crashed. This patch ensures that we do have line number information at that point, albeit line number information that is not very useful in a backtrace.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian
diff -r 244b695224a4 go/gogo-tree.cc --- a/go/gogo-tree.cc Fri Dec 21 17:05:18 2012 -0800 +++ b/go/gogo-tree.cc Wed Jan 16 17:45:59 2013 -0800 @@ -438,15 +438,15 @@ // The tedious details of building your own function. There doesn't // seem to be a helper function for this. std::string name = this->package_name() + ".init"; - tree fndecl = build_decl(BUILTINS_LOCATION, FUNCTION_DECL, - get_identifier_from_string(name), + tree fndecl = build_decl(this->package_->location().gcc_location(), + FUNCTION_DECL, get_identifier_from_string(name), build_function_type(void_type_node, void_list_node)); const std::string& asm_name(this->get_init_fn_name()); SET_DECL_ASSEMBLER_NAME(fndecl, get_identifier_from_string(asm_name)); - tree resdecl = build_decl(BUILTINS_LOCATION, RESULT_DECL, NULL_TREE, - void_type_node); + tree resdecl = build_decl(this->package_->location().gcc_location(), + RESULT_DECL, NULL_TREE, void_type_node); DECL_ARTIFICIAL(resdecl) = 1; DECL_CONTEXT(resdecl) = fndecl; DECL_RESULT(fndecl) = resdecl; @@ -481,7 +481,8 @@ push_struct_function(fndecl); else push_cfun(DECL_STRUCT_FUNCTION(fndecl)); - cfun->function_end_locus = BUILTINS_LOCATION; + cfun->function_start_locus = this->package_->location().gcc_location(); + cfun->function_end_locus = cfun->function_start_locus; gimplify_function_tree(fndecl); @@ -1118,6 +1119,7 @@ else push_cfun(DECL_STRUCT_FUNCTION(decl)); + cfun->function_start_locus = func->location().gcc_location(); cfun->function_end_locus = func->block()->end_location().gcc_location();