From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93855 invoked by alias); 5 Nov 2015 14:18:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 93842 invoked by uid 89); 5 Nov 2015 14:18:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f182.google.com Received: from mail-wi0-f182.google.com (HELO mail-wi0-f182.google.com) (209.85.212.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 05 Nov 2015 14:18:34 +0000 Received: by wicll6 with SMTP id ll6so10485045wic.1 for ; Thu, 05 Nov 2015 06:18:31 -0800 (PST) X-Received: by 10.195.11.129 with SMTP id ei1mr8538849wjd.129.1446733111768; Thu, 05 Nov 2015 06:18:31 -0800 (PST) Received: from bigtime.com ([87.111.149.167]) by smtp.gmail.com with ESMTPSA id 194sm8646030wmh.19.2015.11.05.06.18.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Nov 2015 06:18:30 -0800 (PST) From: Richard Henderson 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 Message-Id: <1446733076-21122-1-git-send-email-rth@redhat.com> In-Reply-To: <1446558190-13482-1-git-send-email-rth@redhat.com> References: <1446558190-13482-1-git-send-email-rth@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00183.txt.bz2 * 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; +} + /* 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); } -- 2.4.3