[PATCH 00/26 v3] Make GDB builtin target descriptions more flexible

Yao Qi qiyaoltc@gmail.com
Mon Jul 10 13:56:00 GMT 2017


This patch series is to change GDB and GDBserver builtin target
descriptions more flexible, by removing pre-generated ones.  Nowadays,
GDB builtin target descriptions are created from initialize_tdesc_*
functions in features/*.c files, while GDBserver builtin target
descriptions are generated from regformats/*.dat files.  Instead,
with these patches applied, these builtin target descriptions can be
got lazily and dynamically.

This patch series changes both GDB and GDBserver to create target
description dynamically from features, instead of using pre-generated
target descriptions.  This patch series only convert x86-linux
(including i386-linux, amd64-linux and x32-linux) target description
to demonstrate the usefulness of the change.

Once one target architecture switches to the new flexible target
description,

 - We only need xml feature files under gdb/features directory.  All
 existing target description xml files can be kept for tests.  Add
 new xml feature file if we want to support the new feature, but
 don't need to add new target description xml files.

 - All existing gdb/regformats/*.dat are not used, but kept for
 the tests.

This is the v3, v2 can be found here
https://sourceware.org/ml/gdb-patches/2017-06/msg00293.html
The v3 address the comments to v2 (I hope), and share the target
description creation code between GDB and GDBserver.  Regression
tested on x86_64-linux (-m64 and -m32), both native and gdbserver.

I pushed my branch to users/qiyao/target-desc-3.

The size of both GDB and GDBserver is reduced, "dev" means
development=true, while "rel" means it is false.

$ size ./gdb-dev-before ./gdb-dev-after 
   text	   data	    bss	    dec	    hex	filename
7766157	 143712	 181344	8091213	 7b764d	./gdb-dev-before
7727869	 143712	 182016	8053597	 7ae35d	./gdb-dev-after

$ size ./gdbserver-dev-before ./gdbserver-dev-after 
   text	   data	    bss	    dec	    hex	filename
1164512	  47744	  40560	1252816	 131dd0	./gdbserver-dev-before
1223188	  27856	  41360	1292404	 13b874	./gdbserver-dev-after
$ ls -l ./gdbserver-dev-before ./gdbserver-dev-after 
-rwxr-xr-x 1 yao.qi primary 4310160 Jul 10 11:49 ./gdbserver-dev-after
-rwxr-xr-x 1 yao.qi primary 3966968 Jul 10 11:31 ./gdbserver-dev-before

$ size ./gdbserver-rel-before ./gdbserver-rel-after 
   text	   data	    bss	    dec	    hex	filename
1164336	  47736	  40560	1252632	 131d18	./gdbserver-rel-before
1171548	  27336	  39824	1238708	 12e6b4	./gdbserver-rel-after
$ ls -l ./gdbserver-rel-before ./gdbserver-rel-after
-rwxr-xr-x 1 yao.qi primary 3923776 Jul 10 11:43 ./gdbserver-rel-after
-rwxr-xr-x 1 yao.qi primary 3966744 Jul 10 11:37 ./gdbserver-rel-before

*** BLURB HERE ***

Yao Qi (26):
  Improve doc about "maint print c-tdesc"
  Class-fy target_desc
  Add optional argument to command "maint prints c-tdesc"
  Centralize i386 linux target descriptions
  Use visitor pattern for "maint print c-tdesc"
  Generate c for feature instead of tdesc
  Lazily and dynamically create i386-linux target descriptions
  Add "maint check xml-descriptions" to test builtin xml target
    descriptions
  Adjust code generated by regformats/regdat.sh
  Use VEC for target_desc.reg_defs
  Return X86_TDESC_MMX in x86_get_ipa_tdesc_idx
  [GDBserver] Centralize tdesc for i386-linux
  GDBserver self test
  [GDBserver] unit test to i386_tdesc
  Dynamically composite xml in reply to GDB
  Share i386-linux target description between GDB and GDBserver
  Remove features/i386/i386-*linux.c
  [GDBserver] Use pre-generated tdesc as test
  [GDBserver] Shorten srv_i386_linux_xmlfiles
  Update comments in amd64_linux_core_read_description
  Centralize amd64-linux target descriptions
  Lazily and dynamically create amd64-linux target descriptions
  Convert amd64-linux target descriptions
  [GDBserver] Use pre-generated amd64-linux tdesc as test
  [GDBserver] shorten srv_amd64_linux_xmlfiles
  Remove features/i386/amd64-*linux.c and features/i386/x32-*linux.c

 gdb/Makefile.in                                    |    6 +-
 gdb/NEWS                                           |   22 +-
 gdb/amd64-linux-tdep.c                             |  121 +--
 gdb/amd64-linux-tdep.h                             |    6 +
 gdb/arch/amd64.c                                   |   71 ++
 gdb/arch/amd64.h                                   |   21 +
 gdb/arch/i386.c                                    |   66 ++
 gdb/arch/i386.h                                    |   21 +
 gdb/arch/tdesc.h                                   |   92 ++
 gdb/cli/cli-cmds.c                                 |    4 +
 gdb/{ => common}/selftest.c                        |   17 +-
 gdb/{ => common}/selftest.h                        |    0
 gdb/configure.tgt                                  |    7 +-
 gdb/doc/gdb.texinfo                                |   27 +-
 gdb/features/Makefile                              |   63 +-
 gdb/features/aarch64.c                             |    8 +-
 gdb/features/arc-arcompact.c                       |    8 +-
 gdb/features/arc-v2.c                              |    8 +-
 gdb/features/arm/arm-with-iwmmxt.c                 |    8 +-
 gdb/features/arm/arm-with-m-fpa-layout.c           |    4 +-
 gdb/features/arm/arm-with-m-vfp-d16.c              |    4 +-
 gdb/features/arm/arm-with-m.c                      |    4 +-
 gdb/features/arm/arm-with-neon.c                   |    4 +-
 gdb/features/arm/arm-with-vfpv2.c                  |    4 +-
 gdb/features/arm/arm-with-vfpv3.c                  |    4 +-
 gdb/features/i386/32bit-avx.c                      |   21 +
 gdb/features/i386/32bit-avx512.c                   |   33 +
 gdb/features/i386/32bit-core.c                     |   66 ++
 gdb/features/i386/32bit-linux.c                    |   15 +
 gdb/features/i386/32bit-mpx.c                      |   51 +
 gdb/features/i386/32bit-pkeys.c                    |   14 +
 gdb/features/i386/32bit-sse.c                      |   75 ++
 gdb/features/i386/64bit-avx.c                      |   29 +
 gdb/features/i386/64bit-avx512.c                   |  124 +++
 gdb/features/i386/64bit-core.c                     |   74 ++
 gdb/features/i386/64bit-linux.c                    |   15 +
 gdb/features/i386/64bit-mpx.c                      |   51 +
 gdb/features/i386/64bit-pkeys.c                    |   14 +
 gdb/features/i386/64bit-segments.c                 |   15 +
 gdb/features/i386/64bit-sse.c                      |   83 ++
 gdb/features/i386/amd64-avx-avx512-linux.c         |  288 ------
 gdb/features/i386/amd64-avx-avx512.c               |    8 +-
 gdb/features/i386/amd64-avx-linux.c                |  177 ----
 gdb/features/i386/amd64-avx-mpx-avx512-pku-linux.c |  329 -------
 gdb/features/i386/amd64-avx-mpx-avx512-pku.c       |    8 +-
 gdb/features/i386/amd64-avx-mpx-linux.c            |  215 -----
 gdb/features/i386/amd64-avx-mpx.c                  |    8 +-
 gdb/features/i386/amd64-avx.c                      |    8 +-
 gdb/features/i386/amd64-linux.c                    |  159 ---
 gdb/features/i386/amd64-mpx-linux.c                |  197 ----
 gdb/features/i386/amd64-mpx.c                      |    8 +-
 gdb/features/i386/amd64.c                          |    8 +-
 gdb/features/i386/i386-avx-avx512-linux.c          |  170 ----
 gdb/features/i386/i386-avx-avx512.c                |    8 +-
 gdb/features/i386/i386-avx-linux.c                 |  149 ---
 gdb/features/i386/i386-avx-mpx-avx512-pku-linux.c  |  211 ----
 gdb/features/i386/i386-avx-mpx-avx512-pku.c        |    8 +-
 gdb/features/i386/i386-avx-mpx-linux.c             |  187 ----
 gdb/features/i386/i386-avx-mpx.c                   |    8 +-
 gdb/features/i386/i386-avx.c                       |    8 +-
 gdb/features/i386/i386-linux.c                     |  139 ---
 gdb/features/i386/i386-mmx-linux.c                 |   78 --
 gdb/features/i386/i386-mmx.c                       |    8 +-
 gdb/features/i386/i386-mpx-linux.c                 |  177 ----
 gdb/features/i386/i386-mpx.c                       |    8 +-
 gdb/features/i386/i386.c                           |    8 +-
 gdb/features/i386/x32-avx-avx512-linux.c           |  288 ------
 gdb/features/i386/x32-avx-avx512.c                 |    8 +-
 gdb/features/i386/x32-avx-linux.c                  |  177 ----
 gdb/features/i386/x32-avx.c                        |    8 +-
 gdb/features/i386/x32-core.c                       |   74 ++
 gdb/features/i386/x32-linux.c                      |  159 ---
 gdb/features/i386/x32.c                            |    8 +-
 gdb/features/mips-dsp-linux.c                      |    4 +-
 gdb/features/mips-linux.c                          |    4 +-
 gdb/features/mips64-dsp-linux.c                    |    4 +-
 gdb/features/mips64-linux.c                        |    4 +-
 gdb/features/nds32.c                               |    4 +-
 gdb/features/nios2-linux.c                         |    4 +-
 gdb/features/nios2.c                               |    4 +-
 gdb/features/rs6000/powerpc-32.c                   |    4 +-
 gdb/features/rs6000/powerpc-32l.c                  |    4 +-
 gdb/features/rs6000/powerpc-64.c                   |    4 +-
 gdb/features/rs6000/powerpc-64l.c                  |    4 +-
 gdb/features/rs6000/powerpc-7400.c                 |    4 +-
 gdb/features/rs6000/powerpc-altivec32.c            |    8 +-
 gdb/features/rs6000/powerpc-altivec32l.c           |    8 +-
 gdb/features/rs6000/powerpc-altivec64.c            |    8 +-
 gdb/features/rs6000/powerpc-altivec64l.c           |    8 +-
 gdb/features/rs6000/powerpc-cell32l.c              |    8 +-
 gdb/features/rs6000/powerpc-cell64l.c              |    8 +-
 gdb/features/rs6000/powerpc-e500.c                 |    4 +-
 gdb/features/rs6000/powerpc-e500l.c                |    4 +-
 gdb/features/rs6000/powerpc-isa205-32l.c           |    4 +-
 gdb/features/rs6000/powerpc-isa205-64l.c           |    4 +-
 gdb/features/rs6000/powerpc-isa205-altivec32l.c    |    8 +-
 gdb/features/rs6000/powerpc-isa205-altivec64l.c    |    8 +-
 gdb/features/rs6000/powerpc-isa205-vsx32l.c        |    8 +-
 gdb/features/rs6000/powerpc-isa205-vsx64l.c        |    8 +-
 gdb/features/rs6000/powerpc-vsx32.c                |    8 +-
 gdb/features/rs6000/powerpc-vsx32l.c               |    8 +-
 gdb/features/rs6000/powerpc-vsx64.c                |    8 +-
 gdb/features/rs6000/powerpc-vsx64l.c               |    8 +-
 gdb/features/rs6000/rs6000.c                       |    4 +-
 gdb/features/s390-linux32.c                        |    4 +-
 gdb/features/s390-linux32v1.c                      |    4 +-
 gdb/features/s390-linux32v2.c                      |    4 +-
 gdb/features/s390-linux64.c                        |    4 +-
 gdb/features/s390-linux64v1.c                      |    4 +-
 gdb/features/s390-linux64v2.c                      |    4 +-
 gdb/features/s390-te-linux64.c                     |    4 +-
 gdb/features/s390-tevx-linux64.c                   |    8 +-
 gdb/features/s390-vx-linux64.c                     |    8 +-
 gdb/features/s390x-linux64.c                       |    4 +-
 gdb/features/s390x-linux64v1.c                     |    4 +-
 gdb/features/s390x-linux64v2.c                     |    4 +-
 gdb/features/s390x-te-linux64.c                    |    4 +-
 gdb/features/s390x-tevx-linux64.c                  |    8 +-
 gdb/features/s390x-vx-linux64.c                    |    8 +-
 gdb/features/tic6x-c62x-linux.c                    |    4 +-
 gdb/features/tic6x-c62x.c                          |    4 +-
 gdb/features/tic6x-c64x-linux.c                    |    4 +-
 gdb/features/tic6x-c64x.c                          |    4 +-
 gdb/features/tic6x-c64xp-linux.c                   |    4 +-
 gdb/features/tic6x-c64xp.c                         |    4 +-
 gdb/gdbcmd.h                                       |    4 +
 gdb/gdbserver/Makefile.in                          |   14 +
 gdb/gdbserver/config.in                            |    3 +
 gdb/gdbserver/configure                            |    6 +
 gdb/gdbserver/configure.ac                         |    5 +
 gdb/gdbserver/configure.srv                        |   32 +-
 gdb/gdbserver/linux-amd64-ipa.c                    |   55 +-
 gdb/gdbserver/linux-i386-ipa.c                     |   39 +-
 gdb/gdbserver/linux-x86-low.c                      |  146 +--
 gdb/gdbserver/linux-x86-tdesc-selftest.c           |  183 ++++
 gdb/gdbserver/linux-x86-tdesc.c                    |  173 ++++
 gdb/gdbserver/linux-x86-tdesc.h                    |   78 +-
 gdb/gdbserver/regcache.c                           |   34 +-
 gdb/gdbserver/server.c                             |   28 +-
 gdb/gdbserver/tdesc.c                              |  186 +++-
 gdb/gdbserver/tdesc.h                              |  106 +-
 gdb/i386-linux-tdep.c                              |   94 +-
 gdb/i386-linux-tdep.h                              |   10 +-
 gdb/maint.c                                        |   18 +
 gdb/regformats/regdat.sh                           |   26 +-
 gdb/regformats/regdef.h                            |   12 +
 gdb/target-descriptions.c                          | 1013 ++++++++++++++------
 gdb/target-descriptions.h                          |   49 +-
 gdb/testsuite/gdb.gdb/unittest.exp                 |    5 +
 gdb/testsuite/gdb.server/unittest.exp              |   41 +
 gdb/x86-linux-nat.c                                |   59 +-
 151 files changed, 3114 insertions(+), 4167 deletions(-)
 create mode 100644 gdb/arch/amd64.c
 create mode 100644 gdb/arch/amd64.h
 create mode 100644 gdb/arch/i386.c
 create mode 100644 gdb/arch/i386.h
 create mode 100644 gdb/arch/tdesc.h
 rename gdb/{ => common}/selftest.c (82%)
 rename gdb/{ => common}/selftest.h (100%)
 create mode 100644 gdb/features/i386/32bit-avx.c
 create mode 100644 gdb/features/i386/32bit-avx512.c
 create mode 100644 gdb/features/i386/32bit-core.c
 create mode 100644 gdb/features/i386/32bit-linux.c
 create mode 100644 gdb/features/i386/32bit-mpx.c
 create mode 100644 gdb/features/i386/32bit-pkeys.c
 create mode 100644 gdb/features/i386/32bit-sse.c
 create mode 100644 gdb/features/i386/64bit-avx.c
 create mode 100644 gdb/features/i386/64bit-avx512.c
 create mode 100644 gdb/features/i386/64bit-core.c
 create mode 100644 gdb/features/i386/64bit-linux.c
 create mode 100644 gdb/features/i386/64bit-mpx.c
 create mode 100644 gdb/features/i386/64bit-pkeys.c
 create mode 100644 gdb/features/i386/64bit-segments.c
 create mode 100644 gdb/features/i386/64bit-sse.c
 delete mode 100644 gdb/features/i386/amd64-avx-avx512-linux.c
 delete mode 100644 gdb/features/i386/amd64-avx-linux.c
 delete mode 100644 gdb/features/i386/amd64-avx-mpx-avx512-pku-linux.c
 delete mode 100644 gdb/features/i386/amd64-avx-mpx-linux.c
 delete mode 100644 gdb/features/i386/amd64-linux.c
 delete mode 100644 gdb/features/i386/amd64-mpx-linux.c
 delete mode 100644 gdb/features/i386/i386-avx-avx512-linux.c
 delete mode 100644 gdb/features/i386/i386-avx-linux.c
 delete mode 100644 gdb/features/i386/i386-avx-mpx-avx512-pku-linux.c
 delete mode 100644 gdb/features/i386/i386-avx-mpx-linux.c
 delete mode 100644 gdb/features/i386/i386-linux.c
 delete mode 100644 gdb/features/i386/i386-mmx-linux.c
 delete mode 100644 gdb/features/i386/i386-mpx-linux.c
 delete mode 100644 gdb/features/i386/x32-avx-avx512-linux.c
 delete mode 100644 gdb/features/i386/x32-avx-linux.c
 create mode 100644 gdb/features/i386/x32-core.c
 delete mode 100644 gdb/features/i386/x32-linux.c
 create mode 100644 gdb/gdbserver/linux-x86-tdesc-selftest.c
 create mode 100644 gdb/gdbserver/linux-x86-tdesc.c
 create mode 100644 gdb/testsuite/gdb.server/unittest.exp

-- 
1.9.1



More information about the Gdb-patches mailing list