[1/4] Add aarch64_create_target_description
Commit Message
> On 30 Oct 2017, at 12:00, Yao Qi <qiyaoltc@gmail.com> wrote:
>
> Alan Hayward <Alan.Hayward@arm.com> writes:
>
>> +/* The Aarch64 target descriptor. */
>
> s/descriptor/description/
>
>> +static const struct target_desc *aarch64_tdesc = NULL;
>> +
>
> Remove "struct".
>
> Can you move aarch64_tdesc to aarch64_read_description? I think it
> only needs to be visible inside that function.
>
>> /* The standard register names, and all the valid aliases for them. */
>> static const struct
>> {
>> @@ -2827,6 +2830,19 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
>> return 1;
>> }
>>
>> +/* Get the correct target description. */
>> +
>> +const target_desc *
>> +aarch64_read_description ()
>
> Otherwise, the patch is good to me.
>
> --
> Yao (齐尧)
Fixed as suggested above.
@@ -779,6 +779,7 @@ ALL_64_TARGET_OBS = \
amd64-sol2-tdep.o \
amd64-tdep.o \
amd64-windows-tdep.o \
+ arch/aarch64.o \
arch/aarch64-insn.o \
arch/amd64.o \
ia64-linux-tdep.o \
@@ -1514,6 +1515,7 @@ HFILES_NO_SRCDIR = \
xml-syscall.h \
xml-tdesc.h \
xtensa-tdep.h \
+ arch/aarch64.h \
arch/aarch64-insn.h \
arch/arm.h \
arch/i386.h \
@@ -501,7 +501,7 @@ aarch64_linux_read_description (struct target_ops *ops)
if (ret == 0)
return tdesc_arm_with_neon;
else
- return tdesc_aarch64;
+ return aarch64_read_description ();
}
/* Convert a native/host siginfo object, into/from the siginfo in the
@@ -244,7 +244,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
if (target_auxv_search (target, AT_HWCAP, &aarch64_hwcap) != 1)
return NULL;
- return tdesc_aarch64;
+ return aarch64_read_description ();
}
/* Implementation of `gdbarch_stap_is_single_operand', as defined in
@@ -75,7 +75,7 @@ struct gdbarch_tdep
int (*aarch64_syscall_record) (struct regcache *regcache, unsigned long svc_number);
};
-extern struct target_desc *tdesc_aarch64;
+const target_desc *aarch64_read_description ();
extern int aarch64_process_record (struct gdbarch *gdbarch,
struct regcache *regcache, CORE_ADDR addr);
@@ -2827,6 +2827,20 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
return 1;
}
+/* Get the correct target description. */
+
+const target_desc *
+aarch64_read_description ()
+{
+ static target_desc *aarch64_tdesc = NULL;
+ target_desc **tdesc = &aarch64_tdesc;
+
+ if (*tdesc == NULL)
+ *tdesc = aarch64_create_target_description ();
+
+ return *tdesc;
+}
+
/* Initialize the current architecture based on INFO. If possible,
re-use an architecture from ARCHES, which is a list of
architectures already created during this debugging session.
@@ -2850,7 +2864,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Ensure we always have a target descriptor. */
if (!tdesc_has_registers (tdesc))
- tdesc = tdesc_aarch64;
+ tdesc = aarch64_read_description ();
gdb_assert (tdesc);
@@ -20,6 +20,10 @@
#ifndef ARCH_AARCH64_H
#define ARCH_AARCH64_H
+#include "tdesc.h"
+
+target_desc *aarch64_create_target_description ();
+
/* Register numbers of various important registers. */
enum aarch64_regnum
{
new file mode 100644
@@ -0,0 +1,30 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include "aarch64.h"
+
+extern struct target_desc *tdesc_aarch64;
+
+/* Create the aarch64 target description. */
+
+target_desc *
+aarch64_create_target_description ()
+{
+ return tdesc_aarch64;
+}
+
@@ -114,7 +114,7 @@ aarch64*-*-freebsd*)
aarch64*-*-linux*)
# Target: AArch64 linux
- gdb_target_obs="aarch64-linux-tdep.o \
+ gdb_target_obs="aarch64-linux-tdep.o arch/aarch64.o\
arch/arm.o arch/arm-linux.o arch/arm-get-next-pcs.o \
arm-tdep.o arm-linux-tdep.o \
glibc-tdep.o linux-tdep.o solib-svr4.o \