Re: Passing an string argument to a GIMPLE call
On June 27, 2020 6:21:12 AM GMT+02:00, Shuai Wang via Gcc 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
Re: Passing an string argument to a GIMPLE call
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 wrote: > On June 27, 2020 6:21:12 AM GMT+02:00, Shuai Wang via Gcc > 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 > >
Re: Passing an string argument to a GIMPLE call
On Sat, 2020-06-27 at 21:27 +0800, Shuai Wang via Gcc wrote: > 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. fun->function_start_locus and fun->function_end_locus are the location_t for the start and end of the function; also, each gimple stmt has a location_t (although this isn't always set for every stmt). Given a location_t, you can use LOCATION_FILE (loc) to get the source file (and various other macros and accessors, see input.h) Hope this is helpful Dave > 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
gcc-10-20200627 is now available
Snapshot gcc-10-20200627 is now available on https://gcc.gnu.org/pub/gcc/snapshots/10-20200627/ and on various mirrors, see http://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 10 git branch with the following options: git://gcc.gnu.org/git/gcc.git branch releases/gcc-10 revision d12079381e25571f2d5f7bb16eaef07ee89b361b You'll find: gcc-10-20200627.tar.xz Complete GCC SHA256=5ec79868c3ec0e7a761138031466932ec2fa31309f2f3a87b5ec036e908750b0 SHA1=36d6779e19071baa67d0eae7633bc9fb19e72822 Diffs from 10-20200620 are available in the diffs/ subdirectory. When a particular snapshot is ready for public consumption the LATEST-10 link is updated and a message is sent to the gcc list. Please do not use a snapshot before it has been announced that way.