gdb: Delay releasing target_desc_up in more cases

After commit:

  commit 51a948fdf0
  Date:   Mon Jul 20 14:18:04 2020 +0100

      gdb: Have allocate_target_description return a unique_ptr

There were a few places where we could (should?) have delayed
releasing the target_desc_up until a little later.  This commit
catches these cases.

In the case of ARC, the target_desc_up is now exposed right out to
gdbserver, which means making a small change there too.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* arch/aarch32.c (aarch32_create_target_description): Release the
	target_desc_up as late as possible.
	* arch/aarch64.c (aarch64_create_target_description): Likewise.
	* arch/amd64.c (amd64_create_target_description): Likewise.
	* arch/arc.c (arc_create_target_description): Return a
	target_desc_up, don't release it.
	* arch/arc.h (arc_create_target_description): Update declaration.
	(arc_lookup_target_description): Move target_desc_up into the
	cache, and return a borrowed pointer.
	* arch/arm.c (arm_create_target_description): Release the
	target_desc_up as late as possible.
	* arch/i386.c (i386_create_target_description): Likewise.
	* arch/riscv.h (riscv_create_target_description): Update
	declaration to match definition.
	* arch/tic6x.c (tic6x_create_target_description): Release the
	target_desc_up as late as possible.

gdbserver/ChangeLog:

	* linux-arc-low.cc (arc_linux_read_description): Release the
	unique_ptr returned from arc_create_target_description.
This commit is contained in:
Andrew Burgess
2020-10-08 10:44:55 +01:00
parent 361cb21935
commit bbb826f5e9
12 changed files with 97 additions and 69 deletions

View File

@@ -374,18 +374,18 @@ shifted_reg_val (struct regcache *regcache, unsigned long inst,
target_desc *
arm_create_target_description (arm_fp_type fp_type)
{
target_desc *tdesc = allocate_target_description ().release ();
target_desc_up tdesc = allocate_target_description ();
#ifndef IN_PROCESS_AGENT
if (fp_type == ARM_FP_TYPE_IWMMXT)
set_tdesc_architecture (tdesc, "iwmmxt");
set_tdesc_architecture (tdesc.get (), "iwmmxt");
else
set_tdesc_architecture (tdesc, "arm");
set_tdesc_architecture (tdesc.get (), "arm");
#endif
long regnum = 0;
regnum = create_feature_arm_arm_core (tdesc, regnum);
regnum = create_feature_arm_arm_core (tdesc.get (), regnum);
switch (fp_type)
{
@@ -393,22 +393,22 @@ arm_create_target_description (arm_fp_type fp_type)
break;
case ARM_FP_TYPE_VFPV2:
regnum = create_feature_arm_arm_vfpv2 (tdesc, regnum);
regnum = create_feature_arm_arm_vfpv2 (tdesc.get (), regnum);
break;
case ARM_FP_TYPE_VFPV3:
regnum = create_feature_arm_arm_vfpv3 (tdesc, regnum);
regnum = create_feature_arm_arm_vfpv3 (tdesc.get (), regnum);
break;
case ARM_FP_TYPE_IWMMXT:
regnum = create_feature_arm_xscale_iwmmxt (tdesc, regnum);
regnum = create_feature_arm_xscale_iwmmxt (tdesc.get (), regnum);
break;
default:
error (_("Invalid Arm FP type: %d"), fp_type);
}
return tdesc;
return tdesc.release ();
}
/* See arch/arm.h. */