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 <tangyouling@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
This commit is contained in:
Youling Tang
2022-05-30 20:08:30 +08:00
committed by Tiezhu Yang
parent 476288fa2b
commit e5ab6af52d
6 changed files with 280 additions and 1 deletions

View File

@@ -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 */

View File

@@ -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 */