From: Alan Hayward <Alan.Hayward@arm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>
Subject: [PATCH v3 5/8] Add tdesc osabi and architecture functions
Date: Thu, 01 Mar 2018 11:40:00 -0000 [thread overview]
Message-ID: <4EAFFAAB-950F-4D3E-BDB2-7B3AC704BB45@arm.com> (raw)
In-Reply-To: <757A8B89-2EF0-46BD-BAA6-6E668538B17F@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.
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.
diff --git a/gdb/common/tdesc.h b/gdb/common/tdesc.h
index 14f7bc3a8f248adff04089438ad61c16e83385d0..c0d2a10b0f7ba4e7b836e3b163d229f1608b02d8 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 1d9aeed217da37fee7220845ff96085dde877876..e11344762a3a4114ed9aa459d7d739bd96a90ae5 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 2782ffaab9355e5a74da45e326ad468ff6bed796..da2c1ce34531c1b23281c42f2dacbc85444ef544 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. */
next prev parent reply other threads:[~2018-03-01 11:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 11:38 [PATCH V3 0/8] Remove gdbserver dependency on xml files Alan Hayward
2018-03-01 11:39 ` [PATCH v3 2/8] Commonise tdesc_reg Alan Hayward
2018-03-12 17:20 ` Philipp Rudo
2018-03-01 11:39 ` [PATCH V3 1/8] Move tdesc header funcs to c file Alan Hayward
2018-03-01 11:40 ` [PATCH v3 4/8] Commonise tdesc types Alan Hayward
2018-03-01 11:40 ` [PATCH v3 3/8] Commonise tdesc_feature Alan Hayward
2018-03-12 17:20 ` Philipp Rudo
2018-03-01 11:40 ` Alan Hayward [this message]
2018-03-01 11:41 ` [PATCH v3 8/8] Remove xml files from gdbserver Alan Hayward
2018-03-01 11:41 ` [PATCH v3 6/8] Create xml from target descriptions Alan Hayward
2018-03-12 17:20 ` Philipp Rudo
2018-03-13 18:05 ` Philipp Rudo
2018-03-14 10:09 ` Alan Hayward
2018-03-01 11:41 ` [PATCH v3 7/8]: Remove xml file references " Alan Hayward
2018-03-09 8:21 ` [PATCH V3 0/8] Remove gdbserver dependency on xml files Alan Hayward
2018-03-12 14:05 ` Omair Javaid
2018-03-12 17:19 ` Philipp Rudo
2018-03-13 10:17 ` Alan Hayward
2018-03-13 17:58 ` Philipp Rudo
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=4EAFFAAB-950F-4D3E-BDB2-7B3AC704BB45@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