From: Richard Henderson <rth@redhat.com>
To: gdb-patches@gcc.gnu.org
Subject: [PATCH 4/3] Segment support for x86_64, part 2
Date: Thu, 05 Nov 2015 14:18:00 -0000 [thread overview]
Message-ID: <1446733076-21122-1-git-send-email-rth@redhat.com> (raw)
In-Reply-To: <1446558190-13482-1-git-send-email-rth@redhat.com>
* amd64-tdep.c (amd64_address_to_pointer): New.
(amd64_pointer_to_address): New.
(amd64_init_abi): Register them.
---
gdb/amd64-tdep.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 3 deletions(-)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 3f12796..b327692 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2934,9 +2934,64 @@ amd64_address_class_name_to_type_flags (struct gdbarch *gdbarch,
return 0;
}
-/* ??? We ought to fill in address_to_pointer and pointer_to_address,
- except that these hooks do not have access to the thread, or a
- regcache for the thread. */
+static void
+amd64_address_to_pointer (struct gdbarch *gdbarch, struct type *type,
+ gdb_byte *buf, CORE_ADDR addr)
+{
+ int regnum = -1;
+
+ switch (TYPE_ADDRESS_CLASS_ALL (type))
+ {
+ case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1:
+ regnum = AMD64_FSBASE_REGNUM;
+ break;
+ case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2:
+ regnum = AMD64_GSBASE_REGNUM;
+ break;
+ }
+ if (regnum >= 0)
+ {
+ struct regcache *regcache = get_current_regcache ();
+ ULONGEST base;
+
+ if (regcache_raw_read_unsigned (regcache, regnum, &base) == REG_VALID)
+ addr -= base;
+ /* ??? else error, but we have no way to signal that here. */
+ }
+
+ store_unsigned_integer (buf, TYPE_LENGTH (type), BFD_ENDIAN_LITTLE, addr);
+}
+
+static CORE_ADDR
+amd64_pointer_to_address (struct gdbarch *gdbarch, struct type *type,
+ const gdb_byte *buf)
+{
+ ULONGEST addr = extract_unsigned_integer (buf, TYPE_LENGTH (type),
+ BFD_ENDIAN_LITTLE);
+ int regnum = -1;
+
+ switch (TYPE_ADDRESS_CLASS_ALL (type))
+ {
+ case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1:
+ regnum = AMD64_FSBASE_REGNUM;
+ break;
+ case TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2:
+ regnum = AMD64_GSBASE_REGNUM;
+ break;
+ }
+ if (regnum >= 0)
+ {
+ struct regcache *regcache = get_current_regcache ();
+ ULONGEST base;
+
+ if (regcache_raw_read_unsigned (regcache, regnum, &base) == REG_VALID)
+ addr += base;
+ /* ??? else error, but we have no way to signal that here. */
+ }
+
+ return addr;
+}
+
\f
/* Figure out where the longjmp will land. Slurp the jmp_buf out of
@@ -3149,6 +3204,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
(gdbarch, amd64_address_class_type_flags_to_name);
set_gdbarch_address_class_name_to_type_flags
(gdbarch, amd64_address_class_name_to_type_flags);
+ set_gdbarch_address_to_pointer (gdbarch, amd64_address_to_pointer);
+ set_gdbarch_pointer_to_address (gdbarch, amd64_pointer_to_address);
}
\f
--
2.4.3
next prev parent reply other threads:[~2015-11-05 14:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 13:43 [PATCH 0/3] Support for x86 segments as address classes Richard Henderson
2015-11-03 13:43 ` [PATCH 2/3] Use register cache for x86_64 ps_get_thread_area Richard Henderson
2015-11-03 13:44 ` [PATCH 1/3] Add amd64 registers fs_base and gs_base Richard Henderson
2015-11-03 13:44 ` [PATCH 3/3] Segment support for x86_64, part 1 Richard Henderson
2015-11-05 11:21 ` [PATCH 0/3] Support for x86 segments as address classes Pedro Alves
2015-11-05 14:15 ` Richard Henderson
2015-11-18 18:18 ` Ulrich Weigand
2015-11-05 14:18 ` Richard Henderson [this message]
2015-11-27 14:34 ` Gary Benson
2016-04-19 14:23 ` Tedeschi, Walfred
2016-04-19 14:44 ` Richard Henderson
2016-04-19 14:47 ` Walfred Tedeschi
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=1446733076-21122-1-git-send-email-rth@redhat.com \
--to=rth@redhat.com \
--cc=gdb-patches@gcc.gnu.org \
/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