From d278f585afe8e096e9232b8fd80404ab5fae5719 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Wed, 18 Apr 2018 11:51:21 +0100 Subject: [PATCH] Add tdesc osabi and architecture functions gdb/ * common/tdesc.h (tdesc_architecture_name): Add new declaration. (tdesc_osabi_name): Likewise. * target-descriptions.c (tdesc_architecture_name): Add new function. (tdesc_osabi_name): Likewise. gdbserver/ * tdesc.c (tdesc_architecture_name): Add new function. (tdesc_osabi_name): Likewise. (tdesc_get_features_xml): Use new functions. --- gdb/ChangeLog | 8 ++++++++ gdb/common/tdesc.h | 8 ++++++++ gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/tdesc.c | 23 ++++++++++++++++++++--- gdb/target-descriptions.c | 19 ++++++++++++++++++- 5 files changed, 60 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 83a2d01f9e..624de26390 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2018-04-18 Alan Hayward + + * common/tdesc.h (tdesc_architecture_name): Add new declaration. + (tdesc_osabi_name): Likewise. + * target-descriptions.c (tdesc_architecture_name): Add new + function. + (tdesc_osabi_name): Likewise. + 2018-04-18 Alan Hayward * common/tdesc.c (tdesc_predefined_type): Move to here. diff --git a/gdb/common/tdesc.h b/gdb/common/tdesc.h index 7f4222b653..8b826ec436 100644 --- a/gdb/common/tdesc.h +++ b/gdb/common/tdesc.h @@ -297,9 +297,17 @@ target_desc *allocate_target_description (void); void set_tdesc_architecture (target_desc *target_desc, const char *name); +/* Return the architecture associated with this target description as a string, + or NULL if no architecture was specified. */ +const char *tdesc_architecture_name (const struct target_desc *target_desc); + /* Set TARGET_DESC's osabi by NAME. */ void set_tdesc_osabi (target_desc *target_desc, const char *name); +/* Return the osabi associated with this target description as a string, + or NULL if no osabi was specified. */ +const char *tdesc_osabi_name (const struct target_desc *target_desc); + /* Return the type associated with ID in the context of FEATURE, or NULL if none. */ struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature, diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index a9de2ddb50..96dc83cc7e 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,9 @@ +2018-04-18 Alan Hayward + + * tdesc.c (tdesc_architecture_name): Add new function. + (tdesc_osabi_name): Likewise. + (tdesc_get_features_xml): Use new functions. + 2018-04-18 Alan Hayward * tdesc.c (tdesc_create_flags): Remove. diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c index aca27ea3b0..7603a90a59 100644 --- a/gdb/gdbserver/tdesc.c +++ b/gdb/gdbserver/tdesc.c @@ -107,6 +107,14 @@ current_target_desc (void) /* See common/tdesc.h. */ +const char * +tdesc_architecture_name (const struct target_desc *target_desc) +{ + return target_desc->arch; +} + +/* See common/tdesc.h. */ + void set_tdesc_architecture (struct target_desc *target_desc, const char *name) @@ -116,6 +124,14 @@ set_tdesc_architecture (struct target_desc *target_desc, /* See common/tdesc.h. */ +const char * +tdesc_osabi_name (const struct target_desc *target_desc) +{ + return target_desc->osabi; +} + +/* See common/tdesc.h. */ + void set_tdesc_osabi (struct target_desc *target_desc, const char *name) { @@ -140,13 +156,14 @@ tdesc_get_features_xml (target_desc *tdesc) buffer += ""; buffer += ""; buffer += ""; - buffer += tdesc->arch; + buffer += tdesc_architecture_name (tdesc); buffer += ""; - if (tdesc->osabi != nullptr) + const char *osabi = tdesc_osabi_name (tdesc); + if (osabi != nullptr) { buffer += ""; - buffer += tdesc->osabi; + buffer += osabi; buffer += ""; } diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 2782ffaab9..da2c1ce345 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -628,6 +628,14 @@ tdesc_architecture (const struct target_desc *target_desc) return target_desc->arch; } +/* See common/tdesc.h. */ + +const char * +tdesc_architecture_name (const struct target_desc *target_desc) +{ + return target_desc->arch->printable_name; +} + /* Return the OSABI associated with this target description, or GDB_OSABI_UNKNOWN if no osabi was specified. */ @@ -637,7 +645,16 @@ tdesc_osabi (const struct target_desc *target_desc) return target_desc->osabi; } - +/* See common/tdesc.h. */ + +const char * +tdesc_osabi_name (const struct target_desc *target_desc) +{ + enum gdb_osabi osabi = tdesc_osabi (target_desc); + if (osabi > GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID) + return gdbarch_osabi_name (osabi); + return nullptr; +} /* Return 1 if this target description includes any registers. */ -- 2.34.1