From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from re-prd-fep-048.btinternet.com (mailomta14-re.btinternet.com [213.120.69.107]) by sourceware.org (Postfix) with ESMTPS id 4FB9D384BC21 for ; Wed, 12 Aug 2020 19:18:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FB9D384BC21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=jon.turney@dronecode.org.uk Received: from re-prd-rgout-002.btmx-prd.synchronoss.net ([10.2.54.5]) by re-prd-fep-048.btinternet.com with ESMTP id <20200812191849.TZXL4701.re-prd-fep-048.btinternet.com@re-prd-rgout-002.btmx-prd.synchronoss.net>; Wed, 12 Aug 2020 20:18:49 +0100 Authentication-Results: btinternet.com; none X-Originating-IP: [31.51.206.146] X-OWM-Source-IP: 31.51.206.146 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgeduiedrledvgddufeehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeflohhnucfvuhhrnhgvhicuoehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkqeenucggtffrrghtthgvrhhnpeefieduveehgfffffeuueehleefgeevfedvffeljeefheduteelteelvdettefhvdenucfkphepfedurdehuddrvddtiedrudegieenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhephhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhinhgvthepfedurdehuddrvddtiedrudegiedpmhgrihhlfhhrohhmpeeojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqpdhrtghpthhtohepoehguggsqdhprghttghhvghssehsohhurhgtvgifrghrvgdrohhrgheqpdhrtghpthhtohepoehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhkqe X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (31.51.206.146) by re-prd-rgout-002.btmx-prd.synchronoss.net (5.8.340) (authenticated as jonturney@btinternet.com) id 5ED9C0CC0B800686; Wed, 12 Aug 2020 20:18:49 +0100 From: Jon Turney To: gdb-patches@sourceware.org Cc: Jon Turney Subject: [PATCH 4/4] Add handling for 64-bit module addresses in Cygwin core dumps Date: Wed, 12 Aug 2020 20:18:16 +0100 Message-Id: <20200812191816.23246-5-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200812191816.23246-1-jon.turney@dronecode.org.uk> References: <20200812191816.23246-1-jon.turney@dronecode.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Aug 2020 19:18:51 -0000 gdb/ChangeLog: 2020-07-01 Jon Turney * windows-tdep.c (NOTE_INFO_MODULE, NOTE_INFO_MODULE64): Define. (core_process_module_section): Handle NOTE_INFO_MODULE64. --- gdb/ChangeLog | 5 +++++ gdb/windows-tdep.c | 30 +++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 037958a4bf5..dd5f69a9acd 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -105,6 +105,10 @@ enum CYGWIN_SIGUSR2 = 31, }; +/* These constants are defined by Cygwin's core_dump.h */ +static constexpr unsigned int NOTE_INFO_MODULE = 3; +static constexpr unsigned int NOTE_INFO_MODULE64 = 4; + struct cmd_list_element *info_w32_cmdlist; typedef struct thread_information_block_32 @@ -1101,8 +1105,10 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj) struct cpms_data *data = (struct cpms_data *) obj; enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch); + unsigned int data_type; char *module_name; size_t module_name_size; + size_t module_name_offset; CORE_ADDR base_addr; gdb_byte *buf = NULL; @@ -1123,16 +1129,26 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj) /* A DWORD (data_type) followed by struct windows_core_module_info. */ + data_type = extract_unsigned_integer (buf, 4, byte_order); - base_addr = - extract_unsigned_integer (buf + 4, 4, byte_order); - - module_name_size = - extract_unsigned_integer (buf + 8, 4, byte_order); + if (data_type == NOTE_INFO_MODULE) + { + base_addr = extract_unsigned_integer (buf + 4, 4, byte_order); + module_name_size = extract_unsigned_integer (buf + 8, 4, byte_order); + module_name_offset = 12; + } + else if (data_type == NOTE_INFO_MODULE64) + { + base_addr = extract_unsigned_integer (buf + 4, 8, byte_order); + module_name_size = extract_unsigned_integer (buf + 12, 4, byte_order); + module_name_offset = 16; + } + else + goto out; - if (12 + module_name_size > bfd_section_size (sect)) + if (module_name_offset + module_name_size > bfd_section_size (sect)) goto out; - module_name = (char *) buf + 12; + module_name = (char *) buf + module_name_offset; /* The first module is the .exe itself. */ if (data->module_count != 0) -- 2.28.0