[PATCH] GDB: fix python config command line arguments based on python version

Karel Gardas karel at functional.vision
Wed Apr 20 18:38:02 UTC 2022


Chris, Frank,

I don't feel particularly comfortable with this patch. It works here on 
Ubuntu 20.04 with python 3.3 and Ubuntu 22.04 with Python 3.10, but I 
have to admit semantics of this cfg language is beyond my liking and a 
lot is in complete darkness here. E.g. how &&, < operator are working 
here. Delete both int conversions and it'll not work at all. Keep one 
and it'll work well.
The problem is probably lack of time to go thorough all the docs on 
docs.rtems.org to find relevant bits while working on the patch.

Anyway, if you have time, please review and test on your platforms.

Thanks,
Karel

On 4/20/22 20:30, Karel Gardas wrote:
> Fixes #4631
> ---
>   source-builder/config/gdb-common-1.cfg | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/source-builder/config/gdb-common-1.cfg b/source-builder/config/gdb-common-1.cfg
> index c7f39552..dba6f212 100644
> --- a/source-builder/config/gdb-common-1.cfg
> +++ b/source-builder/config/gdb-common-1.cfg
> @@ -109,7 +109,13 @@
>     %endif
>     %if %{gdb-python-config} != %{nil}
>       %define gdb-python-lib-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"*";}'
> -    %if %{gdb-python-ver-mm} < 3.8
> +    %define gdb-python-ver-mm-major %(echo "%{gdb-python-ver-mm}" | sed -e 's/\..*//')
> +    %define gdb-python-ver-mm-minor %(echo "%{gdb-python-ver-mm}" | sed -e 's/.*\.//')
> +    # following comparion works correctly even for python 2 as it ends with version 2.7.x
> +    # so we do not get possibly problematic 2.8 and others here.
> +    # Note: int(...) usage is necessary in order to enforce numerical comparison instead of lexicographical
> +    # if we do not use that then 10 < 8 would be true
> +    %if int(%{gdb-python-ver-mm-major}) <= 3 && int(%{gdb-python-ver-mm-major}) < 8
>           %define gdb-python-config-lib-check-flags --ldflags
>       %else
>           %define gdb-python-config-lib-check-flags --ldflags --embed




More information about the devel mailing list