From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org, binutils@sourceware.org
Subject: [PATCH 1/8] Implement the "get_siginfo_type" gdbarch method for FreeBSD architectures.
Date: Thu, 29 Jun 2017 23:33:00 -0000 [thread overview]
Message-ID: <20170629233226.20155-2-jhb@FreeBSD.org> (raw)
In-Reply-To: <20170629233226.20155-1-jhb@FreeBSD.org>
As with Linux architectures, cache the created type in the gdbarch when it
is first created. Currently FreeBSD uses an identical siginfo type on
all architectures, so there is no support for architecture-specific fields.
gdb/ChangeLog:
* fbsd-tdep.c (fbsd_gdbarch_data_handle, struct fbsd_gdbarch_data)
(init_fbsd_gdbarch_data, get_fbsd_gdbarch_data)
(fbsd_get_siginfo_type): New.
(fbsd_init_abi): Install gdbarch "get_siginfo_type" method.
(_initialize_fbsd_tdep): New.
---
gdb/ChangeLog | 8 ++++
gdb/fbsd-tdep.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 130 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4e091d7e40..43d422b4ab 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2017-06-28 John Baldwin <jhb@FreeBSD.org>
+
+ * fbsd-tdep.c (fbsd_gdbarch_data_handle, struct fbsd_gdbarch_data)
+ (init_fbsd_gdbarch_data, get_fbsd_gdbarch_data)
+ (fbsd_get_siginfo_type): New.
+ (fbsd_init_abi): Install gdbarch "get_siginfo_type" method.
+ (_initialize_fbsd_tdep): New.
+
2017-06-19 John Baldwin <jhb@FreeBSD.org>
* mips-tdep.c (print_gp_register_row): Don't error for unavailable
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index b834ce38b4..24a3c20dd6 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -30,6 +30,26 @@
#include "fbsd-tdep.h"
+static struct gdbarch_data *fbsd_gdbarch_data_handle;
+
+struct fbsd_gdbarch_data
+ {
+ struct type *siginfo_type;
+ };
+
+static void *
+init_fbsd_gdbarch_data (struct gdbarch *gdbarch)
+{
+ return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct fbsd_gdbarch_data);
+}
+
+static struct fbsd_gdbarch_data *
+get_fbsd_gdbarch_data (struct gdbarch *gdbarch)
+{
+ return ((struct fbsd_gdbarch_data *)
+ gdbarch_data (gdbarch, fbsd_gdbarch_data_handle));
+}
+
/* This is how we want PTIDs from core files to be printed. */
static const char *
@@ -314,6 +334,97 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
fprint_auxv_entry (file, name, description, format, type, val);
}
+/* Implement the "get_siginfo_type" gdbarch method. */
+
+static struct type *
+fbsd_get_siginfo_type (struct gdbarch *gdbarch)
+{
+ struct fbsd_gdbarch_data *fbsd_gdbarch_data;
+ struct type *int_type, *int32_type, *uint32_type, *long_type, *void_ptr_type;
+ struct type *uid_type, *pid_type;
+ struct type *sigval_type, *reason_type;
+ struct type *siginfo_type;
+ struct type *type;
+
+ fbsd_gdbarch_data = get_fbsd_gdbarch_data (gdbarch);
+ if (fbsd_gdbarch_data->siginfo_type != NULL)
+ return fbsd_gdbarch_data->siginfo_type;
+
+ int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+ 0, "int");
+ int32_type = arch_integer_type (gdbarch, 32, 0, "int32_t");
+ uint32_type = arch_integer_type (gdbarch, 32, 1, "uint32_t");
+ long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+ 0, "long");
+ void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
+
+ /* union sigval */
+ sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
+ TYPE_NAME (sigval_type) = xstrdup ("sigval");
+ append_composite_type_field (sigval_type, "sival_int", int_type);
+ append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
+
+ /* __pid_t */
+ pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
+ TYPE_LENGTH (int32_type), "__pid_t");
+ TYPE_TARGET_TYPE (pid_type) = int32_type;
+ TYPE_TARGET_STUB (pid_type) = 1;
+
+ /* __uid_t */
+ uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
+ TYPE_LENGTH (uint32_type), "__uid_t");
+ TYPE_TARGET_TYPE (uid_type) = uint32_type;
+ TYPE_TARGET_STUB (uid_type) = 1;
+
+ /* _reason */
+ reason_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
+
+ /* _fault */
+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ append_composite_type_field (type, "si_trapno", int_type);
+ append_composite_type_field (reason_type, "_fault", type);
+
+ /* _timer */
+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ append_composite_type_field (type, "si_timerid", int_type);
+ append_composite_type_field (type, "si_overrun", int_type);
+ append_composite_type_field (reason_type, "_timer", type);
+
+ /* _mesgq */
+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ append_composite_type_field (type, "si_mqd", int_type);
+ append_composite_type_field (reason_type, "_mesgq", type);
+
+ /* _poll */
+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ append_composite_type_field (type, "si_band", long_type);
+ append_composite_type_field (reason_type, "_poll", type);
+
+ /* __spare__ */
+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ append_composite_type_field (type, "__spare1__", long_type);
+ append_composite_type_field (type, "__spare2__",
+ init_vector_type (int_type, 7));
+ append_composite_type_field (reason_type, "__spare__", type);
+
+ /* struct siginfo */
+ siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ TYPE_NAME (siginfo_type) = xstrdup ("siginfo");
+ append_composite_type_field (siginfo_type, "si_signo", int_type);
+ append_composite_type_field (siginfo_type, "si_errno", int_type);
+ append_composite_type_field (siginfo_type, "si_code", int_type);
+ append_composite_type_field (siginfo_type, "si_pid", pid_type);
+ append_composite_type_field (siginfo_type, "si_uid", uid_type);
+ append_composite_type_field (siginfo_type, "si_status", int_type);
+ append_composite_type_field (siginfo_type, "si_addr", void_ptr_type);
+ append_composite_type_field (siginfo_type, "si_value", sigval_type);
+ append_composite_type_field (siginfo_type, "_reason", reason_type);
+
+ fbsd_gdbarch_data->siginfo_type = siginfo_type;
+
+ return siginfo_type;
+}
+
/* Implement the "get_syscall_number" gdbarch method. */
static LONGEST
@@ -339,8 +450,19 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name);
set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes);
set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry);
+ set_gdbarch_get_siginfo_type (gdbarch, fbsd_get_siginfo_type);
/* `catch syscall' */
set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml");
set_gdbarch_get_syscall_number (gdbarch, fbsd_get_syscall_number);
}
+
+/* Provide a prototype to silence -Wmissing-prototypes. */
+extern initialize_file_ftype _initialize_fbsd_tdep;
+
+void
+_initialize_fbsd_tdep (void)
+{
+ fbsd_gdbarch_data_handle =
+ gdbarch_data_register_post_init (init_fbsd_gdbarch_data);
+}
--
2.11.0
next prev parent reply other threads:[~2017-06-29 23:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 23:33 [PATCH 0/8] Add support for $_siginfo on FreeBSD John Baldwin
2017-06-29 23:33 ` [PATCH 3/8] Move the thread_section_name class to gdbcore.h John Baldwin
2017-06-29 23:33 ` John Baldwin [this message]
2017-06-29 23:33 ` [PATCH 2/8] Fetch signal information for native FreeBSD processes John Baldwin
2017-06-29 23:33 ` [PATCH 8/8] Read signal information from FreeBSD core dumps John Baldwin
2017-06-29 23:33 ` [PATCH 6/8] Recognize the recently-added FreeBSD core dump note for LWP info John Baldwin
2017-06-30 3:19 ` Alan Modra
2017-06-29 23:33 ` [PATCH 7/8] Create psuedo sections for FreeBSD NT_PTLWPINFO core notes John Baldwin
2017-06-30 3:20 ` Alan Modra
2017-06-29 23:41 ` [PATCH 5/8] Use the thread_section_name helper class in fbsd_core_thread_name John Baldwin
2017-06-29 23:41 ` [PATCH 4/8] Add a new gdbarch method to fetch signal information from core files John Baldwin
2017-07-06 11:17 ` [PATCH 0/8] Add support for $_siginfo on FreeBSD John Baldwin
2017-07-06 13:29 ` Pedro Alves
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=20170629233226.20155-2-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=binutils@sourceware.org \
--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