diff options
author | Alan Hayward <alan.hayward@arm.com> | 2018-03-01 11:03:25 +0000 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2018-03-01 11:03:25 +0000 |
commit | a2303a6ba747046fcb9f848a76ee66d7fce23417 (patch) | |
tree | cff5909678f0f243fa84fb3936e8aae2eb55ede6 | |
parent | 5d5e92d9e071dc9d92934c2b62c25d006be465a5 (diff) | |
download | gdb-a2303a6ba747046fcb9f848a76ee66d7fce23417.zip gdb-a2303a6ba747046fcb9f848a76ee66d7fce23417.tar.gz gdb-a2303a6ba747046fcb9f848a76ee66d7fce23417.tar.bz2 |
[PATCH v3 5/8] Add tdesc osabi and architecture functions
Add functions to access to printable names for osabi and architecture in
target_desc.
I wanted to add these as member functions of target_desc, but cannot until
target_desc is moved into the header files.
Alan.
2018-03-01 Alan Hayward <alan.hayward@arm.com>
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.
gdb/gdbserver/
* tdesc.c (tdesc_architecture_name): Add new function.
(tdesc_osabi_name): Likewise.
(tdesc_get_features_xml): Use new functions.
-rw-r--r-- | gdb/common/tdesc.h | 9 | ||||
-rw-r--r-- | gdb/gdbserver/tdesc.c | 23 | ||||
-rw-r--r-- | gdb/target-descriptions.c | 19 |
3 files changed, 47 insertions, 4 deletions
diff --git a/gdb/common/tdesc.h b/gdb/common/tdesc.h index 14f7bc3..c0d2a10 100644 --- a/gdb/common/tdesc.h +++ b/gdb/common/tdesc.h @@ -304,9 +304,18 @@ 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/tdesc.c b/gdb/gdbserver/tdesc.c index 1d9aeed..e113447 100644 --- a/gdb/gdbserver/tdesc.c +++ b/gdb/gdbserver/tdesc.c @@ -127,6 +127,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) @@ -136,6 +144,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) { @@ -160,13 +176,14 @@ tdesc_get_features_xml (target_desc *tdesc) buffer += "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"; buffer += "<target>"; buffer += "<architecture>"; - buffer += tdesc->arch; + buffer += tdesc_architecture_name (tdesc); buffer += "</architecture>"; - if (tdesc->osabi != nullptr) + const char *osabi = tdesc_osabi_name (tdesc); + if (osabi != nullptr) { buffer += "<osabi>"; - buffer += tdesc->osabi; + buffer += osabi; buffer += "</osabi>"; } diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 2782ffa..da2c1ce 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. */ |