This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Read arm core files


> From: Girish Shilamkar <girish@linsyssoft.com>
> Date: Wed, 15 Feb 2006 16:34:45 +0530
> 
> Hi,
> 	The patch enables gdb to read arm core files.

Whoa, GDB doesn't support reading core files on ARM Linux?  This is
incredible but it sure looks as if it's true.  Unfortunately your
patch isn't quite right.

You can't use deprecated_add_core_fns(), since it is, well,
deprecated.  Please implement arm_linux_regset_from_core_section().  I
think the simplest example on how to implement it is in
vax_regset_from_core_section().

Also please rename the ELF_XXX you're using into ARM_ELF_XXX to avoid
potential clashes with Linux system header files.

Mark

> -Girish.
> 
> 
> --=-rVIxbIbwlwsLDC8PEZQS
> Content-Disposition: attachment; filename=gdb-6.4-arm-core.patch
> Content-Type: text/x-patch; name=gdb-6.4-arm-core.patch; charset=UTF-8
> Content-Transfer-Encoding: 7bit
> 
>  2006-02-15   Girish Shilamkar  <girish@linsyssoft.com>
>  
> 	* arm-linux-tdep.c Core file handler has been added. 
>  	* config/arm/linux.mt Compiles corelow.c required for 
> 	deprecated_add_core_fns	
> 
> Index: cvs-6.4/gdb/arm-linux-tdep.c
> ===================================================================
> --- cvs-6.4.orig/gdb/arm-linux-tdep.c	2006-01-15 13:28:58.000000000 -0500
> +++ cvs-6.4/gdb/arm-linux-tdep.c	2006-02-15 05:34:38.200467944 -0500
> @@ -70,6 +70,18 @@
>  #define ARM_LINUX_JB_ELEMENT_SIZE	INT_REGISTER_SIZE
>  #define ARM_LINUX_JB_PC			21
>  
> +/* Following enums used to implement the core file support. */
> +enum {
> +  ELF_NGREG = 18,      /* core reg size is 72 */
> +  ELF_NFPREG = 33,
> +  ELF_NVRREG = 33
> +};
> +
> +enum {
> +  ELF_GREGSET_SIZE = (ELF_NGREG * 4),
> +  ELF_FPREGSET_SIZE = (ELF_NFPREG * 12)        /* FP_REGISTER_SIZE is 12 */
> +};
> +
>  /* Extract from an array REGBUF containing the (raw) register state
>     a function return value of type TYPE, and copy that, in virtual format,
>     into VALBUF.  */
> @@ -372,8 +384,74 @@
>  }
>  
>  void
> +arm_linux_supply_gregset (char *buf)
> +{
> +  int regi;
> +  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
> +
> +  for (regi = 0; regi < 16; regi++)
> +    regcache_raw_supply(current_regcache, regi, buf + 4 * regi);
> +
> +   regcache_raw_supply (current_regcache, ARM_FPS_REGNUM, buf + 4 * 16);
> +   regcache_raw_supply (current_regcache, ARM_PS_REGNUM, buf + 4 * 17);
> +}
> +
> +void
> +arm_linux_supply_fpregset (char *buf)
> +{
> +  int regi;
> +  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
> +
> +  for (regi = 0; regi < 32; regi++)
> +     regcache_raw_supply (current_regcache, FP0_REGNUM + regi, buf + 8 * regi);
> +}
> +
> +/*
> +  Use a local version of this function to get the correct types for regsets.
> +*/
> +
> +static void
> +fetch_core_registers (char *core_reg_sect,
> +                      unsigned core_reg_size,
> +                      int which,
> +                      CORE_ADDR reg_addr)
> +{
> +  if (which == 0)
> +    {
> +      /* handle Integer register set */
> +      if (core_reg_size == ELF_GREGSET_SIZE)
> +        arm_linux_supply_gregset (core_reg_sect);
> +      else
> +        warning ("wrong size gregset struct in core file");
> +    }
> +  else if (which == 2)
> +    {
> +      /* handle Floating point register set */
> +      if (core_reg_size == ELF_FPREGSET_SIZE)
> +        arm_linux_supply_fpregset (core_reg_sect);
> +      else
> +        warning ("wrong size fpregset struct in core file");
> +    }
> +}
> +
> +/* Register that we are able to handle ELF file formats using standard
> +   procfs "regset" structures.  */
> +
> +static struct core_fns arm_linux_regset_core_fns =
> +{
> +  bfd_target_elf_flavour,       /* core_flavour */
> +  default_check_format,         /* check_format */
> +  default_core_sniffer,         /* core_sniffer */
> +  fetch_core_registers,         /* core_read_registers */
> +  NULL                          /* next */
> +};
> +
> +void
>  _initialize_arm_linux_tdep (void)
>  {
>    gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_LINUX,
>  			  arm_linux_init_abi);
> +
> + /* register core file handling functions */
> + deprecated_add_core_fns (&arm_linux_regset_core_fns);
>  }
> Index: cvs-6.4/gdb/config/arm/linux.mt
> ===================================================================
> --- cvs-6.4.orig/gdb/config/arm/linux.mt	2005-02-09 10:58:50.000000000 -0500
> +++ cvs-6.4/gdb/config/arm/linux.mt	2006-02-15 04:59:40.934300864 -0500
> @@ -1,3 +1,3 @@
>  # Target: ARM based machine running GNU/Linux
>  DEPRECATED_TM_FILE= tm-linux.h
> -TDEPFILES= arm-tdep.o arm-linux-tdep.o glibc-tdep.o solib.o solib-svr4.o solib-legacy.o symfile-mem.o
> +TDEPFILES= arm-tdep.o arm-linux-tdep.o glibc-tdep.o solib.o solib-svr4.o solib-legacy.o symfile-mem.o corelow.o
> 
> --=-rVIxbIbwlwsLDC8PEZQS--
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]