From: Simon Marchi <simon.marchi@ericsson.com>
To: Pedro Alves <palves@redhat.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2 4/7] gdbarch: add addressable_memory_unit_size method
Date: Fri, 12 Jun 2015 20:54:00 -0000 [thread overview]
Message-ID: <557B46EB.5040507@ericsson.com> (raw)
In-Reply-To: <555E19DE.2030706@redhat.com>
> This is the central place everyone should look at first to understand
> non 8-bit bytes targets. For extra clarity, could you please
> add "8-bit"s in there, say:
>
> "the size in 8-bit bytes" (...) to the number of 8-bit bytes associated to
> each address in memory."
>
> Looks good to me with that change.
>
> Thanks,
> Pedro Alves
Thanks, pushed with the change:
From 3374165f51fa3cc3ce1b1bf8c72293464da9d511 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Fri, 12 Jun 2015 16:51:51 -0400
Subject: [PATCH] gdbarch: add addressable_memory_unit_size method
Add a new gdbarch method to get the length of an addressable memory unit
for a given architecture. The default implementation returns 1.
gdb/ChangeLog:
* arch-utils.h (default_addressable_memory_unit_size): New.
* arch-utils.c (default_addressable_memory_unit_size): New.
* gdbarch.sh (addressable_memory_unit_size): New.
* gdbarch.h: Re-generate.
* gdbarch.c: Re-generate.
---
gdb/ChangeLog | 8 ++++++++
gdb/arch-utils.c | 9 +++++++++
gdb/arch-utils.h | 1 +
gdb/gdbarch.c | 23 +++++++++++++++++++++++
gdb/gdbarch.h | 8 ++++++++
gdb/gdbarch.sh | 6 ++++++
6 files changed, 55 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bde6f67..1b28992 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2015-06-12 Simon Marchi <simon.marchi@ericsson.com>
+ * arch-utils.h (default_addressable_memory_unit_size): New.
+ * arch-utils.c (default_addressable_memory_unit_size): New.
+ * gdbarch.sh (addressable_memory_unit_size): New.
+ * gdbarch.h: Re-generate.
+ * gdbarch.c: Re-generate.
+
+2015-06-12 Simon Marchi <simon.marchi@ericsson.com>
+
* target.c (target_read): Rename variables and use
TARGET_XFER_E_IO.
(target_read_with_progress): Same.
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 7f07e21..e9c622d 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -888,6 +888,15 @@ default_gnu_triplet_regexp (struct gdbarch *gdbarch)
return gdbarch_bfd_arch_info (gdbarch)->arch_name;
}
+/* Default method for gdbarch_addressable_memory_unit_size. By default, a memory byte has
+ a size of 1 octet. */
+
+int
+default_addressable_memory_unit_size (struct gdbarch *gdbarch)
+{
+ return 1;
+}
+
/* -Wmissing-prototypes */
extern initialize_file_ftype _initialize_gdbarch_utils;
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 9cb28e4..27f4787 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -203,5 +203,6 @@ extern CORE_ADDR default_infcall_mmap (CORE_ADDR size, unsigned prot);
extern void default_infcall_munmap (CORE_ADDR addr, CORE_ADDR size);
extern char *default_gcc_target_options (struct gdbarch *gdbarch);
extern const char *default_gnu_triplet_regexp (struct gdbarch *gdbarch);
+extern int default_addressable_memory_unit_size (struct gdbarch *gdbarch);
#endif
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index cd82487..c289334 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -329,6 +329,7 @@ struct gdbarch
gdbarch_infcall_munmap_ftype *infcall_munmap;
gdbarch_gcc_target_options_ftype *gcc_target_options;
gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp;
+ gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size;
};
/* Create a new ``struct gdbarch'' based on information provided by
@@ -430,6 +431,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->infcall_munmap = default_infcall_munmap;
gdbarch->gcc_target_options = default_gcc_target_options;
gdbarch->gnu_triplet_regexp = default_gnu_triplet_regexp;
+ gdbarch->addressable_memory_unit_size = default_addressable_memory_unit_size;
/* gdbarch_alloc() */
return gdbarch;
@@ -663,6 +665,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of infcall_munmap, invalid_p == 0 */
/* Skip verify of gcc_target_options, invalid_p == 0 */
/* Skip verify of gnu_triplet_regexp, invalid_p == 0 */
+ /* Skip verify of addressable_memory_unit_size, invalid_p == 0 */
buf = ui_file_xstrdup (log, &length);
make_cleanup (xfree, buf);
if (length > 0)
@@ -714,6 +717,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: address_to_pointer = <%s>\n",
host_address_to_string (gdbarch->address_to_pointer));
fprintf_unfiltered (file,
+ "gdbarch_dump: addressable_memory_unit_size = <%s>\n",
+ host_address_to_string (gdbarch->addressable_memory_unit_size));
+ fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_adjust_breakpoint_address_p() = %d\n",
gdbarch_adjust_breakpoint_address_p (gdbarch));
fprintf_unfiltered (file,
@@ -4730,6 +4736,23 @@ set_gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch,
gdbarch->gnu_triplet_regexp = gnu_triplet_regexp;
}
+int
+gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->addressable_memory_unit_size != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_addressable_memory_unit_size called\n");
+ return gdbarch->addressable_memory_unit_size (gdbarch);
+}
+
+void
+set_gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch,
+ gdbarch_addressable_memory_unit_size_ftype addressable_memory_unit_size)
+{
+ gdbarch->addressable_memory_unit_size = addressable_memory_unit_size;
+}
+
/* Keep a registry of per-architecture data-pointers required by GDB
modules. */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index d2ccd2a..7d6a0cf 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1466,6 +1466,14 @@ typedef const char * (gdbarch_gnu_triplet_regexp_ftype) (struct gdbarch *gdbarch
extern const char * gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch);
extern void set_gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch, gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp);
+/* Return the size in 8-bit bytes of an addressable memory unit on this
+ architecture. This corresponds to the number of 8-bit bytes associated to
+ each address in memory. */
+
+typedef int (gdbarch_addressable_memory_unit_size_ftype) (struct gdbarch *gdbarch);
+extern int gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch);
+extern void set_gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch, gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size);
+
/* Definition for an unknown syscall, used basically in error-cases. */
#define UNKNOWN_SYSCALL (-1)
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index a3c903e..6c5d684 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -1113,6 +1113,12 @@ m:char *:gcc_target_options:void:::default_gcc_target_options::0
# returns the BFD architecture name, which is correct in nearly every
# case.
m:const char *:gnu_triplet_regexp:void:::default_gnu_triplet_regexp::0
+
+# Return the size in 8-bit bytes of an addressable memory unit on this
+# architecture. This corresponds to the number of 8-bit bytes associated to
+# each address in memory.
+m:int:addressable_memory_unit_size:void:::default_addressable_memory_unit_size::0
+
EOF
}
--
2.1.4
next prev parent reply other threads:[~2015-06-12 20:54 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 19:47 [PATCH v2 0/7] Support reading/writing memory on architectures with non 8-bits addressable memory Simon Marchi
2015-04-15 19:47 ` [PATCH v2 5/7] target: consider addressable unit size when reading/writing memory Simon Marchi
2015-05-21 17:46 ` Pedro Alves
2015-06-12 21:07 ` Simon Marchi
2015-04-15 19:47 ` [PATCH v2 1/7] Various cleanups in target read/write code Simon Marchi
2015-05-21 17:45 ` Pedro Alves
2015-06-12 17:09 ` Simon Marchi
2015-04-15 19:47 ` [PATCH v2 3/7] Clarify doc about memory read/write and non-8-bits addressable memory unit sizes Simon Marchi
2015-04-16 14:48 ` Eli Zaretskii
2015-06-12 20:28 ` Simon Marchi
2015-06-13 6:49 ` Eli Zaretskii
2015-06-15 17:40 ` Simon Marchi
2015-06-15 18:09 ` Eli Zaretskii
2015-06-15 19:38 ` Simon Marchi
2015-04-15 19:48 ` [PATCH v2 6/7] remote: consider addressable unit size when reading/writing memory Simon Marchi
2015-05-21 17:48 ` Pedro Alves
2015-06-15 19:28 ` Simon Marchi
2015-06-17 11:55 ` Pedro Alves
2015-06-18 17:14 ` Simon Marchi
2015-04-15 19:48 ` [PATCH v2 2/7] Cleanup some docs about memory write Simon Marchi
2015-05-21 17:45 ` Pedro Alves
2015-06-12 19:17 ` Simon Marchi
2015-06-15 9:57 ` Pedro Alves
2015-06-15 17:36 ` Simon Marchi
2015-04-15 19:48 ` [PATCH v2 4/7] gdbarch: add addressable_memory_unit_size method Simon Marchi
2015-05-21 17:46 ` Pedro Alves
2015-06-12 20:54 ` Simon Marchi [this message]
2015-04-15 19:48 ` [PATCH v2 7/7] MI: consider addressable unit size when reading/writing memory Simon Marchi
2015-05-21 17:52 ` Pedro Alves
2015-06-15 19:51 ` Simon Marchi
2015-05-21 17:44 ` [PATCH v2 0/7] Support reading/writing memory on architectures with non 8-bits addressable memory Pedro Alves
2015-06-11 21:06 ` Simon Marchi
2015-06-11 21:10 ` Simon Marchi
2015-06-12 12:00 ` 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=557B46EB.5040507@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/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