[PATCH 1/3] arc: Add XML target descriptions for Linux targets

Yao Qi qiyaoltc@gmail.com
Thu Oct 12 01:29:00 GMT 2017


On 17-10-11 17:56:31, Anton Kolesov wrote:
> Add XML target descriptions for Linux targets.  Compared to default

Hi,
I am converting existing GDB target descriptions in a more flexible way
to organize them.  I've done the x86 target descriptions, and slowly
converting tic6x and nios2 target descriptions.  Could you please convert
existing arc target descriptions first?  It is definitely helpful to
simplify this patch.  I had a talk about my work in Cauldron.
https://slideslive.com/38902354/a-flexible-gdb-target-description-for-processor-diversity
If you want to convert existing arc target descriptions, I am happy to
share some steps to do that.

> Linux descriptions:
> 
> - Explicitly specify CPU machine.
> - Remove baremetal only ILINK{,1,2} registers.
> - Add LP_START and LP_END registers for hardware loops - required to properly
>   evaluate possible next instruction during software single instruction
>   stepping.
> - Add BTA register which contains branch target address - address of next
>   instruction when processor is in the delay slot.
> - ARC HS description also adds R30, R58 and R59 registers, specific to this
>   architecture.

IMO, it is not a good practise to linux and non-linux target descriptions
have target features of the same name, but same target features have
trivial differences, as you described above.  The common practise we did
is to define each target feature xml file, and use xi:include to "include"
each target feature into target description.  All existing target
descriptions follow this approach.

> 
> gdb/ChangeLog:
> yyyy-mm-dd  Anton Kolesov  <Anton.Kolesov@synopsys.com>
> 
> 	* arc-tdep (arc_tdesc_init): Use tdesc_arc_arcompact_linux and
> 	  tdesc_arc_v2_linux.
> 	  (_initialize_arc_tdep): Invoke initialize_tdesc_arc_v2_linux and
> 	  initialize_tdesc_arc_arcompact_linux.
> 	* features/Makefile: Add targets to generate new files.
> 	* features/arc-arcompact-linux.xml: New file.
> 	* features/arc-v2-linux.xml: Likewise.
> 	* features/arc-arcompact-linux.c: Generate.
> 	* features/arc-v2-linux.c: Likewise.
> 	* regformats/arc-arcompact-linux.dat: Likewise.
> 	* regformats/arc-v2-linux.dat: Likewise.
> ---
>  gdb/arc-tdep.c                         | 17 ++++++-
>  gdb/features/Makefile                  |  5 ++
>  gdb/features/arc-arcompact-linux.c     | 76 ++++++++++++++++++++++++++++
>  gdb/features/arc-arcompact-linux.xml   | 84 +++++++++++++++++++++++++++++++
>  gdb/features/arc-v2-linux.c            | 83 +++++++++++++++++++++++++++++++
>  gdb/features/arc-v2-linux.xml          | 91 ++++++++++++++++++++++++++++++++++
>  gdb/regformats/arc-arcompact-linux.dat | 42 ++++++++++++++++
>  gdb/regformats/arc-v2-linux.dat        | 45 +++++++++++++++++
>  8 files changed, 441 insertions(+), 2 deletions(-)
>  create mode 100644 gdb/features/arc-arcompact-linux.c
>  create mode 100644 gdb/features/arc-arcompact-linux.xml
>  create mode 100644 gdb/features/arc-v2-linux.c
>  create mode 100644 gdb/features/arc-v2-linux.xml
>  create mode 100644 gdb/regformats/arc-arcompact-linux.dat
>  create mode 100644 gdb/regformats/arc-v2-linux.dat
> 
> diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
> index 771d6df..a825917 100644
> --- a/gdb/arc-tdep.c
> +++ b/gdb/arc-tdep.c
> @@ -42,6 +42,8 @@
>  /* Default target descriptions.  */
>  #include "features/arc-v2.c"
>  #include "features/arc-arcompact.c"
> +#include "features/arc-v2-linux.c"
> +#include "features/arc-arcompact-linux.c"
>  
>  /* The frame unwind cache for ARC.  */
>  
> @@ -1799,13 +1801,22 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc,
>      {
>        if (is_arcv2)
>  	{
> -	  tdesc_loc = tdesc_arc_v2;
> +	  /* Usually Linux-specific target description would be provided by
> +	     the gdbserver, but it has to be selected manually when debugging
> +	     core files.  */

You need to implement gdbarch method core_read_description in
arc-linux-tdep.c to return the right linux target description.  It doesn't
make much sense to pull in linux target description into arc-tdep.c.

> +	  if (info.osabi == GDB_OSABI_LINUX)
> +	    tdesc_loc = tdesc_arc_v2_linux;
> +	  else
> +	    tdesc_loc = tdesc_arc_v2;
>  	  if (arc_debug)
>  	    debug_printf ("arc: Using default register set for ARC v2.\n");
>  	}
>        else
>  	{
> -	  tdesc_loc = tdesc_arc_arcompact;
> +	  if (info.osabi == GDB_OSABI_LINUX)
> +	    tdesc_loc = tdesc_arc_arcompact_linux;
> +	  else
> +	    tdesc_loc = tdesc_arc_arcompact;
>  	  if (arc_debug)
>  	    debug_printf ("arc: Using default register set for ARCompact.\n");
>  	}
> @@ -2172,6 +2183,8 @@ _initialize_arc_tdep (void)
>  
>    initialize_tdesc_arc_v2 ();
>    initialize_tdesc_arc_arcompact ();
> +  initialize_tdesc_arc_v2_linux ();
> +  initialize_tdesc_arc_arcompact_linux ();
>  
>    /* Register ARC-specific commands with gdb.  */
>  
> diff --git a/gdb/features/Makefile b/gdb/features/Makefile
> index 8a7f377..8d5e3d3 100644
> --- a/gdb/features/Makefile
> +++ b/gdb/features/Makefile
> @@ -44,6 +44,7 @@
>  #   make GDB=/path/to/gdb XMLTOC="xml files" cfiles
>  
>  WHICH = aarch64 \
> +	arc-v2-linux arc-arcompact-linux \

WHICH is used to generate *.dat file from *.xml file.  *.dat files
are used to generate *.c files for GDBserver.  We don't have arc-linux
GDBserver support in this patch, don't need to include this change.
This change can be included in your GDBserver support patches, if you
have.

>  	arm/arm-with-iwmmxt arm/arm-with-vfpv2 arm/arm-with-vfpv3 \
>  	arm/arm-with-neon \
>  	i386/i386 i386/i386-linux \
> @@ -84,6 +85,8 @@ WHICH = aarch64 \
>  
>  # Record which registers should be sent to GDB by default after stop.
>  aarch64-expedite = x29,sp,pc
> +arc-v2-linux-expedite = sp,pc
> +arc-arcompact-linux-expedite = sp,pc

Again, this is used by GDBserver, don't need this change now.  Also,
gdb/features/Makefile have something magic that you only need to define
a generic one,

arc-expedite = sp,pc.

-- 
Yao (齐尧)



More information about the Gdb-patches mailing list