From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Lancelot SIX <lsix@lancelotsix.com>, Pedro Alves <pedro@palves.net>
Cc: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 02/11] gdb: introduce intrusive_list, make thread_info use it
Date: Tue, 22 Jun 2021 20:48:19 -0400 [thread overview]
Message-ID: <b1645cb3-1f58-f8ad-dcef-fbd7d2ae5469@polymtl.ca> (raw)
In-Reply-To: <20210622231319.6hgxooumjnkns7pb@ubuntu.lan>
>> +class IntrusiveListPrinter:
>> + """Print a struct intrusive_list."""
>> +
>> + def __init__(self, val):
>> + self._val = val
>> +
>> + # Type of linked items.
>> + self._item_type = self._val.type.template_argument(0)
>> + self._node_ptr_type = gdb.lookup_type(
>> + f"intrusive_list_node<{self._item_type.tag}>"
>
> Hi,
>
> I do not know what are the compatibility constraints / minimum python
> version required, but f-string do require at least python-3.6. This
> covers all still supported python versions, but there might be distros
> out-there that are not there yet (there are a few of those in this
> file).
Huh... right. It's not clear what we aim to support, I'd like if it was
clearer. But we still support build against Python 2.7, so it would
make sense to try to be compatible with it. I'll switch to using
`"...".format(...)`.
>> + ).pointer()
>> +
>> + # Type of value -> node converter.
>> + self._conv_type = self._val.type.template_argument(1)
>> +
>> + if self._uses_member_node():
>> + # The second template argument of intrusive_member_node is a member
>> + # pointer value. Its value is the offset of the node member in the
>> + # enclosing type.
>> + member_node_ptr = self._conv_type.template_argument(1)
>> + member_node_ptr = member_node_ptr.cast(gdb.lookup_type("int"))
>> + self._member_node_offset = int(member_node_ptr)
>> +
>> + # This is only needed in _as_node_ptr if using a member node. Look it
>> + # up here so we only do it once.
>> + self._char_ptr_type = gdb.lookup_type("char").pointer()
>> +
>> + def display_hint(self):
>> + return "array"
>> +
>> + # Return True if the list items use a node as a member. Return False if
>> + # they use a node as a base class.
>> + def _uses_member_node(self):
>
> The documentation for the function should probably go as a doc string,
> not a comment before the function:
>
> def _uses_member_node(self):
> """ Return True if the list items use a node as a member. Return False
> if they use a node as a base class.
> """
>
> The same remark stands for the other method in this file.
Done.
>> + if self._conv_type.name.startswith("intrusive_member_node<"):
>> + return True
>> + elif self._conv_type.name.startswith("intrusive_base_node<"):
>> + return False
>> + else:
>> + raise RuntimeError(
>> + f"Unexpected intrusive_list value -> node converter type: {self._conv_type.name}"
>> + )
>> +
>> + def to_string(self):
>> + s = f"intrusive list of {self._item_type}"
>> +
>> + if self._uses_member_node():
>> + node_member = self._conv_type.template_argument(1)
>> + s += f", linked through {node_member}"
>> +
>> + return s
>> +
>> + # Given ELEM_PTR, a pointer to a list element, return a pointer to the
>> + # corresponding intrusive_list_node.
>> + def _as_node_ptr(self, elem_ptr):
>> + assert elem_ptr.type.code == gdb.TYPE_CODE_PTR
>> +
>> + if self._uses_member_node():
>> + # Node as a memer: add the member node offset from to the element's
>
> s/memer/member/ ?
Fixed.
I integrated the changes in my local tree.
Simon
PS: when you review, don't hesitate to trim the irrelevant parts of the
diff, it will make your comments easier to find and harder to miss. I
almost missed the last one, especially because it was after your
signature! Still, thank you very much for looking at the various
patches on the list, it's very appreciated.
next prev parent reply other threads:[~2021-06-23 0:49 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 16:56 [PATCH 00/11] Various thread lists optimizations Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 01/11] gdb: introduce iterator_range, remove next_adapter Simon Marchi via Gdb-patches
2021-07-05 15:41 ` Pedro Alves
2021-07-06 19:16 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 02/11] gdb: introduce intrusive_list, make thread_info use it Simon Marchi via Gdb-patches
2021-06-22 23:13 ` Lancelot SIX via Gdb-patches
2021-06-23 0:48 ` Simon Marchi via Gdb-patches [this message]
2021-07-05 15:44 ` Pedro Alves
2021-07-06 19:38 ` Simon Marchi via Gdb-patches
2021-07-06 20:45 ` Simon Marchi via Gdb-patches
2021-07-06 21:04 ` Pedro Alves
2021-07-06 21:38 ` Simon Marchi via Gdb-patches
2021-07-06 21:02 ` Pedro Alves
2021-07-06 21:45 ` Simon Marchi via Gdb-patches
2021-07-07 11:46 ` Pedro Alves
2021-07-07 13:52 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 03/11] gdb: make inferior_list use intrusive_list Simon Marchi via Gdb-patches
2021-07-05 15:44 ` Pedro Alves
2021-07-14 6:34 ` Tom de Vries
2021-07-14 16:11 ` Simon Marchi via Gdb-patches
2021-07-14 20:15 ` [PATCH] gdb: make all_inferiors_safe actually work Simon Marchi via Gdb-patches
2021-07-15 10:15 ` Tom de Vries
2021-07-17 12:54 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 04/11] gdb: use intrusive list for step-over chain Simon Marchi via Gdb-patches
2021-07-05 15:45 ` Pedro Alves
2021-07-06 20:59 ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 05/11] gdb: add setter / getter for thread_info resumed state Simon Marchi via Gdb-patches
2021-07-05 15:45 ` Pedro Alves
2021-06-22 16:56 ` [PATCH 06/11] gdb: make thread_info::suspend private, add getters / setters Simon Marchi via Gdb-patches
2021-07-05 15:45 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 07/11] gdb: maintain per-process-target list of resumed threads with pending wait status Simon Marchi via Gdb-patches
2021-07-05 15:51 ` Pedro Alves
2021-07-06 21:25 ` Simon Marchi via Gdb-patches
2021-07-07 12:01 ` Pedro Alves
2021-07-12 22:28 ` Simon Marchi via Gdb-patches
2021-07-12 22:34 ` Simon Marchi via Gdb-patches
2021-07-13 12:21 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 08/11] gdb: optimize check for resumed threads with pending wait status in maybe_set_commit_resumed_all_targets Simon Marchi via Gdb-patches
2021-07-05 15:51 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 09/11] gdb: optimize selection of resumed thread with pending event Simon Marchi via Gdb-patches
2021-07-05 15:51 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 10/11] gdb: maintain ptid -> thread map, optimize find_thread_ptid Simon Marchi via Gdb-patches
2021-07-05 15:52 ` Pedro Alves
2021-07-06 21:31 ` Simon Marchi via Gdb-patches
2021-07-07 12:13 ` Pedro Alves
2021-06-22 16:57 ` [PATCH 11/11] gdb: optimize all_matching_threads_iterator Simon Marchi via Gdb-patches
2021-07-05 15:52 ` Pedro Alves
2021-07-14 9:40 ` Tom de Vries
2021-07-13 0:47 ` [PATCH 00/11] Various thread lists optimizations Simon Marchi via Gdb-patches
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=b1645cb3-1f58-f8ad-dcef-fbd7d2ae5469@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
--cc=pedro@palves.net \
--cc=simon.marchi@efficios.com \
--cc=simon.marchi@polymtl.ca \
/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