From: Alan Hayward <alan.hayward@arm.com>
To: gdb-patches@sourceware.org
Cc: nd@arm.com, Alan Hayward <alan.hayward@arm.com>
Subject: [PATCH v5 4/8] Add tdesc osabi and architecture functions
Date: Tue, 10 Apr 2018 14:34:00 -0000 [thread overview]
Message-ID: <20180410143337.71768-5-alan.hayward@arm.com> (raw)
In-Reply-To: <20180410143337.71768-1-alan.hayward@arm.com>
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.
Identical to V3/4 versions.
Alan.
2018-04-10 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.
---
gdb/common/tdesc.h | 9 +++++++++
gdb/gdbserver/tdesc.c | 23 ++++++++++++++++++++---
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 7f4222b653..311341da0d 100644
--- a/gdb/common/tdesc.h
+++ b/gdb/common/tdesc.h
@@ -297,9 +297,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 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 += "<!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 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;
}
-\f
+/* 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.14.3 (Apple Git-98)
next prev parent reply other threads:[~2018-04-10 14:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-10 14:34 [PATCH v5 0/8] Remove gdbserver dependency on xml files Alan Hayward
2018-04-10 14:34 ` [PATCH v5 2/8] Commonise tdesc_feature Alan Hayward
2018-04-10 14:34 ` Alan Hayward [this message]
2018-04-18 2:10 ` [PATCH v5 4/8] Add tdesc osabi and architecture functions Simon Marchi
2018-04-10 14:34 ` [PATCH v5 7/8] Remove xml file references from target descriptions Alan Hayward
2018-04-10 14:34 ` [PATCH v5 6/8] Create xml " Alan Hayward
2018-04-18 2:43 ` Simon Marchi
2018-04-18 21:26 ` Alan Hayward
2018-04-10 14:34 ` [PATCH v5 3/8] Commonise tdesc types Alan Hayward
2018-04-10 14:34 ` [PATCH v5 1/8] Commonise tdesc_reg Alan Hayward
2018-04-18 1:57 ` Simon Marchi
2018-04-18 9:03 ` Alan Hayward
2018-04-18 13:54 ` Simon Marchi
2018-04-10 14:34 ` [PATCH v5 8/8] Remove xml files from gdbserver Alan Hayward
2018-04-10 14:34 ` [PATCH v5 5/8] Add feature reference in .dat files Alan Hayward
2018-04-18 2:49 ` [PATCH v5 0/8] Remove gdbserver dependency on xml files Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180410143337.71768-5-alan.hayward@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).