From e5ab6af52d38ee068c1860ef113b7db4cc985cfb Mon Sep 17 00:00:00 2001 From: Youling Tang Date: Mon, 30 May 2022 20:08:30 +0800 Subject: gdbserver: Add LoongArch/Linux support Implement LoongArch/Linux support, including XML target description handling based on features determined, GPR regset support, and software breakpoint handling. In the Linux kernel code of LoongArch, ptrace implements PTRACE_POKEUSR and PTRACE_PEEKUSR in the arch_ptrace function, so srv_linux_usrregs is set to yes. With this patch on LoongArch: $ make check-gdb TESTS="gdb.server/server-connect.exp" [...] # of expected passes 18 [...] Signed-off-by: Youling Tang Signed-off-by: Tiezhu Yang --- gdb/arch/loongarch.c | 12 +++++++++++- gdb/arch/loongarch.h | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'gdb/arch') diff --git a/gdb/arch/loongarch.c b/gdb/arch/loongarch.c index 934f6e4..11310c1 100644 --- a/gdb/arch/loongarch.c +++ b/gdb/arch/loongarch.c @@ -25,7 +25,13 @@ #include "../features/loongarch/base32.c" #include "../features/loongarch/base64.c" -static target_desc_up +#ifndef GDBSERVER +#define STATIC_IN_GDB static +#else +#define STATIC_IN_GDB +#endif + +STATIC_IN_GDB target_desc_up loongarch_create_target_description (const struct loongarch_gdbarch_features features) { /* Now we should create a new target description. */ @@ -51,6 +57,8 @@ loongarch_create_target_description (const struct loongarch_gdbarch_features fea return tdesc; } +#ifndef GDBSERVER + /* Wrapper used by std::unordered_map to generate hash for feature set. */ struct loongarch_gdbarch_features_hasher { @@ -86,3 +94,5 @@ loongarch_lookup_target_description (const struct loongarch_gdbarch_features fea loongarch_tdesc_cache.emplace (features, std::move (tdesc)); return ptr; } + +#endif /* !GDBSERVER */ diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h index 9e10df9..8194ea6 100644 --- a/gdb/arch/loongarch.h +++ b/gdb/arch/loongarch.h @@ -60,6 +60,17 @@ struct loongarch_gdbarch_features } }; +#ifdef GDBSERVER + +/* Create and return a target description that is compatible with FEATURES. + This is only used directly from the gdbserver where the created target + description is modified after it is return. */ + +target_desc_up loongarch_create_target_description + (const struct loongarch_gdbarch_features features); + +#else + /* Lookup an already existing target description matching FEATURES, or create a new target description if this is the first time we have seen FEATURES. For the same FEATURES the same target_desc is always @@ -70,4 +81,6 @@ struct loongarch_gdbarch_features const target_desc *loongarch_lookup_target_description (const struct loongarch_gdbarch_features features); +#endif /* GDBSERVER */ + #endif /* ARCH_LOONGARCH_H */ -- cgit v1.1