Dear Richard, Thanks for the info. My bad, I will need to append "\0" at the end of the string. Also, a follow-up question which I just cannot find an answer: typically in the plugin entry point:
virtual unsigned int execute(function *fun) How do I know which C files I am instrumenting? Can I somehow get the name of the C file? I don't find a corresponding pointer in the function struct. Best, Shuai On Sat, Jun 27, 2020 at 9:12 PM Richard Biener <richard.guent...@gmail.com> wrote: > On June 27, 2020 6:21:12 AM GMT+02:00, Shuai Wang via Gcc <gcc@gcc.gnu.org> > wrote: > >Hello, > > > >I am writing the following statement to make a GIMPLE call: > > > > tree function_fn_type = build_function_type_list(void_type_node, > >void_type_node, integer_type_node, NULL_TREE); > > tree sancov_fndecl = build_fn_decl("my_instrumentation_function", > >function_fn_type); > > > > auto gcall = gimple_build_call(sancov_fndecl, 2, > >build_string_literal(3, "foo"), build_int_cst_type(integer_type_node, > >0)); > > > >However, when executing the GIMPLE plugin, while inducing no internal > >crash, the following function call statement is generated: > > > > my_instrumentation_function (*&"foo"[0]*, 0); > > > >The first argument seems really strange. Can I somewhat just put a > >"foo" > >there instead of the current form? Thank you very much. > > It looks correct. You are passing the address of the string literal. > > Richard. > > >Best, > >Shuai > >