[PATCH 2/2] Testsuite: Add gdb_simple_compile

Alan Hayward Alan.Hayward@arm.com
Sun Sep 9 17:13:00 GMT 2018



> On 6 Sep 2018, at 16:10, Tom Tromey <tom@tromey.com> wrote:
> 
>>>>>> "Alan" == Alan Hayward <alan.hayward@arm.com> writes:
> 
> Alan> Simplfy gdb.exp by adding a function that will attempt to
> Alan> compile a piece of code, then clean up, leaving the created
> Alan> object.
> 
> Thanks for doing this.
> 
> Alan> +    global obj
> Alan> +    set src { int foo () {return 0;} }
> Alan> +    if {![gdb_simple_compile elf_target $src]} {
> Alan> +        return 0
> Alan>      }
> 
> It would be better not to use a global for this.
> 
> One possibility is to have the caller pass in the variable name and then
> to have the callee use upvar.  Or, some other parts of gdb.exp just pick
> a variable name to inject into the caller using upvar.  The first is
> maybe a little nicer.

I’ll look into using upvar.

> 
> Alan>      # Make sure we have a compiler that understands altivec.
> Alan> -    set compile_flags {debug nowarnings}
> 
> I hadn't noticed this in the first patch but I see now that
> gdb_can_simple_compile / gdb_simple_compile set the default compiler flags.
> 
> Maybe it would be better to have this just be a default and let callers
> override it?

My reasoning was that you would always want both debug and nowarnings.
Didn’t see anywhere that didn’t use them. So I always append those two to
the passed in flags. Happy to move them to the default param.


Alan.



More information about the Gdb-patches mailing list