From: Jon Turney <jon.turney@dronecode.org.uk>
To: gdb-patches@sourceware.org
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH 4/4] Add handling for 64-bit module addresses in Cygwin core dumps
Date: Wed, 12 Aug 2020 20:18:16 +0100 [thread overview]
Message-ID: <20200812191816.23246-5-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20200812191816.23246-1-jon.turney@dronecode.org.uk>
gdb/ChangeLog:
2020-07-01 Jon Turney <jon.turney@dronecode.org.uk>
* 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
next prev parent reply other threads:[~2020-08-12 19:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 19:18 [PATCH 0/4] Add gdb support for Cygwin x86_64 core dumps (v2) Jon Turney
2020-08-12 19:18 ` [PATCH 1/4] Add sniffer for Cygwin x86_64 core dumps Jon Turney
2020-08-20 22:20 ` Simon Marchi
2020-08-21 15:25 ` Jon Turney
2020-08-21 16:22 ` Simon Marchi
2020-08-21 16:28 ` Jon Turney
2020-08-22 19:41 ` Simon Marchi
2020-08-22 19:52 ` Jon Turney
2020-08-24 15:47 ` Simon Marchi
2020-08-24 17:02 ` Jon Turney
2020-08-12 19:18 ` [PATCH 2/4] Add amd64_windows_gregset_reg_offset Jon Turney
2020-08-20 22:08 ` Simon Marchi
2020-09-18 16:31 ` Jon Turney
2020-08-12 19:18 ` [PATCH 3/4] Promote windows_core_xfer_shared_libraries and windows_core_pid_to_str Jon Turney
2020-08-12 19:18 ` Jon Turney [this message]
2020-08-24 18:34 ` [PATCH 4/4] Add handling for 64-bit module addresses in Cygwin core dumps Simon Marchi
2020-09-15 21:44 ` Jon Turney
2020-09-16 2:20 ` Simon Marchi
2020-09-16 9:15 ` Christian Biesinger
2020-08-12 19:30 ` [PATCH 0/4] Add gdb support for Cygwin x86_64 core dumps (v2) Eli Zaretskii
2020-08-13 14:43 ` Jon Turney
2020-08-13 16:48 ` Eli Zaretskii
2020-08-18 15:32 ` Jon Turney
2020-08-18 16:15 ` Eli Zaretskii
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=20200812191816.23246-5-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=gdb-patches@sourceware.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