[01/13] Add a new overload of gdb_bfd_sections

Message ID 20200828162349.987-2-tom@tromey.com
State New
Headers show
Series
  • Use gdb_bfd_sections in more places
Related show

Commit Message

Tom Tromey Aug. 28, 2020, 4:23 p.m.
This adds a new overload of gdb_bfd_sections, that accepts a
gdb_bfd_ref_ptr.  This also fixes the formatting of the existing
function, since I happened to notice it was mildly off.

gdb/ChangeLog
2020-08-28  Tom Tromey  <tom@tromey.com>

	* gdb_bfd.h (gdb_bfd_sections): New overload.  Fix formatting of
	existing function.
---
 gdb/ChangeLog |  5 +++++
 gdb/gdb_bfd.h | 10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

-- 
2.17.2

Comments

Simon Marchi Aug. 28, 2020, 4:34 p.m. | #1
On 2020-08-28 12:23 p.m., Tom Tromey wrote:
> This adds a new overload of gdb_bfd_sections, that accepts a

> gdb_bfd_ref_ptr.  This also fixes the formatting of the existing

> function, since I happened to notice it was mildly off.


Ah thanks for fixing the formatting.  I'm confusing different styles for
different code bases I'm working with at the moment :).

> 

> gdb/ChangeLog

> 2020-08-28  Tom Tromey  <tom@tromey.com>

> 

> 	* gdb_bfd.h (gdb_bfd_sections): New overload.  Fix formatting of

> 	existing function.

> ---

>  gdb/ChangeLog |  5 +++++

>  gdb/gdb_bfd.h | 10 ++++++++--

>  2 files changed, 13 insertions(+), 2 deletions(-)

> 

> diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h

> index 0f450567d50..12330970873 100644

> --- a/gdb/gdb_bfd.h

> +++ b/gdb/gdb_bfd.h

> @@ -205,10 +205,16 @@ bool gdb_bfd_get_full_section_contents (bfd *abfd, asection *section,

>  using gdb_bfd_section_iterator = next_iterator<asection>;

>  using gdb_bfd_section_range = next_adapter<asection, gdb_bfd_section_iterator>;

>  

> -static inline

> -gdb_bfd_section_range gdb_bfd_sections (bfd *abfd)

> +static inline gdb_bfd_section_range

> +gdb_bfd_sections (bfd *abfd)

>  {

>    return gdb_bfd_section_range (abfd->sections);

>  }

>  

> +static inline gdb_bfd_section_range

> +gdb_bfd_sections (const gdb_bfd_ref_ptr &abfd)

> +{

> +  return gdb_bfd_section_range (abfd->sections);

> +};

> +


Just to confirm, the point of this is to avoid having to do `.get ()` everywhere?

(it LGTM)

Simon
Tom Tromey Aug. 28, 2020, 7:25 p.m. | #2
Simon> Ah thanks for fixing the formatting.  I'm confusing different styles for
Simon> different code bases I'm working with at the moment :).

It's definitely a pain when you work on more than one code base.
That happened to me when I was at Moz.  Actually the Moz tree itself had
two different styles, which as you can imagine is impossible to get right.

>> +static inline gdb_bfd_section_range

>> +gdb_bfd_sections (const gdb_bfd_ref_ptr &abfd)

>> +{

>> +  return gdb_bfd_section_range (abfd->sections);

>> +};

>> +


Simon> Just to confirm, the point of this is to avoid having to do `.get
Simon> ()` everywhere?

Yeah, it is just a convenience for exactly that reason.

Tom

Patch

diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h
index 0f450567d50..12330970873 100644
--- a/gdb/gdb_bfd.h
+++ b/gdb/gdb_bfd.h
@@ -205,10 +205,16 @@  bool gdb_bfd_get_full_section_contents (bfd *abfd, asection *section,
 using gdb_bfd_section_iterator = next_iterator<asection>;
 using gdb_bfd_section_range = next_adapter<asection, gdb_bfd_section_iterator>;
 
-static inline
-gdb_bfd_section_range gdb_bfd_sections (bfd *abfd)
+static inline gdb_bfd_section_range
+gdb_bfd_sections (bfd *abfd)
 {
   return gdb_bfd_section_range (abfd->sections);
 }
 
+static inline gdb_bfd_section_range
+gdb_bfd_sections (const gdb_bfd_ref_ptr &abfd)
+{
+  return gdb_bfd_section_range (abfd->sections);
+};
+
 #endif /* GDB_BFD_H */