public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [PATCH] [gdb] adds several headers to the include list
@ 2022-07-20  6:01 Christopher Di Bella
  2022-07-20  6:04 ` Christopher Di Bella
  2022-07-20 14:21 ` Simon Marchi
  0 siblings, 2 replies; 8+ messages in thread
From: Christopher Di Bella @ 2022-07-20  6:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: manojgupta, Christopher Di Bella

Building GDB currently fails to build with libc++, because libc++ is
stricter about which headers "leak" entities they're not guaranteed
to support. The following headers have been added:

* `<iterator>`, to support `std::back_insert_iterator`
* `<utility>`, to support `std::move` and `std::swap`
* `<vector>`, to support `std::vector`
---
 gdb/value.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/value.c b/gdb/value.c
index 022fca91a42..c9bec678d95 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -40,6 +40,9 @@
 #include "cp-abi.h"
 #include "user-regs.h"
 #include <algorithm>
+#include <iterator>
+#include <utility>
+#include <vector>
 #include "completer.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/array-view.h"
-- 
2.37.0.170.g444d1eabd0-goog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PATCH] [gdb] adds several headers to the include list
  2022-07-20  6:01 [PATCH] [PATCH] [gdb] adds several headers to the include list Christopher Di Bella
@ 2022-07-20  6:04 ` Christopher Di Bella
  2022-07-20 14:21 ` Simon Marchi
  1 sibling, 0 replies; 8+ messages in thread
From: Christopher Di Bella @ 2022-07-20  6:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: manojgupta, Enze Li, simark, aburgess

This is an updated version of '[PATCH] [PATCH] [gdb] adds several headers
to the include list'.

On Tue, 19 Jul 2022 at 23:01, Christopher Di Bella <cjdb@google.com> wrote:

> Building GDB currently fails to build with libc++, because libc++ is
> stricter about which headers "leak" entities they're not guaranteed
> to support. The following headers have been added:
>
> * `<iterator>`, to support `std::back_insert_iterator`
> * `<utility>`, to support `std::move` and `std::swap`
> * `<vector>`, to support `std::vector`
> ---
>  gdb/value.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/gdb/value.c b/gdb/value.c
> index 022fca91a42..c9bec678d95 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -40,6 +40,9 @@
>  #include "cp-abi.h"
>  #include "user-regs.h"
>  #include <algorithm>
> +#include <iterator>
> +#include <utility>
> +#include <vector>
>  #include "completer.h"
>  #include "gdbsupport/selftest.h"
>  #include "gdbsupport/array-view.h"
> --
> 2.37.0.170.g444d1eabd0-goog
>
>

-- 
Kind regards,

Christopher Di Bella (he/him/his)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PATCH] [gdb] adds several headers to the include list
  2022-07-20  6:01 [PATCH] [PATCH] [gdb] adds several headers to the include list Christopher Di Bella
  2022-07-20  6:04 ` Christopher Di Bella
@ 2022-07-20 14:21 ` Simon Marchi
  2022-07-20 15:42   ` Christopher Di Bella
  1 sibling, 1 reply; 8+ messages in thread
From: Simon Marchi @ 2022-07-20 14:21 UTC (permalink / raw)
  To: Christopher Di Bella, gdb-patches; +Cc: manojgupta



On 2022-07-20 02:01, Christopher Di Bella via Gdb-patches wrote:
> Building GDB currently fails to build with libc++, because libc++ is
> stricter about which headers "leak" entities they're not guaranteed
> to support. The following headers have been added:
> 
> * `<iterator>`, to support `std::back_insert_iterator`

I don't see any use of back_insert_iterator, I guess you mean back_inserter.

I pushed the patch with that fixed, thanks.

Simon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PATCH] [gdb] adds several headers to the include list
  2022-07-20 14:21 ` Simon Marchi
@ 2022-07-20 15:42   ` Christopher Di Bella
  2022-07-21 17:41     ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Di Bella @ 2022-07-20 15:42 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, manojgupta

Right, back_inserter's return type is back_insert_iterator and I mixed
the two up. Thanks for correcting it and merging!

On Wed, 20 Jul 2022 at 07:21, Simon Marchi <simark@simark.ca> wrote:

>
>
> On 2022-07-20 02:01, Christopher Di Bella via Gdb-patches wrote:
> > Building GDB currently fails to build with libc++, because libc++ is
> > stricter about which headers "leak" entities they're not guaranteed
> > to support. The following headers have been added:
> >
> > * `<iterator>`, to support `std::back_insert_iterator`
>
> I don't see any use of back_insert_iterator, I guess you mean
> back_inserter.
>
> I pushed the patch with that fixed, thanks.
>
> Simon
>


-- 
Kind regards,

Christopher Di Bella (he/him/his)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PATCH] [gdb] adds several headers to the include list
  2022-07-20 15:42   ` Christopher Di Bella
@ 2022-07-21 17:41     ` Pedro Alves
  2022-07-22 18:46       ` Manoj Gupta
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2022-07-21 17:41 UTC (permalink / raw)
  To: Christopher Di Bella, Simon Marchi; +Cc: manojgupta, gdb-patches

> diff --git a/gdb/value.c b/gdb/value.c
> index 022fca91a42..c9bec678d95 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -40,6 +40,9 @@
>  #include "cp-abi.h"
>  #include "user-regs.h"
>  #include <algorithm>
> +#include <iterator>
> +#include <utility>
> +#include <vector>

It seems to me that <vector> should have beeen included in the header (value.h):

 $ grep std::vector value.h
                                 std::vector<value_ref_ptr> *val_chain,
 extern std::vector<value_ref_ptr> value_release_to_mark


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PATCH] [gdb] adds several headers to the include list
  2022-07-21 17:41     ` Pedro Alves
@ 2022-07-22 18:46       ` Manoj Gupta
  2022-07-22 19:26         ` Simon Marchi
  0 siblings, 1 reply; 8+ messages in thread
From: Manoj Gupta @ 2022-07-22 18:46 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Christopher Di Bella, Simon Marchi, gdb-patches

On Thu, Jul 21, 2022 at 10:41 AM Pedro Alves <pedro@palves.net> wrote:

> > diff --git a/gdb/value.c b/gdb/value.c
> > index 022fca91a42..c9bec678d95 100644
> > --- a/gdb/value.c
> > +++ b/gdb/value.c
> > @@ -40,6 +40,9 @@
> >  #include "cp-abi.h"
> >  #include "user-regs.h"
> >  #include <algorithm>
> > +#include <iterator>
> > +#include <utility>
> > +#include <vector>
>
> It seems to me that <vector> should have beeen included in the header
> (value.h):
>
>  $ grep std::vector value.h
>                                  std::vector<value_ref_ptr> *val_chain,
>  extern std::vector<value_ref_ptr> value_release_to_mark
>
> This looks like a pervasive thing in the gdb codebase.
I just quickly grepped for '#include <vector>' for files that have a
"std::vector" in the gdb codebase .

There are 200+ files that use std::vector but do not include <vector> i.e.
they rely on a transitive include through other headers.

Thanks,
Manoj

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PATCH] [gdb] adds several headers to the include list
  2022-07-22 18:46       ` Manoj Gupta
@ 2022-07-22 19:26         ` Simon Marchi
  2022-07-26 23:45           ` Manoj Gupta
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Marchi @ 2022-07-22 19:26 UTC (permalink / raw)
  To: Manoj Gupta, Pedro Alves; +Cc: Christopher Di Bella, gdb-patches


> On Thu, Jul 21, 2022 at 10:41 AM Pedro Alves <pedro@palves.net <mailto:pedro@palves.net>> wrote:
> 
>     > diff --git a/gdb/value.c b/gdb/value.c
>     > index 022fca91a42..c9bec678d95 100644
>     > --- a/gdb/value.c
>     > +++ b/gdb/value.c
>     > @@ -40,6 +40,9 @@
>     >  #include "cp-abi.h"
>     >  #include "user-regs.h"
>     >  #include <algorithm>
>     > +#include <iterator>
>     > +#include <utility>
>     > +#include <vector>
> 
>     It seems to me that <vector> should have beeen included in the header (value.h):
> 
>      $ grep std::vector value.h
>                                      std::vector<value_ref_ptr> *val_chain,
>      extern std::vector<value_ref_ptr> value_release_to_mark
> 
> This looks like a pervasive thing in the gdb codebase.
> I just quickly grepped for '#include <vector>' for files that have a "std::vector" in the gdb codebase .
> 
> There are 200+ files that use std::vector but do not include <vector> i.e. they rely on a transitive include through other headers.
> 
> Thanks,
> Manoj


Indeed, ideally every file would include what it uses.  I don't know
about you, but I don't see that as a big problem though.  The worst that
can happen is that you need to fix some includes when shuffling things.
I don't think that a file relying on a transitive include can lead to
some wrong behavior.

I think the opposite is more annoying though, files including headers
they no longer need to.  Let's say foo.c unnecessarily includes
breakpoint.h, then when changing breakpoint.h, foo.c will unnecessarily
get re-built.  I sometimes run some files through include-what-you-use
[1] and remove the includes it tells me are unnecessary.
Unfortunately, it only works for main source files, it won't tell you
that foo.h unnecessarily includes bar.h.  It might be possible to get it
to work by trying to compile foo.h as a main source file, but that's not
really possible in our context, with how things are done currently.

Simon

[1] https://github.com/include-what-you-use/include-what-you-use

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] [PATCH] [gdb] adds several headers to the include list
  2022-07-22 19:26         ` Simon Marchi
@ 2022-07-26 23:45           ` Manoj Gupta
  0 siblings, 0 replies; 8+ messages in thread
From: Manoj Gupta @ 2022-07-26 23:45 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Pedro Alves, Christopher Di Bella, gdb-patches

On Fri, Jul 22, 2022 at 12:26 PM Simon Marchi <simark@simark.ca> wrote:

>
> > On Thu, Jul 21, 2022 at 10:41 AM Pedro Alves <pedro@palves.net <mailto:
> pedro@palves.net>> wrote:
> >
> >     > diff --git a/gdb/value.c b/gdb/value.c
> >     > index 022fca91a42..c9bec678d95 100644
> >     > --- a/gdb/value.c
> >     > +++ b/gdb/value.c
> >     > @@ -40,6 +40,9 @@
> >     >  #include "cp-abi.h"
> >     >  #include "user-regs.h"
> >     >  #include <algorithm>
> >     > +#include <iterator>
> >     > +#include <utility>
> >     > +#include <vector>
> >
> >     It seems to me that <vector> should have beeen included in the
> header (value.h):
> >
> >      $ grep std::vector value.h
> >                                      std::vector<value_ref_ptr>
> *val_chain,
> >      extern std::vector<value_ref_ptr> value_release_to_mark
> >
> > This looks like a pervasive thing in the gdb codebase.
> > I just quickly grepped for '#include <vector>' for files that have a
> "std::vector" in the gdb codebase .
> >
> > There are 200+ files that use std::vector but do not include <vector>
> i.e. they rely on a transitive include through other headers.
> >
> > Thanks,
> > Manoj
>
>
> Indeed, ideally every file would include what it uses.  I don't know
> about you, but I don't see that as a big problem though.  The worst that
> can happen is that you need to fix some includes when shuffling things.
> I don't think that a file relying on a transitive include can lead to
> some wrong behavior.
>
> I think the opposite is more annoying though, files including headers
> they no longer need to.  Let's say foo.c unnecessarily includes
> breakpoint.h, then when changing breakpoint.h, foo.c will unnecessarily
> get re-built.  I sometimes run some files through include-what-you-use
> [1] and remove the includes it tells me are unnecessary.
> Unfortunately, it only works for main source files, it won't tell you
> that foo.h unnecessarily includes bar.h.  It might be possible to get it
> to work by trying to compile foo.h as a main source file, but that's not
> really possible in our context, with how things are done currently.
>
> I do agree that including unneeded headers is also annoying.
In large projects like Chromium, headers bloat can significantly increase
build times
and is not easy to find out the extraneous ones.

That said, iwyu is a great tool if it can be made to work.


Simon
>
> [1] https://github.com/include-what-you-use/include-what-you-use
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-26 23:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20  6:01 [PATCH] [PATCH] [gdb] adds several headers to the include list Christopher Di Bella
2022-07-20  6:04 ` Christopher Di Bella
2022-07-20 14:21 ` Simon Marchi
2022-07-20 15:42   ` Christopher Di Bella
2022-07-21 17:41     ` Pedro Alves
2022-07-22 18:46       ` Manoj Gupta
2022-07-22 19:26         ` Simon Marchi
2022-07-26 23:45           ` Manoj Gupta

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).