From: Pedro Alves <palves@redhat.com>
To: Christian Biesinger <cbiesinger@google.com>,
Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb/linux-fork: simplify one_fork_p
Date: Mon, 20 Jan 2020 15:13:00 -0000 [thread overview]
Message-ID: <0e37f7a3-1697-6f90-1eab-f3ff94e47807@redhat.com> (raw)
In-Reply-To: <CAPTJ0XFQeAHg8jVZLuhcSh4cdE+jvtfOG2tZRaHDq3zLmDiS3g@mail.gmail.com>
On 1/19/20 4:56 PM, Christian Biesinger via gdb-patches wrote:
> On Sun, Jan 19, 2020 at 11:53 AM Simon Marchi <simon.marchi@polymtl.ca> wrote:
>>
>> On 2020-01-19 11:41 a.m., Christian Biesinger wrote:
>>> On Sun, Jan 19, 2020 at 11:11 AM Simon Marchi <simon.marchi@polymtl.ca> wrote:
>>>>
>>>> Unless I'm missing something, this function is a complicated way of
>>>> saying "fork_list.size () == 1".
>>>
>>> Before C++11, size() wasn't guaranteed to run in constant time, so I
>>> assume the code was written to handle that. But GDB uses C++11, so
>>> this change seems fine.
>>> https://en.cppreference.com/w/cpp/container/list/size
>>
>> Ahh, good point. Although by the time that change was made, we were already
>> using C++11. I don't remember if we had a C++ < 11 phase, but if we did it
>> was very short.
Yes, we had one. It was short. Everyone hated my unique_ptr emulation
so much that we moved quickly to C++11. :-D
>>
>> Thanks for looking at it, I'll push it now.
>
> Ah. it's also possible that whoever wrote the code just assumed that
> size() would run in linear time, of course.
Note, I believe that size() isn't linear when compiled with gcc 4.8,
since the new C++11 ABI was only introduced in GCC 5:
https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/
But I think it's OK to ignore that. Especially for non-hot code like
here. I think it's reasonable to say that if you care about performance,
you'll want to compile with a newer compiler.
I was the one who wrote it (06974e6c05556e), but I don't remember why
I did it that way. Might have been the non-O(1) issue, or it could have been
about blindly C++-fying code without realizing the potential simplification.
I agree that size () == 1 works just as well, assuming C++11 std::list.
Thanks,
Pedro Alves
prev parent reply other threads:[~2020-01-20 15:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-19 16:18 Simon Marchi
2020-01-19 16:53 ` Christian Biesinger via gdb-patches
2020-01-19 16:57 ` Simon Marchi
2020-01-19 17:01 ` Christian Biesinger via gdb-patches
2020-01-20 15:13 ` Pedro Alves [this message]
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=0e37f7a3-1697-6f90-1eab-f3ff94e47807@redhat.com \
--to=palves@redhat.com \
--cc=cbiesinger@google.com \
--cc=gdb-patches@sourceware.org \
--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