public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* Re: Libabigail release (was: [PATCH v1 00/11] Refactor abg-writer)
  2019-01-01  0:00       ` Libabigail release (was: [PATCH v1 00/11] Refactor abg-writer) Matthias Maennich via libabigail
@ 2019-01-01  0:00         ` Mark Wielaard
  0 siblings, 0 replies; 17+ messages in thread
From: Mark Wielaard @ 2019-01-01  0:00 UTC (permalink / raw)
  To: Matthias Maennich, Dodji Seketeli; +Cc: libabigail, kernel-team

Hi,

On Tue, 2019-05-28 at 09:11 +0100, Matthias Maennich via libabigail
wrote:
> Thanks for letting me know. Indeed, the version now being master
> contains quite
> a lot of new things that I could use in an officially released
> version. But I
> also agree that we should address the `anonymous struct`
> indeterminism first.
> Do you know whether this is something newly introduced after the 1.6
> release?
> Or has this been seen/reported before?

Since it seems to be non-deterministic we don't really know :)
I suspect the issue(s) were latent and might just have been exposed
because we have more and better tests now.

But looking at the buildbot results it seems to have started early
April. Somewhere after the following fixes landed:
https://sourceware.org/bugzilla/show_bug.cgi?id=24410#c2

Since then the buildbot has reported spurious failures.
There have been several commits since then to address the issue. And we
thought it was fixed. But there is still very occasionally some
unexplained failure. I suspect it is some unstable sort or comparison
somewhere. But it is subtle and doesn't trigger often.

See https://builder.wildebeest.org/buildbot/#/builders?tags=libabigail
for the last 15 changes * 9 arches that the buildbot runs only 3 out of
135 failed.

One on x86_64 with FAIL: runtestannotate.
One on s390x with FAIL: runtestreaddwarf.
And one on ppc64 with FAIL: runtestannotate.

They all look somewhat similar. They start with an __anonymous_union__
that has a different type-id-nnn than expected.

Cheers,

Mark

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

* [PATCH v1 01/11] abg-writer: Simplify 'annotate' propagation
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (9 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 07/11] abidw: Consolidate setting options Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 02/11] Add deprecation facilities Matthias Maennich via libabigail
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

'annotate' is one of many flags that could potentially influence the
way, output is written. Remove the default parameter from
write_context's constructor and let users explicitely set that flag on
the context.

	* src/abg-writer.cc (write_context): remove 'annotate' parameter and
	adjust call sites in the various 'write_*' and 'dump' functions

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 src/abg-writer.cc | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 89f0822dd3b3..83ea3b30d9fa 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -188,11 +188,11 @@ public:
   /// @param env the enviroment we are operating from.
   ///
   /// @param os the output stream to write to.
-  write_context(const environment* env, ostream& os, const bool annotate = false)
+  write_context(const environment* env, ostream& os)
     : m_env(env),
       m_id_manager(env),
       m_ostream(os),
-      m_annotate(annotate),
+      m_annotate(false),
       m_show_locs(true)
   {}
 
@@ -1715,8 +1715,7 @@ write_context_sptr
 create_write_context(const environment *env,
 		     ostream& default_output_stream)
 {
-  write_context_sptr ctxt(new write_context(env, default_output_stream,
-					    /*annotate=*/false));
+  write_context_sptr ctxt(new write_context(env, default_output_stream));
   return ctxt;
 }
 
@@ -1938,7 +1937,8 @@ write_translation_unit(const translation_unit&	tu,
 		       std::ostream&		out,
 		       const bool		annotate)
 {
-  write_context ctxt(tu.get_environment(), out, annotate);
+  write_context ctxt(tu.get_environment(), out);
+  set_annotate(ctxt, annotate);
   return write_translation_unit(tu, ctxt, indent);
 }
 
@@ -4169,7 +4169,8 @@ write_corpus(const corpus_sptr	corpus,
   if (!corpus)
     return false;
 
-  write_context ctxt(corpus->get_environment(), out, annotate);
+  write_context ctxt(corpus->get_environment(), out);
+  set_annotate(ctxt, annotate);
 
   return write_corpus(corpus, indent, ctxt);
 }
@@ -4248,7 +4249,8 @@ write_corpus_group(const corpus_group_sptr&	group,
   if (!group)
     return false;
 
-  write_context ctxt(group->get_environment(), out, annotate);
+  write_context ctxt(group->get_environment(), out);
+  set_annotate(ctxt, annotate);
 
   return write_corpus_group(group, indent, ctxt);
 }
@@ -4315,7 +4317,8 @@ using namespace abigail::ir;
 void
 dump(const decl_base_sptr d, std::ostream& o, const bool annotate)
 {
-  xml_writer::write_context ctxt(d->get_environment(), o, annotate);
+  xml_writer::write_context ctxt(d->get_environment(), o);
+  xml_writer::set_annotate(ctxt, annotate);
   write_decl(d, ctxt, /*indent=*/0);
   o << "\n";
 }
@@ -4359,7 +4362,8 @@ dump(const type_base_sptr t, const bool annotate)
 void
 dump(const var_decl_sptr v, std::ostream& o, const bool annotate)
 {
-  xml_writer::write_context ctxt(v->get_environment(), o, annotate);
+  xml_writer::write_context ctxt(v->get_environment(), o);
+  xml_writer::set_annotate(ctxt, annotate);
   write_var_decl(v, ctxt, /*linkage_name*/true, /*indent=*/0);
   cerr << "\n";
 }
@@ -4383,7 +4387,8 @@ dump(const var_decl_sptr v, const bool annotate)
 void
 dump(const translation_unit& t, std::ostream& o, const bool annotate)
 {
-  xml_writer::write_context ctxt(t.get_environment(), o, annotate);
+  xml_writer::write_context ctxt(t.get_environment(), o);
+  xml_writer::set_annotate(ctxt, annotate);
   write_translation_unit(t, ctxt, /*indent=*/0);
   o << "\n";
 }
-- 
2.21.0.1020.gf2820cf01a-goog

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

* Libabigail release (was: [PATCH v1 00/11] Refactor abg-writer)
  2019-01-01  0:00     ` Dodji Seketeli
@ 2019-01-01  0:00       ` Matthias Maennich via libabigail
  2019-01-01  0:00         ` Mark Wielaard
  0 siblings, 1 reply; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: libabigail, kernel-team

Hi Dodji!

On Thu, May 23, 2019 at 06:41:16PM +0200, Dodji Seketeli wrote:
> > Speaking of which, what would be the criteria for releasing current
> > master as a new version?
> 
> There is no hard criteria :-) It really is whenever we feel that what we
> have at the moment is solid enough to be rolled out basically :-) For
> instance, I'd still like to see the heisengbugs that appear
> intermittently to be fixed :( But if there is a consensus or a user
> feeling strongly that we'd need to release, then, so will it be.  We
> really try to be "plastic" in how we move forward.
> 
Thanks for letting me know. Indeed, the version now being master contains quite
a lot of new things that I could use in an officially released version. But I
also agree that we should address the `anonymous struct` indeterminism first.
Do you know whether this is something newly introduced after the 1.6 release?
Or has this been seen/reported before?

> I hope this helps.
Definitely! Thanks!

-- 
Cheers,
Matthias

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

* Re: [PATCH v1 00/11] Refactor abg-writer
  2019-01-01  0:00 ` [PATCH v1 00/11] Refactor abg-writer Dodji Seketeli
@ 2019-01-01  0:00   ` Matthias Maennich via libabigail
  2019-01-01  0:00     ` Dodji Seketeli
  0 siblings, 1 reply; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: libabigail, kernel-team

Hi Dodji!

On Wed, May 22, 2019 at 02:32:12PM +0200, Dodji Seketeli wrote:
> Hello Matthias,
> 
> 
> Thank you for this patch series!
> 
> It looks good to me so I have applied it to master.
> 
> I have however picked a few nits here and there and applied some very
> slightly modified versions of the patches.
> 
> Please find below the detail of my comments.
> 

Thanks for applying it right away with all the useful additions!

[...]

> I have also mentioned the names of the changed functions in the
> ChangeLog, following the (GNU) conventions referred to int he
> COMMIT-LOG-GUIDLINES file at
> https://sourceware.org/git/gitweb.cgi?p=libabigail.git;a=blob;f=COMMIT-LOG-GUIDELINES.
> 

Especially thanks for cleaning up the ChangeLogs. I tried to follow the rules,
but I guess I need to read that part again more carefully. :-)

I also saw you accepting the 'breaking' change that drops compatibility with
previous libabigail versions. I assume, the next version will have to bump the
major version then. Speaking of which, what would be the criteria for releasing
current master as a new version?

-- 
Cheers,
Matthias

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

* [PATCH v1 06/11] write_context: allow mutating the ostream used
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (6 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 03/11] abg-writer: Refactor write_translation_unit API Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 11/11] abg-writer: drop deprecated API Matthias Maennich via libabigail
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Allowing the mutation of the ostream, allows heavy reuse of the
write_context as this is the distinction in most places where
write_context is used.

Hence, fixup various users of write_context and use common objects where
applicable.

	* include/abg-writer.h: add declaration set_ostream(write_context&, ostream&)
	* src/abg-writer.cc: Likewise add the definitions.
	* tools/abidw.cc: Use the feature of mutating the ostream and
	reuse the write_context in most cases.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h |  3 +++
 src/abg-writer.cc    | 27 ++++++++++++++++++++++++---
 tools/abidw.cc       | 29 ++++++++++++-----------------
 3 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index 45303e42bb15..dddb554112e3 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -53,6 +53,9 @@ set_show_locs(write_context& ctxt, bool flag);
 void
 set_annotate(write_context& ctxt, bool flag);
 
+void
+set_ostream(write_context& ctxt, ostream& os);
+
 bool
 write_translation_unit(write_context&	       ctxt,
 		       const translation_unit& tu,
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 8280e2342a56..d67e64fff22d 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -162,7 +162,7 @@ class write_context
   const environment*			m_env;
   id_manager				m_id_manager;
   config				m_config;
-  ostream&				m_ostream;
+  ostream*				m_ostream;
   bool					m_annotate;
   bool					m_show_locs;
   mutable type_ptr_map			m_type_id_map;
@@ -191,7 +191,7 @@ public:
   write_context(const environment* env, ostream& os)
     : m_env(env),
       m_id_manager(env),
-      m_ostream(os),
+      m_ostream(&os),
       m_annotate(false),
       m_show_locs(true)
   {}
@@ -207,9 +207,19 @@ public:
   get_config() const
   {return m_config;}
 
+  /// Getter for the current ostream
+  ///
+  /// @return a reference to the current ostream
   ostream&
   get_ostream()
-  {return m_ostream;}
+  {return *m_ostream;}
+
+  /// Setter for the current ostream
+  ///
+  /// @param os the new ostream
+  void
+  set_ostream(ostream& os)
+  {m_ostream = &os;}
 
   /// Getter of the annotation option.
   ///
@@ -1742,6 +1752,17 @@ void
 set_annotate(write_context& ctxt, bool flag)
 {ctxt.set_annotate(flag);}
 
+/// Set the new ostream.
+///
+/// The ostream refers to the object, writers should stream new output to.
+///
+/// @param ctxt the context to set this to.
+///
+/// @param os the new ostream
+void
+set_ostream(write_context& ctxt, ostream& os)
+{ctxt.set_ostream(os);}
+
 /// Serialize a translation unit to an output stream.
 ///
 /// @param ctxt the context of the serialization.  It contains e.g,
diff --git a/tools/abidw.cc b/tools/abidw.cc
index d47088604603..2ff6cf3d56b8 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -442,15 +442,18 @@ load_corpus_and_write_abixml(char* argv[],
     }
   else
     {
+      const write_context_sptr& write_ctxt
+	  = create_write_context(corp->get_environment(), cout);
+      set_annotate(*write_ctxt, opts.annotate);
+      set_show_locs(*write_ctxt, opts.show_locs);
+
       if (opts.abidiff)
 	{
 	  // Save the abi in abixml format in a temporary file, read
 	  // it back, and compare the ABI of what we've read back
 	  // against the ABI of the input ELF file.
 	  temp_file_sptr tmp_file = temp_file::create();
-	  const write_context_sptr& write_ctxt = create_write_context(
-	      corp->get_environment(), tmp_file->get_stream());
-	  set_annotate(*write_ctxt, opts.annotate);
+	  set_ostream(*write_ctxt, tmp_file->get_stream());
 	  write_corpus(*write_ctxt, corp, 0);
 	  tmp_file->get_stream().flush();
 	  corpus_sptr corp2 =
@@ -494,20 +497,13 @@ load_corpus_and_write_abixml(char* argv[],
 		<< opts.out_file_path << "'\n";
 	      return 1;
 	    }
-	  const write_context_sptr& write_ctxt
-	      = create_write_context(corp->get_environment(), of);
-	  set_show_locs(*write_ctxt, opts.show_locs);
-	  set_annotate(*write_ctxt, opts.annotate);
+	  set_ostream(*write_ctxt, of);
 	  write_corpus(*write_ctxt, corp, 0);
 	  of.close();
 	  return 0;
 	}
       else
 	{
-	  write_context_sptr write_ctxt
-	      = create_write_context(corp->get_environment(), cout);
-	  set_show_locs(*write_ctxt, opts.show_locs);
-	  set_annotate(*write_ctxt, opts.annotate);
 	  exit_code = !write_corpus(*write_ctxt, corp, 0);
 	}
     }
@@ -560,6 +556,10 @@ load_kernel_corpus_group_and_write_abixml(char* argv[],
 
   if (!opts.noout)
     {
+      const xml_writer::write_context_sptr& ctxt
+	  = xml_writer::create_write_context(group->get_environment(), cout);
+      set_annotate(*ctxt, opts.annotate);
+
       if (!opts.out_file_path.empty())
 	{
 	  ofstream of(opts.out_file_path.c_str(), std::ios_base::trunc);
@@ -570,16 +570,11 @@ load_kernel_corpus_group_and_write_abixml(char* argv[],
 		<< opts.out_file_path << "'\n";
 	      return 1;
 	    }
-	  const write_context_sptr& ctxt
-	      = create_write_context(group->get_environment(), of);
-	  set_annotate(*ctxt, opts.annotate);
+	  set_ostream(*ctxt, of);
 	  exit_code = !write_corpus_group(*ctxt, group, 0);
 	}
       else
 	{
-	  const write_context_sptr& ctxt
-	      = create_write_context(group->get_environment(), cout);
-	  set_annotate(*ctxt, opts.annotate);
 	  exit_code = !write_corpus_group(*ctxt, group, 0);
 	}
     }
-- 
2.21.0.1020.gf2820cf01a-goog

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

* Re: [PATCH v1 00/11] Refactor abg-writer
  2019-01-01  0:00   ` Matthias Maennich via libabigail
@ 2019-01-01  0:00     ` Dodji Seketeli
  2019-01-01  0:00       ` Libabigail release (was: [PATCH v1 00/11] Refactor abg-writer) Matthias Maennich via libabigail
  0 siblings, 1 reply; 17+ messages in thread
From: Dodji Seketeli @ 2019-01-01  0:00 UTC (permalink / raw)
  To: Matthias Maennich; +Cc: libabigail, kernel-team

Hello Matthias,

Matthias Maennich <maennich@google.com> a écrit:


>> Thank you for this patch series!

My pleasure!

> I also saw you accepting the 'breaking' change that drops compatibility with
> previous libabigail versions.

Well, we don't really commit to any API compatibility for now, because I
feel that we still have many things in flux (API-wise) so we are still
figuring things out.  Also, most of the users of Libabigail seem to be
using the command line tools, not the library directly.  So I try to
stick with compatibility at the level of the tools for now.  API
compatibility will come, I guess, when we feel we have users who are
more concerned about that, as opposed as seing feature improvements.

> I assume, the next version will have to bump the major version then.

Not necessarily.  We have changed the API in the past in minor versions
and nobody complained.  For now, I think the next version is just going
to be 1.7, unless we find a compelling reason to move to 2.0 :-)

> Speaking of which, what would be the criteria for releasing current
> master as a new version?

There is no hard criteria :-) It really is whenever we feel that what we
have at the moment is solid enough to be rolled out basically :-) For
instance, I'd still like to see the heisengbugs that appear
intermittently to be fixed :( But if there is a consensus or a user
feeling strongly that we'd need to release, then, so will it be.  We
really try to be "plastic" in how we move forward.

I hope this helps.

Cheers,

-- 
		Dodji

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

* [PATCH v1 10/11] abidw: add option to only emit file names (--short-locs)
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 04/11] abg-writer: Refactor write_corpus API Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 00/11] Refactor abg-writer Dodji Seketeli
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 05/11] abg-writer: Refactor write_corpus_group API Matthias Maennich via libabigail
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Various emitted directories contain machine specific information and
therefore break reproducibility of abidw's output across different
build paths.

Hence introduce --short-locs to only emit file names.

Thanks to earlier changes, adding an option boils down to adding it to
set_opts and to the write_context along with some auxiliary functions
for setting and getting.

	* include/abg-writer.h: add set_short_locs and use it within
	set_opts
	* src/abg-writer.cc (write_context): add m_short_locs flag along
	with getters and setters
	(write_*): emit short paths for filenames if asked for
	* tools/abidw.cc: add short-locs option

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h |  4 +++
 src/abg-writer.cc    | 64 ++++++++++++++++++++++++++++++++++++--------
 tools/abidw.cc       |  5 ++++
 3 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index abb89d6785ae..3a1f2f1dcea8 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -62,6 +62,9 @@ set_write_corpus_path(write_context& ctxt, bool flag);
 void
 set_write_comp_dir(write_context& ctxt, bool flag);
 
+void
+set_short_locs(write_context& ctxt, bool flag);
+
 template <typename OPTS>
 void
 set_opts(write_context& ctxt, const OPTS& opts)
@@ -71,6 +74,7 @@ set_opts(write_context& ctxt, const OPTS& opts)
   set_write_architecture(ctxt, opts.write_architecture);
   set_write_corpus_path(ctxt, opts.write_corpus_path);
   set_write_comp_dir(ctxt, opts.write_comp_dir);
+  set_short_locs(ctxt, opts.short_locs);
 }
 
 void
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 452cab4fca3b..d3c85362b488 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -168,6 +168,7 @@ class write_context
   bool					m_write_architecture;
   bool					m_write_corpus_path;
   bool					m_write_comp_dir;
+  bool					m_short_locs;
   mutable type_ptr_map			m_type_id_map;
   mutable type_ptr_set_type		m_emitted_type_set;
   type_ptr_set_type			m_emitted_decl_only_set;
@@ -199,7 +200,8 @@ public:
       m_show_locs(true),
       m_write_architecture(true),
       m_write_corpus_path(true),
-      m_write_comp_dir(true)
+      m_write_comp_dir(true),
+      m_short_locs(false)
   {}
 
   /// Getter of the environment we are operating from.
@@ -283,6 +285,19 @@ public:
   set_write_comp_dir(bool f)
   {m_write_comp_dir = f;}
 
+  /// Getter of the short-locs option.
+  ///
+  /// @return true iff short locations shall be emitted
+  bool
+  get_short_locs()
+  {return m_short_locs;}
+
+  /// Setter of the short-locs option
+  ///
+  /// @param f the new value of the flag.
+  void
+  set_short_locs(bool f)
+  {m_short_locs = f;}
 
   /// Getter of the "show-locs" option.
   ///
@@ -792,6 +807,7 @@ static bool write_class_tdecl
 static void	do_indent(ostream&, unsigned);
 static void	do_indent_to_level(write_context&, unsigned, unsigned);
 static unsigned get_indent_to_level(write_context&, unsigned, unsigned);
+static std::string get_filename(const std::string&);
 
 /// Emit nb_whitespaces white spaces into the output stream.
 void
@@ -1108,6 +1124,11 @@ write_location(const location& loc, write_context& ctxt)
 
   ostream &o = ctxt.get_ostream();
 
+  if (ctxt.get_short_locs())
+    {
+      filepath = get_filename(filepath);
+    }
+
   o << " filepath='" << xml::escape_xml_string(filepath) << "'"
     << " line='"     << line     << "'"
     << " column='"   << column   << "'";
@@ -1848,6 +1869,18 @@ void
 set_write_comp_dir(write_context& ctxt, bool flag)
 {ctxt.set_write_comp_dir(flag);}
 
+/// Set the 'short-locs' flag.
+///
+/// When this flag is set then the XML writer will emit only file names
+/// rather than full paths.
+///
+/// @param ctxt the context to set this flag on to.
+///
+/// @param flag the new value of the 'short-locs' flag.
+void
+set_short_locs(write_context& ctxt, bool flag)
+{ctxt.set_short_locs(flag);}
+
 /// Serialize a translation unit to an output stream.
 ///
 /// @param ctxt the context of the serialization.  It contains e.g,
@@ -1877,8 +1910,11 @@ write_translation_unit(write_context&	       ctxt,
   if (tu.get_address_size() != 0)
     o << " address-size='" << static_cast<int>(tu.get_address_size()) << "'";
 
-  if (!tu.get_path().empty())
-    o << " path='" << xml::escape_xml_string(tu.get_path()) << "'";
+  std::string tu_path = tu.get_path();
+  if (ctxt.get_short_locs())
+    tu_path = get_filename(tu_path);
+  if (!tu_path.empty())
+    o << " path='" << xml::escape_xml_string(tu_path) << "'";
 
   if (!tu.get_compilation_dir_path().empty() && ctxt.get_write_comp_dir())
     o << " comp-dir-path='"
@@ -4166,6 +4202,13 @@ write_corpus_to_archive(const corpus_sptr corp, const bool annotate)
 
 #endif //WITH_ZIP_ARCHIVE
 
+static std::string
+get_filename(const std::string& path)
+{
+  size_t pos = path.rfind('/');
+  return path.substr(pos != std::string::npos ? pos + 1 : 0);
+}
+
 /// Serialize an ABI corpus to a single native xml document.  The root
 /// note of the resulting XML document is 'abi-corpus'.
 ///
@@ -4197,15 +4240,14 @@ write_corpus(write_context&	ctxt,
   if (!ctxt.get_write_corpus_path())
     {
       if (member_of_group)
-	{
-	  size_t pos = corpus_path.rfind('/');
-	  corpus_path
-	      = corpus_path.substr(pos != std::string::npos ? pos + 1 : 0);
-	}
+	corpus_path = get_filename(corpus_path);
       else
-	{
-	  corpus_path.clear();
-	}
+	corpus_path.clear();
+    }
+  else
+    {
+      if (ctxt.get_short_locs())
+	corpus_path = get_filename(corpus_path);
     }
   if (!corpus_path.empty())
     out << " path='" << xml::escape_xml_string(corpus_path) << "'";
diff --git a/tools/abidw.cc b/tools/abidw.cc
index e8eaa2a0d230..cf8f6ce0df62 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -97,6 +97,7 @@ struct options
   bool			write_architecture;
   bool			write_corpus_path;
   bool			write_comp_dir;
+  bool			short_locs;
   bool			load_all_types;
   bool			linux_kernel_mode;
   bool			corpus_group_for_linux;
@@ -114,6 +115,7 @@ struct options
       write_architecture(true),
       write_corpus_path(true),
       write_comp_dir(true),
+      short_locs(false),
       load_all_types(),
       linux_kernel_mode(true),
       corpus_group_for_linux(false),
@@ -152,6 +154,7 @@ display_usage(const string& prog_name, ostream& out)
     << "  --no-architecture  do not emit architecture info in the output\n"
     << "  --no-corpus-path  do not take the path to the corpora into account\n"
     << "  --no-show-locs  do not show location information\n"
+    << "  --short-locs  only print filenames rather than paths\n"
     << "  --no-comp-dir-path  do not show compilation path information\n"
     << "  --check-alternate-debug-info <elf-path>  check alternate debug info "
     "of <elf-path>\n"
@@ -260,6 +263,8 @@ parse_command_line(int argc, char* argv[], options& opts)
 	opts.write_corpus_path = false;
       else if (!strcmp(argv[i], "--no-show-locs"))
 	opts.show_locs = false;
+      else if (!strcmp(argv[i], "--short-locs"))
+	opts.short_locs = true;
       else if (!strcmp(argv[i], "--no-comp-dir-path"))
 	opts.write_comp_dir = false;
       else if (!strcmp(argv[i], "--check-alternate-debug-info")
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 07/11] abidw: Consolidate setting options
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (8 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 11/11] abg-writer: drop deprecated API Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 01/11] abg-writer: Simplify 'annotate' propagation Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 02/11] Add deprecation facilities Matthias Maennich via libabigail
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

When setting options meant to be used for the write_context, it is easy
to forget to change all relavant locations. In order to consolidate
that, introduce a set_opts function that sets various known options.

We benefit from earlier refactoring as now the write_context is passed
around to carry options for writers. Hence we can be sure, that if we
set up the context correctly (and do not use deprecated functionality),
the respective write_* function we see the options set in the context.

	* include/abg-writer.h: add set_opts(context, options) function
	* tools/abidw.cc: use the newly introduced set_opts where applicable

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h | 8 ++++++++
 tools/abidw.cc       | 5 ++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index dddb554112e3..071b2075880a 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -53,6 +53,14 @@ set_show_locs(write_context& ctxt, bool flag);
 void
 set_annotate(write_context& ctxt, bool flag);
 
+template <typename OPTS>
+void
+set_opts(write_context& ctxt, const OPTS& opts)
+{
+  set_annotate(ctxt, opts.annotate);
+  set_show_locs(ctxt, opts.show_locs);
+}
+
 void
 set_ostream(write_context& ctxt, ostream& os);
 
diff --git a/tools/abidw.cc b/tools/abidw.cc
index 2ff6cf3d56b8..4d30d75b7529 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -444,8 +444,7 @@ load_corpus_and_write_abixml(char* argv[],
     {
       const write_context_sptr& write_ctxt
 	  = create_write_context(corp->get_environment(), cout);
-      set_annotate(*write_ctxt, opts.annotate);
-      set_show_locs(*write_ctxt, opts.show_locs);
+      set_opts(*write_ctxt, opts);
 
       if (opts.abidiff)
 	{
@@ -558,7 +557,7 @@ load_kernel_corpus_group_and_write_abixml(char* argv[],
     {
       const xml_writer::write_context_sptr& ctxt
 	  = xml_writer::create_write_context(group->get_environment(), cout);
-      set_annotate(*ctxt, opts.annotate);
+      set_opts(*ctxt, opts);
 
       if (!opts.out_file_path.empty())
 	{
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 09/11] abidw: add option to omit the compilation directory
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (3 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 05/11] abg-writer: Refactor write_corpus_group API Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 08/11] Make write_architecture and write_corpus_path flags in the write_context Matthias Maennich via libabigail
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

The compilation directory contains machine specific information
therefore breaks reproducibility of abidw's output across different
build paths. Hence introduce --no-comp-dir-path (as in the xml
attribute). Internally I decided to not carry on the duplication of
'dir' and 'path' and used 'comp_dir'.

Thanks to earlier changes, adding an option boils down to adding it to
set_opts and to the write_context along with some auxiliary functions
for setting and getting.

write_translation_unit uses the flag in the write_context and omits the
comp-dir-path if asked for.

	* include/abg-writer.h: add set_write_comp_dir and use it in
	set_opts
	* src/abg-writer.cc: add m_write_comp_dir and resp. getters and
	setters, (write_translation_unit) teach to respect
	write_comp_dir flag of write_context.
	* tools/abidw.cc: add option to omit the comp-dir-path when
	emitting translation_units

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h |  4 ++++
 src/abg-writer.cc    | 33 +++++++++++++++++++++++++++++++--
 tools/abidw.cc       |  5 +++++
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index fdf407703166..abb89d6785ae 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -59,6 +59,9 @@ set_write_architecture(write_context& ctxt, bool flag);
 void
 set_write_corpus_path(write_context& ctxt, bool flag);
 
+void
+set_write_comp_dir(write_context& ctxt, bool flag);
+
 template <typename OPTS>
 void
 set_opts(write_context& ctxt, const OPTS& opts)
@@ -67,6 +70,7 @@ set_opts(write_context& ctxt, const OPTS& opts)
   set_show_locs(ctxt, opts.show_locs);
   set_write_architecture(ctxt, opts.write_architecture);
   set_write_corpus_path(ctxt, opts.write_corpus_path);
+  set_write_comp_dir(ctxt, opts.write_comp_dir);
 }
 
 void
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 0cf1a11087ee..452cab4fca3b 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -167,6 +167,7 @@ class write_context
   bool					m_show_locs;
   bool					m_write_architecture;
   bool					m_write_corpus_path;
+  bool					m_write_comp_dir;
   mutable type_ptr_map			m_type_id_map;
   mutable type_ptr_set_type		m_emitted_type_set;
   type_ptr_set_type			m_emitted_decl_only_set;
@@ -197,7 +198,8 @@ public:
       m_annotate(false),
       m_show_locs(true),
       m_write_architecture(true),
-      m_write_corpus_path(true)
+      m_write_corpus_path(true),
+      m_write_comp_dir(true)
   {}
 
   /// Getter of the environment we are operating from.
@@ -267,6 +269,21 @@ public:
   set_write_corpus_path(bool f)
   {m_write_corpus_path = f;}
 
+  /// Getter of the comp-dir-path option.
+  ///
+  /// @return true iff compilation dir information shall be emitted
+  bool
+  get_write_comp_dir()
+  {return m_write_comp_dir;}
+
+  /// Setter of the comp-dir-path option
+  ///
+  /// @param f the new value of the flag.
+  void
+  set_write_comp_dir(bool f)
+  {m_write_comp_dir = f;}
+
+
   /// Getter of the "show-locs" option.
   ///
   /// When this option is true then the XML writer emits location
@@ -1819,6 +1836,18 @@ void
 set_write_corpus_path(write_context& ctxt, bool flag)
 {ctxt.set_write_corpus_path(flag);}
 
+/// Set the 'write-comp-dir' flag.
+///
+/// When this flag is set then the XML writer will emit compilation dir
+/// information
+///
+/// @param ctxt the context to set this flag on to.
+///
+/// @param flag the new value of the 'write-comp-dir' flag.
+void
+set_write_comp_dir(write_context& ctxt, bool flag)
+{ctxt.set_write_comp_dir(flag);}
+
 /// Serialize a translation unit to an output stream.
 ///
 /// @param ctxt the context of the serialization.  It contains e.g,
@@ -1851,7 +1880,7 @@ write_translation_unit(write_context&	       ctxt,
   if (!tu.get_path().empty())
     o << " path='" << xml::escape_xml_string(tu.get_path()) << "'";
 
-  if (!tu.get_compilation_dir_path().empty())
+  if (!tu.get_compilation_dir_path().empty() && ctxt.get_write_comp_dir())
     o << " comp-dir-path='"
       << xml::escape_xml_string(tu.get_compilation_dir_path()) << "'";
 
diff --git a/tools/abidw.cc b/tools/abidw.cc
index 5ed87216a125..e8eaa2a0d230 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -96,6 +96,7 @@ struct options
   bool			show_base_name_alt_debug_info_path;
   bool			write_architecture;
   bool			write_corpus_path;
+  bool			write_comp_dir;
   bool			load_all_types;
   bool			linux_kernel_mode;
   bool			corpus_group_for_linux;
@@ -112,6 +113,7 @@ struct options
       show_base_name_alt_debug_info_path(),
       write_architecture(true),
       write_corpus_path(true),
+      write_comp_dir(true),
       load_all_types(),
       linux_kernel_mode(true),
       corpus_group_for_linux(false),
@@ -150,6 +152,7 @@ display_usage(const string& prog_name, ostream& out)
     << "  --no-architecture  do not emit architecture info in the output\n"
     << "  --no-corpus-path  do not take the path to the corpora into account\n"
     << "  --no-show-locs  do not show location information\n"
+    << "  --no-comp-dir-path  do not show compilation path information\n"
     << "  --check-alternate-debug-info <elf-path>  check alternate debug info "
     "of <elf-path>\n"
     << "  --check-alternate-debug-info-base-name <elf-path>  check alternate "
@@ -257,6 +260,8 @@ parse_command_line(int argc, char* argv[], options& opts)
 	opts.write_corpus_path = false;
       else if (!strcmp(argv[i], "--no-show-locs"))
 	opts.show_locs = false;
+      else if (!strcmp(argv[i], "--no-comp-dir-path"))
+	opts.write_comp_dir = false;
       else if (!strcmp(argv[i], "--check-alternate-debug-info")
 	       || !strcmp(argv[i], "--check-alternate-debug-info-base-name"))
 	{
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 11/11] abg-writer: drop deprecated API
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (7 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 06/11] write_context: allow mutating the ostream used Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 07/11] abidw: Consolidate setting options Matthias Maennich via libabigail
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Drop the deprecated overloads for write_translation_unit, write_corpus,
write_corpus_group. Also remove the deprecation facilities as they are
note used anymore.

	* include/abg-fwd.h: drop ABG_DEPRECATED macro
	* include/abg-writer.h: drop deprecated declarations
	* src/abg-writer.cc: drop deprecated definitions

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-fwd.h    |   9 --
 include/abg-writer.h |  44 ---------
 src/abg-writer.cc    | 225 -------------------------------------------
 3 files changed, 278 deletions(-)

diff --git a/include/abg-fwd.h b/include/abg-fwd.h
index e9258008f963..ddec06d8d29c 100644
--- a/include/abg-fwd.h
+++ b/include/abg-fwd.h
@@ -1342,14 +1342,5 @@ dump_decl_location(const decl_base_sptr&);
 #define ABG_ASSERT(cond) do {({bool __abg_cond__ = (cond); assert(__abg_cond__); !!__abg_cond__;});} while (false)
 #endif
 
-/// Define ABG_DEPRECATED to allow marking parts of the API deprecated without
-/// actually removing it. This allows to keep compatible (yet incomplete) APIs
-/// around for a transition period into a major version.
-#ifdef __GNUC__
-#define ABG_DEPRECATED __attribute__((deprecated))
-#else
-#define ABG_DEPRECATED
-#endif
-
 } // end namespace abigail
 #endif // __ABG_IRFWD_H__
diff --git a/include/abg-writer.h b/include/abg-writer.h
index 3a1f2f1dcea8..661c217ac565 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -85,18 +85,6 @@ write_translation_unit(write_context&	       ctxt,
 		       const translation_unit& tu,
 		       const unsigned	       indent);
 
-bool ABG_DEPRECATED
-write_translation_unit(const translation_unit& tu,
-		       unsigned		       indent,
-		       std::ostream&	       out,
-		       const bool	       annotate = false);
-
-bool ABG_DEPRECATED
-write_translation_unit(const translation_unit& tu,
-		       unsigned		       indent,
-		       const string&	       path,
-		       const bool	       annotate = false);
-
 bool
 write_corpus_to_archive(const corpus& corp,
 			const string& path,
@@ -116,43 +104,11 @@ write_corpus(write_context&	ctxt,
 	     unsigned		indent,
 	     bool		member_of_group = false);
 
-bool ABG_DEPRECATED
-write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt);
-
-bool ABG_DEPRECATED
-write_corpus(const corpus_sptr corpus,
-	     unsigned	       indent,
-	     std::ostream&     out,
-	     const bool	       annotate = false);
-
-bool ABG_DEPRECATED
-write_corpus(const corpus_sptr corpus,
-	     unsigned	       indent,
-	     const string&     path,
-	     const bool	       annotate = false);
-
 bool
 write_corpus_group(write_context&	    ctx,
 		   const corpus_group_sptr& group,
 		   unsigned		    indent);
 
-bool ABG_DEPRECATED
-write_corpus_group(const corpus_group_sptr& group,
-		   unsigned		    indent,
-		   write_context&	    ctxt);
-
-bool ABG_DEPRECATED
-write_corpus_group(const corpus_group_sptr& group,
-		   unsigned		    indent,
-		   std::ostream&	    out,
-		   const bool		    annotate = false);
-
-bool ABG_DEPRECATED
-write_corpus_group(const corpus_group_sptr& group,
-		   unsigned		    indent,
-		   const string&	    path,
-		   const bool		    annotate = false);
-
 }// end namespace xml_writer
 }// end namespace abigail
 
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index d3c85362b488..7b664931d819 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -2061,82 +2061,6 @@ write_translation_unit(write_context&	       ctxt,
   return true;
 }
 
-/// Serialize a translation unit to an output stream.
-///
-/// @param tu the translation unit to serialize.
-///
-/// @param indent how many indentation spaces to use during the
-/// serialization.
-///
-/// @param out the output stream to serialize the translation unit to.
-///
-/// @param annotate whether to annotate the output with debug information
-///
-/// @deprecated use write_translation_unit(ctct, tu, indent)
-///
-/// @return true upon successful completion, false otherwise.
-bool ABG_DEPRECATED
-write_translation_unit(const translation_unit& tu,
-		       unsigned		       indent,
-		       std::ostream&	       out,
-		       const bool	       annotate)
-{
-  write_context ctxt(tu.get_environment(), out);
-  set_annotate(ctxt, annotate);
-  return write_translation_unit(ctxt, tu, indent);
-}
-
-/// Serialize a translation unit to a file.
-///
-/// @param tu the translation unit to serialize.
-///
-/// @param indent how many indentation spaces to use during the
-/// serialization.
-///
-/// @param path the file to serialize the translation unit to.
-///
-/// @param annotate whether to annotate the output with debug information
-///
-/// @deprecated use write_translation_unit(ctct, tu, indent)
-///
-/// @return true upon successful completion, false otherwise.
-bool ABG_DEPRECATED
-write_translation_unit(const translation_unit& tu,
-		       unsigned		       indent,
-		       const string&	       path,
-		       const bool	       annotate)
-{
-  bool result = true;
-
-  try
-    {
-      ofstream of(path.c_str(), std::ios_base::trunc);
-      if (!of.is_open())
-	{
-	  cerr << "failed to access " << path << "\n";
-	  return false;
-	}
-
-      write_context ctxt(tu.get_environment(), of);
-      set_annotate(ctxt, annotate);
-      if (!write_translation_unit(ctxt, tu, indent))
-	{
-	  cerr << "failed to access " << path << "\n";
-	  result = false;
-	}
-
-      of.close();
-    }
-  catch(...)
-    {
-      cerr << "failed to write to " << path << "\n";
-      result = false;
-    }
-
-  return result;
-}
-
-
 /// Serialize a pointer to an instance of basic type declaration, into
 /// an output stream.
 ///
@@ -4323,53 +4247,6 @@ write_corpus(write_context&	ctxt,
   return true;
 }
 
-/// Serialize an ABI corpus to a single native xml document.  The root
-/// node of the resulting XML document is 'abi-corpus'.
-///
-/// @param corpus the corpus to serialize.
-///
-/// @param indent the number of white space indentation to use.
-///
-/// @param ctxt the write context to use.
-///
-/// @deprecated: use write_corpus(ctxt, corpus, indent)
-///
-/// @return true upon successful completion, false otherwise.
-bool ABG_DEPRECATED
-write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt)
-{
-  return write_corpus(ctxt, corpus, indent);
-}
-
-/// Serialize an ABI corpus to a single native xml document.  The root
-/// node of the resulting XML document is 'abi-corpus'.
-///
-/// @param corpus the corpus to serialize.
-///
-/// @param indent the number of white space indentation to use.
-///
-/// @param out the output stream to serialize the ABI corpus to.
-///
-/// @param annotate whether ABIXML output should be annotated.
-///
-/// @deprecated: use write_corpus(ctxt, corpus, indent)
-///
-/// @return true upon successful completion, false otherwise.
-bool ABG_DEPRECATED
-write_corpus(const corpus_sptr corpus,
-	     unsigned	       indent,
-	     std::ostream&     out,
-	     const bool	       annotate)
-{
-  if (!corpus)
-    return false;
-
-  write_context ctxt(corpus->get_environment(), out);
-  set_annotate(ctxt, annotate);
-
-  return write_corpus(ctxt, corpus, indent);
-}
-
 /// Serialize an ABI corpus group to a single native xml document.
 /// The root note of the resulting XML document is 'abi-corpus-group'.
 ///
@@ -4422,108 +4299,6 @@ std::ostream& out = ctxt.get_ostream();
   return true;
 }
 
-/// Serialize an ABI corpus group to a single native xml document.
-/// The root note of the resulting XML document is 'abi-corpus-group'.
-///
-/// @param group the corpus group to serialize.
-///
-/// @param indent the number of white space indentation to use.
-///
-/// @param ctxt the write context to use.
-///
-/// @deprecated use write_corpus_group(ctxt, corpus_group, indent)
-///
-/// @return true upon successful completion, false otherwise.
-bool ABG_DEPRECATED
-write_corpus_group(const corpus_group_sptr& group,
-		   unsigned		    indent,
-		   write_context&	    ctxt)
-
-{
-  return write_corpus_group(ctxt, group, indent);
-}
-
-/// Serialize an ABI corpus group to a single native xml document.
-/// The root note of the resulting XML document is 'abi-corpus-group'.
-///
-/// @param group the corpus group to serialize.
-///
-/// @param indent the number of white space indentation to use.
-///
-/// @param out the output stream to serialize the ABI corpus to.
-///
-/// @param annotate whether ABIXML output should be annotated.
-///
-/// @deprecated use write_corpus_group(ctxt, corpus_group, indent)
-///
-/// @return true upon successful completion, false otherwise.
-bool ABG_DEPRECATED
-write_corpus_group(const corpus_group_sptr& group,
-		   unsigned		    indent,
-		   std::ostream&	    out,
-		   const bool		    annotate)
-
-{
-  if (!group)
-    return false;
-
-  write_context ctxt(group->get_environment(), out);
-  set_annotate(ctxt, annotate);
-
-  return write_corpus_group(ctxt, group, indent);
-}
-
-/// Serialize an ABI corpus to a single native xml document.  The root
-/// note of the resulting XML document is 'abi-corpus'.
-///
-/// @param corpus the corpus to serialize.
-///
-/// @param indent the number of white space indentation to use.
-///
-/// @param path the output file to serialize the ABI corpus to.
-///
-/// @param annotate whether ABIXML output should be annotated.
-///
-/// @deprecated: use write_corpus(ctxt, corpus, indent)
-///
-/// @return true upon successful completion, false otherwise.
-bool ABG_DEPRECATED
-write_corpus(const corpus_sptr corpus,
-	     unsigned	       indent,
-	     const string&     path,
-	     const bool	       annotate)
-{
-    bool result = true;
-
-  try
-    {
-      ofstream of(path.c_str(), std::ios_base::trunc);
-      if (!of.is_open())
-	{
-	  cerr << "failed to access " << path << "\n";
-	  return false;
-	}
-
-      const write_context_sptr& ctxt
-	  = create_write_context(corpus->get_environment(), of);
-      ctxt->set_annotate(annotate);
-      if (!write_corpus(*ctxt, corpus, indent))
-	{
-	  cerr << "failed to access " << path << "\n";
-	  result = false;
-	}
-
-      of.close();
-    }
-  catch(...)
-    {
-      cerr << "failed to write to " << path << "\n";
-      result = false;
-    }
-
-  return result;
-}
-
 } //end namespace xml_writer
 
 // <Debugging routines>
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 08/11] Make write_architecture and write_corpus_path flags in the write_context
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (4 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 09/11] abidw: add option to omit the compilation directory Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 03/11] abg-writer: Refactor write_translation_unit API Matthias Maennich via libabigail
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Having write_context carry corresponding flags for output sensitive
command line options, is useful to ensure these options are not lost in
chains for write_* calls. In particular, these options can have various
meanings depending on the context (corpus, corpus_group, etc.)

Hence add them to the write_context along with getters and setters and
make the writers aware of their existence. We do not need to modify the
corpus or corpus group's path or architecture any longer as they get
ignored for a different reason now.

Finally, drop the flag handling in abidw as it is already done via
set_opts, which learned about these new flags.

	* include/abg-writer.h: add declarations set_write_architecture
	and set_write_corpus_path, make write_corpus aware of when
	written as part of a corpus_group
	* src/abg-writer.cc (write_context): add members
	m_write_architecture, m_write_corpus_path along with getters,
	setters and free modification functions.
	* src/abg-writer.cc (write_corpus): add flag to make aware if
	written as part of a group.
	* tools/abidw.cc: drop obsolete option handling

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h | 13 ++++++-
 src/abg-writer.cc    | 93 ++++++++++++++++++++++++++++++++++++++++----
 tools/abidw.cc       | 10 -----
 3 files changed, 97 insertions(+), 19 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index 071b2075880a..fdf407703166 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -53,12 +53,20 @@ set_show_locs(write_context& ctxt, bool flag);
 void
 set_annotate(write_context& ctxt, bool flag);
 
+void
+set_write_architecture(write_context& ctxt, bool flag);
+
+void
+set_write_corpus_path(write_context& ctxt, bool flag);
+
 template <typename OPTS>
 void
 set_opts(write_context& ctxt, const OPTS& opts)
 {
   set_annotate(ctxt, opts.annotate);
   set_show_locs(ctxt, opts.show_locs);
+  set_write_architecture(ctxt, opts.write_architecture);
+  set_write_corpus_path(ctxt, opts.write_corpus_path);
 }
 
 void
@@ -95,7 +103,10 @@ write_corpus_to_archive(const corpus_sptr corp,
 			const bool annotate = false);
 
 bool
-write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent);
+write_corpus(write_context&	ctxt,
+	     const corpus_sptr& corpus,
+	     unsigned		indent,
+	     bool		member_of_group = false);
 
 bool ABG_DEPRECATED
 write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt);
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index d67e64fff22d..0cf1a11087ee 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -165,6 +165,8 @@ class write_context
   ostream*				m_ostream;
   bool					m_annotate;
   bool					m_show_locs;
+  bool					m_write_architecture;
+  bool					m_write_corpus_path;
   mutable type_ptr_map			m_type_id_map;
   mutable type_ptr_set_type		m_emitted_type_set;
   type_ptr_set_type			m_emitted_decl_only_set;
@@ -193,7 +195,9 @@ public:
       m_id_manager(env),
       m_ostream(&os),
       m_annotate(false),
-      m_show_locs(true)
+      m_show_locs(true),
+      m_write_architecture(true),
+      m_write_corpus_path(true)
   {}
 
   /// Getter of the environment we are operating from.
@@ -235,6 +239,34 @@ public:
   set_annotate(bool f)
   {m_annotate = f;}
 
+  /// Getter of the write-architecture option.
+  ///
+  /// @return true iff architecture information shall be emitted
+  bool
+  get_write_architecture()
+  {return m_write_architecture;}
+
+  /// Setter of the write-architecture option
+  ///
+  /// @param f the new value of the flag.
+  void
+  set_write_architecture(bool f)
+  {m_write_architecture = f;}
+
+  /// Getter of the write-corpus-path option.
+  ///
+  /// @return true iff corpus-path information shall be emitted
+  bool
+  get_write_corpus_path()
+  {return m_write_corpus_path;}
+
+  /// Setter of the write-corpus-path option
+  ///
+  /// @param f the new value of the flag.
+  void
+  set_write_corpus_path(bool f)
+  {m_write_corpus_path = f;}
+
   /// Getter of the "show-locs" option.
   ///
   /// When this option is true then the XML writer emits location
@@ -1763,6 +1795,30 @@ void
 set_ostream(write_context& ctxt, ostream& os)
 {ctxt.set_ostream(os);}
 
+/// Set the 'write-architecture' flag.
+///
+/// When this flag is set then the XML writer will emit architecture
+/// information
+///
+/// @param ctxt the context to set this flag on to.
+///
+/// @param flag the new value of the 'write-architecture' flag.
+void
+set_write_architecture(write_context& ctxt, bool flag)
+{ctxt.set_write_architecture(flag);}
+
+/// Set the 'write-corpus-path' flag.
+///
+/// When this flag is set then the XML writer will emit corpus-path
+/// information
+///
+/// @param ctxt the context to set this flag on to.
+///
+/// @param flag the new value of the 'write-corpus-path' flag.
+void
+set_write_corpus_path(write_context& ctxt, bool flag)
+{ctxt.set_write_corpus_path(flag);}
+
 /// Serialize a translation unit to an output stream.
 ///
 /// @param ctxt the context of the serialization.  It contains e.g,
@@ -4092,7 +4148,10 @@ write_corpus_to_archive(const corpus_sptr corp, const bool annotate)
 ///
 /// @return true upon successful completion, false otherwise.
 bool
-write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent)
+write_corpus(write_context&	ctxt,
+	     const corpus_sptr& corpus,
+	     unsigned		indent,
+	     bool		member_of_group)
 {
   if (!corpus)
     return false;
@@ -4102,10 +4161,28 @@ write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent)
   std::ostream& out = ctxt.get_ostream();
 
   out << "<abi-corpus";
-  if (!corpus->get_path().empty())
-    out << " path='" << xml::escape_xml_string(corpus->get_path()) << "'";
 
-  if (!corpus->get_architecture_name().empty())
+  // For an abi-corpus as part of an abi-corpus group, only omit the path, but
+  // keep the filename.
+  std::string corpus_path = corpus->get_path();
+  if (!ctxt.get_write_corpus_path())
+    {
+      if (member_of_group)
+	{
+	  size_t pos = corpus_path.rfind('/');
+	  corpus_path
+	      = corpus_path.substr(pos != std::string::npos ? pos + 1 : 0);
+	}
+      else
+	{
+	  corpus_path.clear();
+	}
+    }
+  if (!corpus_path.empty())
+    out << " path='" << xml::escape_xml_string(corpus_path) << "'";
+
+  if (!corpus->get_architecture_name().empty()
+      && ctxt.get_write_architecture())
     out << " architecture='" << corpus->get_architecture_name()<< "'";
 
   if (!corpus->get_soname().empty())
@@ -4247,10 +4324,10 @@ std::ostream& out = ctxt.get_ostream();
 
   out << "<abi-corpus-group";
 
-  if (!group->get_path().empty())
+  if (!group->get_path().empty() && ctxt.get_write_corpus_path())
     out << " path='" << xml::escape_xml_string(group->get_path()) << "'";
 
-  if (!group->get_architecture_name().empty())
+  if (!group->get_architecture_name().empty() && ctxt.get_write_architecture())
     out << " architecture='" << group->get_architecture_name()<< "'";
 
   if (group->is_empty())
@@ -4266,7 +4343,7 @@ std::ostream& out = ctxt.get_ostream();
 	 group->get_corpora().begin();
        c != group->get_corpora().end();
        ++c)
-    write_corpus(ctxt, *c, get_indent_to_level(ctxt, indent, 1));
+    write_corpus(ctxt, *c, get_indent_to_level(ctxt, indent, 1), true);
 
   do_indent_to_level(ctxt, indent, 0);
   out << "</abi-corpus-group>\n";
diff --git a/tools/abidw.cc b/tools/abidw.cc
index 4d30d75b7529..5ed87216a125 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -481,11 +481,6 @@ load_corpus_and_write_abixml(char* argv[],
       if (opts.noout)
 	return 0;
 
-      if (!opts.write_architecture)
-	corp->set_architecture_name("");
-      if (!opts.write_corpus_path)
-	corp->set_path("");
-
       if (!opts.out_file_path.empty())
 	{
 	  ofstream of(opts.out_file_path.c_str(), std::ios_base::trunc);
@@ -548,11 +543,6 @@ load_kernel_corpus_group_and_write_abixml(char* argv[],
   if (!group)
     return 1;
 
-  if (!opts.write_architecture)
-    group->set_architecture_name("");
-  if (!opts.write_corpus_path)
-    group->set_path("");
-
   if (!opts.noout)
     {
       const xml_writer::write_context_sptr& ctxt
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 03/11] abg-writer: Refactor write_translation_unit API
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (5 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 08/11] Make write_architecture and write_corpus_path flags in the write_context Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 06/11] write_context: allow mutating the ostream used Matthias Maennich via libabigail
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Introduce a new overload for write_translation_unit that follows the
parameter order context, object (i.e. translation unit), indent.

Deprecate all other overloads that were part of the API and mostly
forward them to the new one. That effort is made to ensure write_context
is always provided. write_context allows access to all options that
influence the output format.

	* include/abg-writer.h: Introduce write_translation_unit(ctxt,
	tu, indent) and deprecate all other overloads
	* src/abg-writer.cc: Likewise. Also adjust call sites to use new
	overload.
	* tools/abilint.cc (main): use new write_translation_unit() API

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h | 27 ++++++++++++++--------
 src/abg-writer.cc    | 54 +++++++++++++++++++++++++-------------------
 tools/abilint.cc     | 21 +++++++++++++----
 3 files changed, 65 insertions(+), 37 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index 467f8d0a4b2b..ee245cf75db6 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -29,6 +29,8 @@
 #ifndef __ABG_WRITER_H__
 #define __ABG_WRITER_H__
 
+#include "abg-fwd.h"
+
 namespace abigail
 {
 namespace xml_writer
@@ -52,16 +54,21 @@ void
 set_annotate(write_context& ctxt, bool flag);
 
 bool
-write_translation_unit(const translation_unit&	tu,
-		       unsigned		indent,
-		       std::ostream&		out,
-		       const bool		annotate = false);
-
-bool
-write_translation_unit(const translation_unit&	tu,
-		       unsigned		indent,
-		       const string&		path,
-		       const bool		annotate = false);
+write_translation_unit(write_context&	       ctxt,
+		       const translation_unit& tu,
+		       const unsigned	       indent);
+
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+		       unsigned		       indent,
+		       std::ostream&	       out,
+		       const bool	       annotate = false);
+
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+		       unsigned		       indent,
+		       const string&	       path,
+		       const bool	       annotate = false);
 
 bool
 write_corpus_to_archive(const corpus& corp,
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 83ea3b30d9fa..627a44715807 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -649,8 +649,6 @@ public:
 
 };//end write_context
 
-static bool write_translation_unit(const translation_unit&,
-				   write_context&, unsigned);
 static void write_location(const location&, write_context&);
 static void write_location(const decl_base_sptr&, write_context&);
 static bool write_visibility(const decl_base_sptr&, ostream&);
@@ -1746,19 +1744,19 @@ set_annotate(write_context& ctxt, bool flag)
 
 /// Serialize a translation unit to an output stream.
 ///
-/// @param tu the translation unit to serialize.
-///
 /// @param ctxt the context of the serialization.  It contains e.g,
 /// the output stream to serialize to.
 ///
+/// @param tu the translation unit to serialize.
+///
 /// @param indent how many indentation spaces to use during the
 /// serialization.
 ///
 /// @return true upon successful completion, false otherwise.
-static bool
-write_translation_unit(const translation_unit&	tu,
-		       write_context&		ctxt,
-		       unsigned		indent)
+bool
+write_translation_unit(write_context&	       ctxt,
+		       const translation_unit& tu,
+		       const unsigned	       indent)
 {
   ostream& o = ctxt.get_ostream();
   const config& c = ctxt.get_config();
@@ -1930,16 +1928,20 @@ write_translation_unit(const translation_unit&	tu,
 ///
 /// @param out the output stream to serialize the translation unit to.
 ///
+/// @param annotate whether to annotate the output with debug information
+///
+/// @deprecated use write_translation_unit(ctct, tu, indent)
+///
 /// @return true upon successful completion, false otherwise.
-bool
-write_translation_unit(const translation_unit&	tu,
-		       unsigned		indent,
-		       std::ostream&		out,
-		       const bool		annotate)
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+		       unsigned		       indent,
+		       std::ostream&	       out,
+		       const bool	       annotate)
 {
   write_context ctxt(tu.get_environment(), out);
   set_annotate(ctxt, annotate);
-  return write_translation_unit(tu, ctxt, indent);
+  return write_translation_unit(ctxt, tu, indent);
 }
 
 /// Serialize a translation unit to a file.
@@ -1949,14 +1951,18 @@ write_translation_unit(const translation_unit&	tu,
 /// @param indent how many indentation spaces to use during the
 /// serialization.
 ///
-/// @param out the file to serialize the translation unit to.
+/// @param path the file to serialize the translation unit to.
+///
+/// @param annotate whether to annotate the output with debug information
+///
+/// @deprecated use write_translation_unit(ctct, tu, indent)
 ///
 /// @return true upon successful completion, false otherwise.
-bool
-write_translation_unit(const translation_unit&	tu,
-		       unsigned		indent,
-		       const string&		path,
-		       const bool annotate)
+bool ABG_DEPRECATED
+write_translation_unit(const translation_unit& tu,
+		       unsigned		       indent,
+		       const string&	       path,
+		       const bool	       annotate)
 {
   bool result = true;
 
@@ -1969,7 +1975,9 @@ write_translation_unit(const translation_unit&	tu,
 	  return false;
 	}
 
-      if (!write_translation_unit(tu, indent, of, annotate))
+      write_context ctxt(tu.get_environment(), of);
+      set_annotate(ctxt, annotate);
+      if (!write_translation_unit(ctxt, tu, indent))
 	{
 	  cerr << "failed to access " << path << "\n";
 	  result = false;
@@ -4139,7 +4147,7 @@ write_corpus(const corpus_sptr	corpus,
     {
       translation_unit& tu = **i;
       if (!tu.is_empty())
-	write_translation_unit(tu, ctxt, get_indent_to_level(ctxt, indent, 1));
+	write_translation_unit(ctxt, tu, get_indent_to_level(ctxt, indent, 1));
     }
 
   do_indent_to_level(ctxt, indent, 0);
@@ -4389,7 +4397,7 @@ dump(const translation_unit& t, std::ostream& o, const bool annotate)
 {
   xml_writer::write_context ctxt(t.get_environment(), o);
   xml_writer::set_annotate(ctxt, annotate);
-  write_translation_unit(t, ctxt, /*indent=*/0);
+  write_translation_unit(ctxt, t, /*indent=*/0);
   o << "\n";
 }
 
diff --git a/tools/abilint.cc b/tools/abilint.cc
index 8798a24ec256..fab2e6331c8b 100644
--- a/tools/abilint.cc
+++ b/tools/abilint.cc
@@ -67,6 +67,8 @@ using abigail::xml_reader::read_corpus_from_native_xml;
 using abigail::xml_reader::read_corpus_from_native_xml_file;
 using abigail::dwarf_reader::read_corpus_from_elf;
 using abigail::xml_writer::write_translation_unit;
+using abigail::xml_writer::write_context_sptr;
+using abigail::xml_writer::create_write_context;
 using abigail::xml_writer::write_corpus;
 using abigail::xml_writer::write_corpus_to_archive;
 
@@ -287,7 +289,11 @@ main(int argc, char* argv[])
 	    }
 
 	  if (!opts.noout)
-	    write_translation_unit(*tu, 0, cout);
+	    {
+	      const write_context_sptr& ctxt
+		  = create_write_context(tu->get_environment(), cout);
+	      write_translation_unit(*ctxt, *tu, 0);
+	    }
 	  return 0;
 	}
       else
@@ -411,10 +417,17 @@ main(int argc, char* argv[])
       if (tu)
 	{
 	  if (opts.diff)
-	    r = write_translation_unit(*tu, /*indent=*/0,
-				       tmp_file->get_stream());
+	    {
+	      const write_context_sptr& ctxt = create_write_context(
+		  tu->get_environment(), tmp_file->get_stream());
+	      r = write_translation_unit(*ctxt, *tu, 0);
+	    }
 	  if (!opts.noout && !opts.diff)
-	    r &= write_translation_unit(*tu, /*indent=*/0, cout);
+	    {
+	      const write_context_sptr& ctxt
+		  = create_write_context(tu->get_environment(), cout);
+	      r &= write_translation_unit(*ctxt, *tu, 0);
+	    }
 	}
       else
 	{
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 04/11] abg-writer: Refactor write_corpus API
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 00/11] Refactor abg-writer Dodji Seketeli
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Introduce a new overload for write_corpus that follows the parameter
order context, object (i.e. corpus), indent.

Deprecate all other overloads that were part of the API and mostly
forward them to the new overload. That effort is made to ensure
write_context is always provided. write_context allows access to all
options that influence the output format.

	* include/abg-writer.h: Introduce write_corpus(ctxt, corpus,
	indent) and deprecate all other overloads
	* src/abg-writer.cc: Likewise. Also adjust call sites to use new
	overload.
	* tests/test-read-dwarf.cc: Migrate to new API of write_corpus()
	* tools/abidw.cc: Likewise.
	* tools/abilint.cc: Likewise. Also simplify logic around the
	locations as they now can be expressed with less code.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h     | 27 +++++++++---------
 src/abg-writer.cc        | 61 +++++++++++++++++++++++++++-------------
 tests/test-read-dwarf.cc |  8 ++++--
 tools/abidw.cc           | 29 ++++++++++---------
 tools/abilint.cc         | 48 ++++++++++++-------------------
 5 files changed, 96 insertions(+), 77 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index ee245cf75db6..d93cc69a3452 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -84,21 +84,22 @@ write_corpus_to_archive(const corpus_sptr corp,
 			const bool annotate = false);
 
 bool
-write_corpus(const corpus_sptr	corpus,
-	     unsigned		indent,
-	     write_context&	ctxt);
+write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent);
 
-bool
-write_corpus(const corpus_sptr	corpus,
-	     unsigned		indent,
-	     std::ostream&	out,
-	     const bool	annotate = false);
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt);
 
-bool
-write_corpus(const corpus_sptr	corpus,
-	     unsigned		indent,
-	     const string&	path,
-	     const bool	annotate = false);
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+	     unsigned	       indent,
+	     std::ostream&     out,
+	     const bool	       annotate = false);
+
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+	     unsigned	       indent,
+	     const string&     path,
+	     const bool	       annotate = false);
 
 bool
 write_corpus_group(const corpus_group_sptr&	group,
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 627a44715807..85f3aebc155a 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -4063,17 +4063,15 @@ write_corpus_to_archive(const corpus_sptr corp, const bool annotate)
 /// Serialize an ABI corpus to a single native xml document.  The root
 /// note of the resulting XML document is 'abi-corpus'.
 ///
+/// @param ctxt the write context to use.
+///
 /// @param corpus the corpus to serialize.
 ///
 /// @param indent the number of white space indentation to use.
 ///
-/// @param ctxt the write context to use.
-///
 /// @return true upon successful completion, false otherwise.
 bool
-write_corpus(const corpus_sptr	corpus,
-	     unsigned		indent,
-	     write_context&	ctxt)
+write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent)
 {
   if (!corpus)
     return false;
@@ -4157,7 +4155,25 @@ write_corpus(const corpus_sptr	corpus,
 }
 
 /// Serialize an ABI corpus to a single native xml document.  The root
-/// note of the resulting XML document is 'abi-corpus'.
+/// node of the resulting XML document is 'abi-corpus'.
+///
+/// @param corpus the corpus to serialize.
+///
+/// @param indent the number of white space indentation to use.
+///
+/// @param ctxt the write context to use.
+///
+/// @deprecated: use write_corpus(ctxt, corpus, indent)
+///
+/// @return true upon successful completion, false otherwise.
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt)
+{
+  return write_corpus(ctxt, corpus, indent);
+}
+
+/// Serialize an ABI corpus to a single native xml document.  The root
+/// node of the resulting XML document is 'abi-corpus'.
 ///
 /// @param corpus the corpus to serialize.
 ///
@@ -4167,12 +4183,14 @@ write_corpus(const corpus_sptr	corpus,
 ///
 /// @param annotate whether ABIXML output should be annotated.
 ///
+/// @deprecated: use write_corpus(ctxt, corpus, indent)
+///
 /// @return true upon successful completion, false otherwise.
-bool
-write_corpus(const corpus_sptr	corpus,
-	     unsigned		indent,
-	     std::ostream&	out,
-	     const bool	annotate)
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+	     unsigned	       indent,
+	     std::ostream&     out,
+	     const bool	       annotate)
 {
   if (!corpus)
     return false;
@@ -4180,7 +4198,7 @@ write_corpus(const corpus_sptr	corpus,
   write_context ctxt(corpus->get_environment(), out);
   set_annotate(ctxt, annotate);
 
-  return write_corpus(corpus, indent, ctxt);
+  return write_corpus(ctxt, corpus, indent);
 }
 
 /// Serialize an ABI corpus group to a single native xml document.
@@ -4227,7 +4245,7 @@ std::ostream& out = ctxt.get_ostream();
 	 group->get_corpora().begin();
        c != group->get_corpora().end();
        ++c)
-    write_corpus(*c, get_indent_to_level(ctxt, indent, 1), ctxt);
+    write_corpus(ctxt, *c, get_indent_to_level(ctxt, indent, 1));
 
   do_indent_to_level(ctxt, indent, 0);
   out << "</abi-corpus-group>\n";
@@ -4274,12 +4292,14 @@ write_corpus_group(const corpus_group_sptr&	group,
 ///
 /// @param annotate whether ABIXML output should be annotated.
 ///
+/// @deprecated: use write_corpus(ctxt, corpus, indent)
+///
 /// @return true upon successful completion, false otherwise.
-bool
-write_corpus(const corpus_sptr	corpus,
-	     unsigned		indent,
-	     const string&	path,
-	     const bool	annotate)
+bool ABG_DEPRECATED
+write_corpus(const corpus_sptr corpus,
+	     unsigned	       indent,
+	     const string&     path,
+	     const bool	       annotate)
 {
     bool result = true;
 
@@ -4292,7 +4312,10 @@ write_corpus(const corpus_sptr	corpus,
 	  return false;
 	}
 
-      if (!write_corpus(corpus, indent, of, annotate))
+      const write_context_sptr& ctxt
+	  = create_write_context(corpus->get_environment(), of);
+      ctxt->set_annotate(annotate);
+      if (!write_corpus(*ctxt, corpus, indent))
 	{
 	  cerr << "failed to access " << path << "\n";
 	  result = false;
diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc
index e743e5b6e960..b3be07fec1ec 100644
--- a/tests/test-read-dwarf.cc
+++ b/tests/test-read-dwarf.cc
@@ -46,6 +46,9 @@ using abigail::dwarf_reader::read_corpus_from_elf;
 using abigail::dwarf_reader::read_context;
 using abigail::dwarf_reader::read_context_sptr;
 using abigail::dwarf_reader::create_read_context;
+using abigail::xml_writer::create_write_context;
+using abigail::xml_writer::write_context_sptr;
+using abigail::xml_writer::write_corpus;
 
 /// This is an aggregate that specifies where a test shall get its
 /// input from, and where it shall write its ouput to.
@@ -333,8 +336,9 @@ struct test_task : public abigail::workers::task
 	is_ok = false;
 	return;
       }
-    is_ok =
-      abigail::xml_writer::write_corpus(corp, /*indent=*/0, of);
+    const write_context_sptr write_ctxt
+	= create_write_context(corp->get_environment(), of);
+    is_ok = write_corpus(*write_ctxt, corp, /*indent=*/0);
     of.close();
 
     string abidw = string(get_build_dir()) + "/tools/abidw";
diff --git a/tools/abidw.cc b/tools/abidw.cc
index d86c3607e454..45c0b862aeec 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -69,6 +69,8 @@ using abigail::comparison::corpus_diff_sptr;
 using abigail::comparison::compute_diff;
 using abigail::comparison::diff_context_sptr;
 using abigail::comparison::diff_context;
+using abigail::xml_writer::create_write_context;
+using abigail::xml_writer::write_context_sptr;
 using abigail::xml_writer::write_corpus;
 using abigail::xml_reader::read_corpus_from_native_xml_file;
 using abigail::dwarf_reader::read_context;
@@ -446,7 +448,10 @@ load_corpus_and_write_abixml(char* argv[],
 	  // it back, and compare the ABI of what we've read back
 	  // against the ABI of the input ELF file.
 	  temp_file_sptr tmp_file = temp_file::create();
-	  write_corpus(corp, 0, tmp_file->get_stream(), opts.annotate);
+	  const write_context_sptr& write_ctxt = create_write_context(
+	      corp->get_environment(), tmp_file->get_stream());
+	  set_annotate(*write_ctxt, opts.annotate);
+	  write_corpus(*write_ctxt, corp, 0);
 	  tmp_file->get_stream().flush();
 	  corpus_sptr corp2 =
 	    read_corpus_from_native_xml_file(tmp_file->get_path(),
@@ -489,23 +494,21 @@ load_corpus_and_write_abixml(char* argv[],
 		<< opts.out_file_path << "'\n";
 	      return 1;
 	    }
-	  abigail::xml_writer::write_context_sptr write_ctxt =
-	    abigail::xml_writer::create_write_context(corp->get_environment(),
-						      of);
-	  abigail::xml_writer::set_show_locs(*write_ctxt, opts.show_locs);
-	  abigail::xml_writer::set_annotate(*write_ctxt, opts.annotate);
-	  abigail::xml_writer::write_corpus(corp, 0, *write_ctxt);
+	  const write_context_sptr& write_ctxt
+	      = create_write_context(corp->get_environment(), of);
+	  set_show_locs(*write_ctxt, opts.show_locs);
+	  set_annotate(*write_ctxt, opts.annotate);
+	  write_corpus(*write_ctxt, corp, 0);
 	  of.close();
 	  return 0;
 	}
       else
 	{
-	  abigail::xml_writer::write_context_sptr write_ctxt =
-	    abigail::xml_writer::create_write_context(corp->get_environment(),
-						      cout);
-	  abigail::xml_writer::set_show_locs(*write_ctxt, opts.show_locs);
-	  abigail::xml_writer::set_annotate(*write_ctxt, opts.annotate);
-	  exit_code = !abigail::xml_writer::write_corpus(corp, 0, *write_ctxt);
+	  write_context_sptr write_ctxt
+	      = create_write_context(corp->get_environment(), cout);
+	  set_show_locs(*write_ctxt, opts.show_locs);
+	  set_annotate(*write_ctxt, opts.annotate);
+	  exit_code = !write_corpus(*write_ctxt, corp, 0);
 	}
     }
 
diff --git a/tools/abilint.cc b/tools/abilint.cc
index fab2e6331c8b..0bdc4962dee0 100644
--- a/tools/abilint.cc
+++ b/tools/abilint.cc
@@ -305,7 +305,11 @@ main(int argc, char* argv[])
 	  set_suppressions(*ctxt, opts);
 	  corpus_sptr corp = abigail::xml_reader::read_corpus_from_input(*ctxt);
 	  if (!opts.noout)
-	    write_corpus(corp, /*indent=*/0, cout);
+	    {
+	      const write_context_sptr& ctxt
+		  = create_write_context(corp->get_environment(), cout);
+	      write_corpus(*ctxt, corp, /*indent=*/0);
+	    }
 	  return 0;
 	}
     }
@@ -411,51 +415,35 @@ main(int argc, char* argv[])
 	  return 1;
 	}
 
-      std::iostream& of = tmp_file->get_stream();
-      bool r = true;
+      std::ostream& of = opts.diff ? tmp_file->get_stream() : cout;
+      const abigail::ir::environment* env
+	  = tu ? tu->get_environment() : corp->get_environment();
+      const write_context_sptr ctxt = create_write_context(env, of);
+
+      bool is_ok = true;
 
       if (tu)
 	{
-	  if (opts.diff)
-	    {
-	      const write_context_sptr& ctxt = create_write_context(
-		  tu->get_environment(), tmp_file->get_stream());
-	      r = write_translation_unit(*ctxt, *tu, 0);
-	    }
-	  if (!opts.noout && !opts.diff)
-	    {
-	      const write_context_sptr& ctxt
-		  = create_write_context(tu->get_environment(), cout);
-	      r &= write_translation_unit(*ctxt, *tu, 0);
-	    }
+	  if (!opts.noout)
+	    is_ok = write_translation_unit(*ctxt, *tu, 0);
 	}
       else
 	{
-	  r = true;
-	  if (type == abigail::tools_utils::FILE_TYPE_XML_CORPUS)
+	  if (type == abigail::tools_utils::FILE_TYPE_XML_CORPUS
+	      || type == abigail::tools_utils::FILE_TYPE_ELF)
 	    {
-	      if (opts.diff)
-		r = write_corpus(corp, /*indent=*/0, of);
-
-	      if (!opts.noout && !opts.diff)
-		r &= write_corpus(corp, /*indent=*/0, cout);
+	      if (!opts.noout)
+		is_ok = write_corpus(*ctxt, corp, 0);
 	    }
 	  else if (type == abigail::tools_utils::FILE_TYPE_ZIP_CORPUS)
 	    {
 #ifdef WITH_ZIP_ARCHIVE
 	      if (!opts.noout)
-		r = write_corpus_to_archive(*corp, tmp_file->get_path());
+		is_ok = write_corpus_to_archive(*corp, tmp_file->get_path());
 #endif //WITH_ZIP_ARCHIVE
 	    }
-	  else if (type == abigail::tools_utils::FILE_TYPE_ELF)
-	    {
-	      if (!opts.noout)
-		r = write_corpus(corp, /*indent=*/0, cout);
-	    }
 	}
 
-      bool is_ok = r;
-
       if (!is_ok)
 	{
 	  string output =
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 05/11] abg-writer: Refactor write_corpus_group API
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (2 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 10/11] abidw: add option to only emit file names (--short-locs) Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 09/11] abidw: add option to omit the compilation directory Matthias Maennich via libabigail
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Introduce a new call overload for write_corpus_group that follows the
parameter order context, object (i.e. corpus_group), indent.

Deprecate all other overloads that were part of the API and mostly
forward them to the new overload. That effort is made to ensure
write_context is always provided. write_context allows access to all
options that influence the output format.

	* include/abg-writer.h: Introduce write_corpus_group(ctxt,
	corpus_group, indent) and deprecate all other overloads
	* src/abg-writer.cc: Likewise. Also adjust call sites to use new
	overload.
	* tools/abidw.cc: Migrate to new API of write_corpus_group()

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-writer.h | 31 +++++++++++++++++-------------
 src/abg-writer.cc    | 45 +++++++++++++++++++++++++++++++++-----------
 tools/abidw.cc       | 14 ++++++++++----
 3 files changed, 62 insertions(+), 28 deletions(-)

diff --git a/include/abg-writer.h b/include/abg-writer.h
index d93cc69a3452..45303e42bb15 100644
--- a/include/abg-writer.h
+++ b/include/abg-writer.h
@@ -102,21 +102,26 @@ write_corpus(const corpus_sptr corpus,
 	     const bool	       annotate = false);
 
 bool
-write_corpus_group(const corpus_group_sptr&	group,
-		   unsigned			indent,
-		   write_context&		ctxt);
+write_corpus_group(write_context&	    ctx,
+		   const corpus_group_sptr& group,
+		   unsigned		    indent);
 
-bool
-write_corpus_group(const corpus_group_sptr&	group,
-		   unsigned			indent,
-		   std::ostream&		out,
-		   const bool			annotate = false);
+bool ABG_DEPRECATED
+write_corpus_group(const corpus_group_sptr& group,
+		   unsigned		    indent,
+		   write_context&	    ctxt);
 
-bool
-write_corpus_group(const corpus_group_sptr&	group,
-		   unsigned			indent,
-		   const string&		path,
-		   const bool			annotate = false);
+bool ABG_DEPRECATED
+write_corpus_group(const corpus_group_sptr& group,
+		   unsigned		    indent,
+		   std::ostream&	    out,
+		   const bool		    annotate = false);
+
+bool ABG_DEPRECATED
+write_corpus_group(const corpus_group_sptr& group,
+		   unsigned		    indent,
+		   const string&	    path,
+		   const bool		    annotate = false);
 
 }// end namespace xml_writer
 }// end namespace abigail
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 85f3aebc155a..8280e2342a56 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -4204,17 +4204,17 @@ write_corpus(const corpus_sptr corpus,
 /// Serialize an ABI corpus group to a single native xml document.
 /// The root note of the resulting XML document is 'abi-corpus-group'.
 ///
+/// @param ctxt the write context to use.
+///
 /// @param group the corpus group to serialize.
 ///
 /// @param indent the number of white space indentation to use.
 ///
-/// @param ctxt the write context to use.
-///
 /// @return true upon successful completion, false otherwise.
 bool
-write_corpus_group(const corpus_group_sptr&	group,
-		   unsigned			indent,
-		   write_context&		ctxt)
+write_corpus_group(write_context&	    ctxt,
+		   const corpus_group_sptr& group,
+		   unsigned		    indent)
 
 {
   if (!group)
@@ -4253,6 +4253,27 @@ std::ostream& out = ctxt.get_ostream();
   return true;
 }
 
+/// Serialize an ABI corpus group to a single native xml document.
+/// The root note of the resulting XML document is 'abi-corpus-group'.
+///
+/// @param group the corpus group to serialize.
+///
+/// @param indent the number of white space indentation to use.
+///
+/// @param ctxt the write context to use.
+///
+/// @deprecated use write_corpus_group(ctxt, corpus_group, indent)
+///
+/// @return true upon successful completion, false otherwise.
+bool ABG_DEPRECATED
+write_corpus_group(const corpus_group_sptr& group,
+		   unsigned		    indent,
+		   write_context&	    ctxt)
+
+{
+  return write_corpus_group(ctxt, group, indent);
+}
+
 /// Serialize an ABI corpus group to a single native xml document.
 /// The root note of the resulting XML document is 'abi-corpus-group'.
 ///
@@ -4264,12 +4285,14 @@ std::ostream& out = ctxt.get_ostream();
 ///
 /// @param annotate whether ABIXML output should be annotated.
 ///
+/// @deprecated use write_corpus_group(ctxt, corpus_group, indent)
+///
 /// @return true upon successful completion, false otherwise.
-bool
-write_corpus_group(const corpus_group_sptr&	group,
-		   unsigned			indent,
-		   std::ostream&		out,
-		   const bool			annotate)
+bool ABG_DEPRECATED
+write_corpus_group(const corpus_group_sptr& group,
+		   unsigned		    indent,
+		   std::ostream&	    out,
+		   const bool		    annotate)
 
 {
   if (!group)
@@ -4278,7 +4301,7 @@ write_corpus_group(const corpus_group_sptr&	group,
   write_context ctxt(group->get_environment(), out);
   set_annotate(ctxt, annotate);
 
-  return write_corpus_group(group, indent, ctxt);
+  return write_corpus_group(ctxt, group, indent);
 }
 
 /// Serialize an ABI corpus to a single native xml document.  The root
diff --git a/tools/abidw.cc b/tools/abidw.cc
index 45c0b862aeec..d47088604603 100644
--- a/tools/abidw.cc
+++ b/tools/abidw.cc
@@ -570,12 +570,18 @@ load_kernel_corpus_group_and_write_abixml(char* argv[],
 		<< opts.out_file_path << "'\n";
 	      return 1;
 	    }
-	  exit_code = !xml_writer::write_corpus_group(group, 0, of,
-						      opts.annotate);
+	  const write_context_sptr& ctxt
+	      = create_write_context(group->get_environment(), of);
+	  set_annotate(*ctxt, opts.annotate);
+	  exit_code = !write_corpus_group(*ctxt, group, 0);
 	}
       else
-	exit_code = !xml_writer::write_corpus_group(group, 0, cout,
-						    opts.annotate);
+	{
+	  const write_context_sptr& ctxt
+	      = create_write_context(group->get_environment(), cout);
+	  set_annotate(*ctxt, opts.annotate);
+	  exit_code = !write_corpus_group(*ctxt, group, 0);
+	}
     }
 
   return exit_code;
-- 
2.21.0.1020.gf2820cf01a-goog

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

* [PATCH v1 00/11] Refactor abg-writer
@ 2019-01-01  0:00 Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 04/11] abg-writer: Refactor write_corpus API Matthias Maennich via libabigail
                   ` (11 more replies)
  0 siblings, 12 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Hi!

This patch series refactors the abg-writer API. The main reason is to ensure
that flags added to tools like abidw are consistently passed to the
corresponding write_* functions. In addition, it should be much easier to add
new flags or to ensure consistent behaviour.

The main implementation detail is that all write_* functions now follow the
pattern write_*(context, obj, indent). All flags are passed down via the
context and do not need to be passed along the call chain anymore.

The final cleanup commit breaks backward compatibility of libabigail and is
therefore optional.

Along the way, some bugs related to the propagation of flags to corpus and
corpus-group representations were fixed.

Two new flags were introduced to support reproducibility across different
environments:
  --no-comp-dir-path: omit the compilation directory in xml output
  --short-locs      : only emit file names rather than full (absolute_) paths



Matthias Maennich (11):
  abg-writer: Simplify 'annotate' propagation
  Add deprecation facilities
  abg-writer: Refactor write_translation_unit API
  abg-writer: Refactor write_corpus API
  abg-writer: Refactor write_corpus_group API
  write_context: allow mutating the ostream used
  abidw: Consolidate setting options
  Make write_architecture and write_corpus_path flags in the write_context
  abidw: add option to omit the compilation directory
  abidw: add option to only emit file names (--short-locs)
  abg-writer: drop deprecated API

 include/abg-writer.h     |  75 ++++---
 src/abg-writer.cc        | 409 ++++++++++++++++++++-------------------
 tests/test-read-dwarf.cc |   8 +-
 tools/abidw.cc           |  57 +++---
 tools/abilint.cc         |  49 ++---
 5 files changed, 304 insertions(+), 294 deletions(-)

-- 
2.21.0.1020.gf2820cf01a-goog

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

* Re: [PATCH v1 00/11] Refactor abg-writer
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 04/11] abg-writer: Refactor write_corpus API Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Dodji Seketeli
  2019-01-01  0:00   ` Matthias Maennich via libabigail
  2019-01-01  0:00 ` [PATCH v1 10/11] abidw: add option to only emit file names (--short-locs) Matthias Maennich via libabigail
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: Dodji Seketeli @ 2019-01-01  0:00 UTC (permalink / raw)
  To: Matthias Maennich; +Cc: libabigail, kernel-team

Hello Matthias,


Thank you for this patch series!

It looks good to me so I have applied it to master.

I have however picked a few nits here and there and applied some very
slightly modified versions of the patches.

Please find below the detail of my comments.

[...]

> Subject: [PATCH v1 07/11] abidw: Consolidate setting options

[...]

I just fixed a typo in the description of this patch ...

> When setting options meant to be used for the write_context, it is easy
> to forget to change all relavant locations. In order to consolidate
> that, introduce a set_opts function that sets various known options.
> 
> We benefit from earlier refactoring as now the write_context is passed
> around to carry options for writers. Hence we can be sure, that if we
> set up the context correctly (and do not use deprecated functionality),
> the respective write_* function we see the options set in the context.
                                   ^
                                   |
                                  here: s/we/will.

> 
> 	* include/abg-writer.h: add set_opts(context, options) function
> 	* tools/abidw.cc: use the newly introduced set_opts where applicable

Applied with the fix.

[...]

> Subject: [PATCH v1 07/11] abidw: Consolidate setting options

[...]

> When setting options meant to be used for the write_context, it is easy
> to forget to change all relavant locations. In order to consolidate
> that, introduce a set_opts function that sets various known options.

I have changed the name to set_common_options to make the name be more
self-documented, as there are usually a number of option setting
functions in the code of tools using the library.


[...]

> diff --git a/include/abg-writer.h b/include/abg-writer.h
> index dddb554112e3..071b2075880a 100644
> --- a/include/abg-writer.h
> +++ b/include/abg-writer.h
> @@ -53,6 +53,14 @@ set_show_locs(write_context& ctxt, bool flag);
>  void
>  set_annotate(write_context& ctxt, bool flag);
>  
> +template <typename OPTS>
> +void
> +set_opts(write_context& ctxt, const OPTS& opts)

In addition to changing the name to set_common_options, I have added a
comment for the function.

[...]

> +{
> +  set_annotate(ctxt, opts.annotate);
> +  set_show_locs(ctxt, opts.show_locs);
> +}
> +

> 
> 	* include/abg-writer.h: add set_opts(context, options) function
> 	* tools/abidw.cc: use the newly introduced set_opts where applicable

I have also mentioned the names of the changed functions in the
ChangeLog, following the (GNU) conventions referred to int he
COMMIT-LOG-GUIDLINES file at
https://sourceware.org/git/gitweb.cgi?p=libabigail.git;a=blob;f=COMMIT-LOG-GUIDELINES.


[...]

Subject: [PATCH v1 10/11] abidw: add option to only emit file names (--short-locs)

[...]

> 
> 	* include/abg-writer.h: add set_short_locs and use it within
> 	set_opts
> 	* src/abg-writer.cc (write_context): add m_short_locs flag along
> 	with getters and setters
> 	(write_*): emit short paths for filenames if asked for
> 	* tools/abidw.cc: add short-locs option

Likewise, I updated this to comply with the ChangeLog rules.  I have
also updated all the other ChangeLogs, basically.

[...]

> +static std::string
> +get_filename(const std::string& path)
> +{

There is already a function in abg-tools-utils.{h,cc} which name is
abigail::tools_utils::base_name which has a similar functionality.  I
have amended the patch to use that one, rather than defining this one
here.

[...]

So thanks again for this nice patchset.

Cheers,

-- 
		Dodji

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

* [PATCH v1 02/11] Add deprecation facilities
  2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
                   ` (10 preceding siblings ...)
  2019-01-01  0:00 ` [PATCH v1 01/11] abg-writer: Simplify 'annotate' propagation Matthias Maennich via libabigail
@ 2019-01-01  0:00 ` Matthias Maennich via libabigail
  11 siblings, 0 replies; 17+ messages in thread
From: Matthias Maennich via libabigail @ 2019-01-01  0:00 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, Matthias Maennich

Add the macro 'ABG_DEPRECATED' to mark APIs as to be removed in a next
major release. APIs marked with that flag are supposed to work as
before, but might come with downsides. E.g. they could perform worse or
provide only limited functionality. All deprecated functions shall come
with a hint to equivalent functionality within the non-deprecated part
of the API.

	* include/abg-fwd.h: Introduce deprecation macro ABG_DEPRECATED

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-fwd.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/abg-fwd.h b/include/abg-fwd.h
index ddec06d8d29c..e9258008f963 100644
--- a/include/abg-fwd.h
+++ b/include/abg-fwd.h
@@ -1342,5 +1342,14 @@ dump_decl_location(const decl_base_sptr&);
 #define ABG_ASSERT(cond) do {({bool __abg_cond__ = (cond); assert(__abg_cond__); !!__abg_cond__;});} while (false)
 #endif
 
+/// Define ABG_DEPRECATED to allow marking parts of the API deprecated without
+/// actually removing it. This allows to keep compatible (yet incomplete) APIs
+/// around for a transition period into a major version.
+#ifdef __GNUC__
+#define ABG_DEPRECATED __attribute__((deprecated))
+#else
+#define ABG_DEPRECATED
+#endif
+
 } // end namespace abigail
 #endif // __ABG_IRFWD_H__
-- 
2.21.0.1020.gf2820cf01a-goog

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

end of thread, other threads:[~2019-05-28 10:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  0:00 [PATCH v1 00/11] Refactor abg-writer Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 04/11] abg-writer: Refactor write_corpus API Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 00/11] Refactor abg-writer Dodji Seketeli
2019-01-01  0:00   ` Matthias Maennich via libabigail
2019-01-01  0:00     ` Dodji Seketeli
2019-01-01  0:00       ` Libabigail release (was: [PATCH v1 00/11] Refactor abg-writer) Matthias Maennich via libabigail
2019-01-01  0:00         ` Mark Wielaard
2019-01-01  0:00 ` [PATCH v1 10/11] abidw: add option to only emit file names (--short-locs) Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 05/11] abg-writer: Refactor write_corpus_group API Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 09/11] abidw: add option to omit the compilation directory Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 08/11] Make write_architecture and write_corpus_path flags in the write_context Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 03/11] abg-writer: Refactor write_translation_unit API Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 06/11] write_context: allow mutating the ostream used Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 11/11] abg-writer: drop deprecated API Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 07/11] abidw: Consolidate setting options Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 01/11] abg-writer: Simplify 'annotate' propagation Matthias Maennich via libabigail
2019-01-01  0:00 ` [PATCH v1 02/11] Add deprecation facilities Matthias Maennich via libabigail

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