From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 8/8] Document components.py
Date: Wed, 15 Dec 2021 15:45:13 -0700 [thread overview]
Message-ID: <20211215224513.1626598-9-tom@tromey.com> (raw)
In-Reply-To: <20211215224513.1626598-1-tom@tromey.com>
This adds a comment to document how to update gdbarch.
---
gdb/components.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/gdb/components.py b/gdb/components.py
index c854a008a50..36ec45ce531 100644
--- a/gdb/components.py
+++ b/gdb/components.py
@@ -17,7 +17,58 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
+# How to add to gdbarch:
+#
+# There are four kinds of fields in gdbarch:
+# * Info - you should never need this; it is only for things that
+# are copied directly from the gdbarch_info.
+# * Value - a variable.
+# * Function - a function pointer.
+# * Method - a function pointer, but the function takes a gdbarch
+# as its first parameter.
+#
+# You construct a new one with a call to one of those functions. So,
+# for instance, you can use the function named "Value" to make a new
+# Value.
+#
+# All parameters are keyword-only. This is done to help catch typos.
+#
+# Some parameters are shared among all types (including Info):
+# * "name" - required, the name of the field.
+# * "return_type" - required, the type of the field.
+# For functions and methods, this is the return type.
+# * "printer" - an expression to turn this field into a 'const char *'.
+# This is used for dumping. The string must live long enough
+# to be passed to printf.
+#
+# Value, Function, and Method share some more parameters:
+# * "comment" - a comment that's written to the .h file.
+# Please always use this. (It isn't currently
+# a required option for historical reasons.)
+# * "predicate" - a boolean, if True then a _p predicate function
+# will be generated.
+# * "predefault" - a string (or None, but normally you should leave
+# it unspecified) that is used to set the field's
+# initial value.
+# * "postdefault" - a string (or None, but normally you should leave
+# it unspecified). If this is specified, and if the
+# field is invalid after initialization (see "invalid"
+# to understand this), then the field will be reset to
+# the "postdefault" value.
+# * "invalid" - a string, or True or False (or None, etc).
+# If a string, it is an expression to check the
+# validity of this field. If False, no validity
+# checking will be done. If True, then the default
+# validity checking will be done -- this means
+# comparing the value to the "predefault".
+#
+# Function and Method share:
+# * "params" - a tuple of tuples. Each inner tuple is a pair
+# of the form (TYPE, NAME), where TYPE is the
+# type of this argument, and NAME is the name.
+# Note that while the names could be auto-generated,
+# this approach lets the "comment" field refer to
+# arguments in a nicer way.
Info(
name="bfd_arch_info",
--
2.31.1
next prev parent reply other threads:[~2021-12-15 22:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 22:45 [PATCH 0/8] Rewrite gdbarch.sh in Python Tom Tromey
2021-12-15 22:45 ` [PATCH 1/8] Move ordinary gdbarch code to arch-utils Tom Tromey
2021-12-15 22:45 ` [PATCH 2/8] Split gdbarch.h into two files Tom Tromey
2021-12-15 22:45 ` [PATCH 3/8] Do not generate gdbarch.h Tom Tromey
2021-12-15 22:45 ` [PATCH 4/8] Do not sort the fields in gdbarch_dump Tom Tromey
2021-12-15 22:45 ` [PATCH 5/8] Generate new components.py from gdbarch.sh Tom Tromey
2021-12-16 1:31 ` Simon Marchi
2021-12-16 18:46 ` Tom Tromey
2021-12-17 16:41 ` Simon Marchi
2021-12-15 22:45 ` [PATCH 6/8] Add new gdbarch generator Tom Tromey
2021-12-16 2:01 ` Simon Marchi
2021-12-16 18:56 ` Tom Tromey
2021-12-16 18:57 ` Tom Tromey
2021-12-16 19:03 ` Tom Tromey
2021-12-15 22:45 ` [PATCH 7/8] Remove gdbarch.sh Tom Tromey
2021-12-15 22:45 ` Tom Tromey [this message]
2021-12-16 1:46 ` [PATCH 8/8] Document components.py Simon Marchi
2021-12-16 20:19 ` Tom Tromey
2021-12-16 18:02 ` [PATCH 0/8] Rewrite gdbarch.sh in Python John Baldwin
2021-12-16 19:13 ` Tom Tromey
2021-12-17 19:23 ` John Baldwin
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=20211215224513.1626598-9-tom@tromey.com \
--to=tom@tromey.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).